当前位置 主页 > 服务器问题 > nginx问题汇总 >

    CentOS 7.2 下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法(3)

    栏目:nginx问题汇总 时间:2019-02-20 16:36

    2、编译步骤如下

      1、用winSCP上传php-7.0.10.tar.gz到/root目录下

      2、tar -zvxf php-7.0.10.tar.gz #解压

      3、配置编译php参数, 可使用./configure --help命令查看所有编译配置项目, 下列参数要写在一行中

     ./configure     --prefix=/usr/local/php    --exec-prefix=/usr/local/php    --datadir=/usr/local/php    --with-config-file-path=/usr/local/php/etc    --with-mysqli=mysqlnd    --with-pdo-mysql=mysqlnd    --with-fpm-user=nginx    --with-fpm-group=nginx    --with-gd    --with-iconv    --enable-mbstring    --enable-fpm    --enable-mysqlnd

      4、make && make install #编译并安装

      5、cd /usr/local/php #进入编译目录

      6、修改相关配置文件

        6.1 cp /usr/local/php/etc/php.ini.default /usr/local/php/etc/php.ini #php.ini中相关配置依项目需要自行修改,配置nginx支持php参考http://php.net/manual/zh/install.unix.nginx.php

        6.2 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #去掉[global]项下pid前的;

        6.3 cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf #大致在23、24行修改user和group如:user = nginx,group = nginx

      7、chmod 777 /usr/local/php/var/run #默认PID文件是写在/usr/local/php/var/run这个目录中,所以修改目录权限

      8、sbin/php-fpm #启动php, 可通过sbin/php-fpm -h 查看相关操作命令列表

      9、在/usr/lib/systemd/system目录下新建php-fpm.service文件,这样就可以通过systemctl stop|start|reload php-fpm.service来操作php-fpm,内容如下:

     [Unit]    Description=The PHP FastCGI Process Manager    After=syslog.target network.target    Before=nginx.service    [Service]    Type=forking    PIDFile=/usr/local/php/var/run/php-fpm.pid    ExecStart=/usr/local/php/sbin/php-fpm    ExecStop=/bin/kill -QUIT `cat /usr/local/php/var/run/php-fpm.pid`    ExecReload=/bin/kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`    PrivateTmp=true    [Install]    WantedBy=multi-user.target

    五、至此在我的VirturBox中CentOS7.2下成功搭建了LNMP环境

    以上所述是小编给大家介绍的CentOS 7.2 下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法详解(mini版本),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对IIS7站长之家网站的支持!