下载
http://php.net/downloads.php
安装需要配置的资源包
yum -y install libxml2 yum -y install libxml2-devel yum -y install openssl yum -y install openssl-devel yum -y install curl yum -y install curl-devel yum -y install libjpeg yum -y install libjpeg-devel yum -y install libpng yum -y install libpng-devel yum -y install freetype yum -y install freetype-devel yum -y install pcre yum -y install pcre-devel yum -y install libxslt yum -y install libxslt-devel yum -y install bzip2 yum -y install bzip2-devel
安装PHP(php7.2不支持这两个选项:–with-mcrypt, –enable-gd-native-ttf)
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fileinfo
make&&make install
复制
cp php.ini-development /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp sapi/fpm/php-fpm /usr/local/bin
修改/usr/local/php/lib/php.ini
cgi.fix_pathinfo=0
创建用户和组
groupadd www-data
useradd -g www-data www-data
修改php/etc/php-fpm.conf最后include(如果是/usr/local则不用改)
NONE改为/usr/local
修改配置
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf vim /usr/local/php/etc/php-fpm.d/www.conf user=www-data group=www-data
启动
/usr/local/bin/php-fpm或php-fpm
kill -INT PID #关闭
killall php-fpm #关闭
kill -USR2 PID #重启
修改/usr/local/php/etc/php-fpm.conf中pid = run/php-fpm.pid,重启,即可使用
启动:/usr/local/php/sbin/php-fpm
重启:kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
停止:kill -INT `cat /usr/local/php/var/run/php-fpm.pid`
设置开机启动:
touch /usr/lib/systemd/system/php-fpm.service文件: [Unit] Description=php-fpm After=network.target [Service] Type=forking ExecStart=/usr/local/php/sbin/php-fpm ExecReload=kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` ExecStop=kill -INT `cat /usr/local/php/var/run/php-fpm.pid` PrivateTmp=true [Install] WantedBy=multi-user.target 启动nginx服务:systemctl start php-fpm.service 设置开机自启动:systemctl enable php-fpm.service 停止开机自启动:systemctl disable php-fpm.service 查看服务当前状态:systemctl status php-fpm.service 重新启动服务:systemctl restart php-fpm.service 查看所有已启动的服务:systemctl list-units --type=service 查看是否开机启动,检查/etc/systemd/system/multi-user.target.wants/下是否有你需要开机启动的软连接
修改nginx.conf,添加默认支持index.php,修改支持php,修改user
user www-data www-data; location / { root html; index index.php index.html index.htm; } 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; }
重启nginx
nginx -s stop
nginx
查看