设为首页 加入收藏

TOP

LNMP环境搭建(三)
2019-08-23 00:32:39 】 浏览:51
Tags:LNMP 环境 搭建
usr/local/php/sbin/php-fpm &

启动PHP-FPM

cd /usr/local/php
sbin/php-fpm # 启动PHP-FPM
ps -e | grep php-fpm

配置Nginx和PHP关联

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    use epoll;
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    
    #隐藏Nginx软件版本号
    server_tokens off;
    
    #激活tcp_nodelay功能,提高I/O性能
    tcp_nodelay on;

    # 设置读取客户端请求头数据的超时时间。此处的数值为15,其单位是秒,为经验参考值
    client_header_timeout 15;

    # 设置读取客户端请求体的超时时间
    client_body_timeout 15;

    # 指定响应客户端的超时时间
    send_timeout 25;

    # 上传文件大小限制
    client_max_body_size 8m;
    
    #压缩配置
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types text/css text/xml text/plain application/java script;
    gzip_vary on;
    #include extra/gzip.config;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
         listen       80;
         server_name  www.nginx.com;
         root html/blog/public;
         #access_log  logs/host.access.log  main;

         location / {
            index  index.php index.html index.htm;
            if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php/$1 last;
            }
         }

         #error_page  404              /404.html;

         # redirect server error pages to the static page /50x.html
         #
         error_page   500 502 503 504  /50x.html;
         location = /50x.html {
            root   html;
         }

         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
         #
         location ~ \.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
         }
    }
}

CentOS7开机/etc/rc.local不执行问题

CentOS7中,默认开机不再执行/etc/rc.local,查询/etc/rc.local里的内容可以发现如下描述:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In constrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

翻译过来就是


#这个文件是为了兼容性的问题而添加的。
#
#强烈建议创建自己的systemd服务或udev规则来在开机时运行脚本而不是使用这个文件。
#
#与以前的版本引导时的并行执行相比较,这个脚本将不会在其他所有的服务后执行。
#
#请记住,你必须执行“chmod +x /etc/rc.d/rc.local”来确保确保这个脚本在引导时执行。

所以要解决开机不执行问题,只需要执行下面的命令然后重启服务器。

chmod +x /etc/rc.d/rc.local

完成上面这些步骤,一个LNMP环境就配好啦,重启服务器即可。

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[Linux] 简单安装和使用composer 下一篇使用PHP、MySQL实现修改密码 + 防..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目