一、下载源码
wget http://be2.php.net/distributions/php-7.2.8.tar.gz
二、解压源码
tar -zxvf php-7.2.8.tar.gz
三、安装编译所需环境
yum -y install libxml2-devel openssl-devel libcurl-devel libpng-devel freetype-devel libxslt-devel
四、配置
./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-xmlrpc \ --with-xsl \ --with-zlib \ --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-xml \ --enable-zip
vim ~/.bash_aliases
写入信息:
alias php='/usr/local/php/bin/php' alias phpize='/usr/local/php/bin/phpize' alias php-fpm='/usr/local/php/sbin/php-fpm'
使设置生效
source ~/.bash_aliases
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 /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on
设置服务
vim /lib/systemd/system/php-fpm.service
[Unit] Description=php-fpm After=network.target [Service] Type=forking ExecStart=/usr/local/php/sbin/php-fpm PrivateTmp=true [Install] WantedBy=multi-user.target
vim /usr/local/php/etc/php-fpm.d/www.conf
user = www-data group = www-data listen = 127.0.0.1:9000 ;listen = /run/php/php7.0-fpm.sock listen.owner = www-data listen.group = www-data pm.max_requests = 5000
注:需要创建/run/php目录
mkdir /run/php
修改php.ini配置
vim /usr/local/php/lib/php.ini
post_max_size = 100M upload_max_filesize = 80M date.timezone = PRC
启动php-fpm
service php-fpm start