php: 源码安装
1、安装前系统工具安装:
yum install gcc autoconf gcc-c++
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel
yum install systemd-devel
yum install openjpeg-devel
yum install -y icu libicu libicu-devel
yum install sqlite-devel
yum install oniguruma-devel
2、添加php-fpm用户
创建群组
groupadd www-data
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www-data -M www-data
step 1: 编译参数
./configure --prefix=/usr/local/php -with-config-file-path=/usr/local/php/etc --with-mysqli --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache --with-xsl
step 2: make && make install
复制一份到指定的目录下(根据自己的情况选用,自己可以对比下这两个文件的差异):
cp php.ini-production /usr/local/php/etc/php.ini
php-fpm复制一份新的php-fpm配置文件:
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
配置错误日志:
error_log = /usr/local/php/var/php-fpm.log
配置pid文件:
pid = /usr/local/php/var/run/php-fpm.pid
保存退出
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
管理php-fpm配置:
cd /usr/local/src/php-7.2.4
cp ./sapi/fpm/php-fpm.service 到 /usr/lib/systemd/system/下
vim /usr/lib/systemd/system/php-fpm.service
把
ProtectSystem=full
改成
ProtectSystem=false
配置开机启动php-fpm:
systemctl enable php-fpm
启动php-fpm:
systemctl start php-fpm
查看状态:
systemctl status php-fpm
添加环境变量:
vim /etc/profile
在末尾追加:
export PATH=$PATH:'/usr/local/php/bin/'
保存退出。
source /etc/profile
测试:
php -v