1、环境介绍
操作系统:Centos7.3 Linux
版本:PHP5.6.34
镜像源:阿里镜像源
2、安装依赖包
yum -y install gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel
3、编译安装
tar zxf php-5.6.34.tar.gz
cd php-5.6.34
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm
make
make install
cp php.ini-production /usr/local/php/etc/php.ini
4、使用systemctl管理php-fpm:
目录创建:
mkdir –p /usr/lib/system/system/
/usr/lib/system/system/php-fpm.service
[Unit]
Description=php-fpm
After=network.target#网络启动以后启动
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
[Install]
WantedBy=multi-user.target
5、启动
环境变量:
export PATH=$PATH:/usr/local/php/sbin/:/usr/local/bin/
生成配置文件:
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
启动:
php-fpm –t检查
systemctl start php-fpm或者php-fpm
netstat -lntup|grep php
6、文件目录
目录/usr/local/php/:
lib var sbin php include bin etc