美文网首页我爱编程
Centos7编译Nginx+PHP+MySql《二》

Centos7编译Nginx+PHP+MySql《二》

作者: kaibiao123 | 来源:发表于2016-12-27 21:05 被阅读29次

    一、准备工作

    1.1 安装vim

    # yum install vim

    二、开始配置(nginx篇)

    2.1 修改nginx.conf

    # vim nginx.conf

    2.2 找到如下内容,并删除 斜划线 标记的字符

    # pass the PHP scripts to FastCGI server listening on127.0.0.1:9000

    #

     # location~\.php$ {#root          html;

                # fastcgi_pass127.0.0.1:9000;

               # fastcgi_index  index.php;

                # fastcgi_param  SCRIPT_FILENAME   /scripts$fastcgi_script_name;

                # include        fastcgi_params;       

     # }

    2.3 修改完成

    # pass the PHP scripts to FastCGI server listening on127.0.0.1:9000

    #

    location~\.php$ {

    root          html;

    fastcgi_pass         127.0.0.1:9000;            

    fastcgi_index        index.php;            

    fastcgi_param       SCRIPT_FILENAME     $document_root$fastcgi_script_name;            

    include                   fastcgi_params;        

    }

    2.4 输出phpinfo文件

    2.5 启动nginx

    /lnmp/nginx/sbin/nginx

    小章总结:

    完成上面的修改就可以让nginx来转发php的动态脚本请求。

    不过目前还不能打开php文件,因为还没有打开php-fpm。

    我们继续向下看。

    三、开始配置(php-fpm)

    3.1 copy默认配置文件

    # cd /source/php-7.0.2

    # cp php.ini-development /lnmp/php/etc/php.ini

    # cd /lnmp/php/etc

    # cp php-fpm.conf.default php-fpm.conf

    # cd /lnmp/php/etc/php-fpm.d/

    # cp www.conf.default www.conf

    3.2 运行php-fpm

    # /lnmp/php/sbin/php-fpm -c /lnmp/php/etc/php.ini

    二、常用命令

    nginx常用命令

    启动nginx

    # /lnmp/nginx/sbin/nginx

    重启nginx

    # /lnmp/nginx/sbin/nginx -s reload

    关闭nginx

    # /lnmp/nginx/sbin/nginx -s stop

    php-fpm常用命令

    启动php-fpm

    # /lnmp/php/sbin/php-fpm -c /lnmp/php/etc/php.ini

    重启php-fpm

    # kill -SIGUSR2 `cat /lnmp/php/var/run/php-fpm.pid`

    关闭php-fpm

    # kill -SIGINT `cat /lnmp/php/var/run/php-fpm.pid`

    信号解释:

    SIGINT, SIGTERM 立刻终止

    SIGQUIT 平滑终止

    SIGUSR1 重新打开日志文件

    SIGUSR2 平滑重载所有worker进程并重新载入配置和二进制模块

    相关文章

      网友评论

        本文标题:Centos7编译Nginx+PHP+MySql《二》

        本文链接:https://www.haomeiwen.com/subject/ocpevttx.html