CentOS 7.2 下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法详解(mini版

2019-05-03 02:47:21王振洲

8.2 通过winSCP修改/etc/init.d/mysqld文件

    8.2.1 basedir=/usr/local/mysql #手动指定

    8.2.2 datadir=/usr/local/mysql/data #手动指定

    8.2.3 mysqld_pid_file_path=/usr/local/mysql/mysqld.pid #手动指定

    8.2.4 把此文件中所有未注释的含有mysqld_safe的字符替换成mysqld

四、编译安装php

1、去官网http://php.net/downloads.php下载php7.0.10版本

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环境

相关文章 大家在看