CentOS7.3编译安装PHP

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7.3编译安装PHP相关的知识,希望对你有一定的参考价值。

系统:CentOS Linux release 7.3.1611
内核:3.10.0-514.el7.x86_64
php:php-5.3.27.tar.gz

步骤:
#yum install -y libxml2 libxml2-devel curl curl-devel freetype freetype-devel libpng libpng-devel libjpeg-devel openssl openssl-devel

下载php:
#wget http://am1.php.net/distributions/php-5.3.27.tar.gz
#cp php-5.3.27.tar.gz /usr/local/src
#cd /usr/local/src
#tar -zxvf php-5.3.27.tar.gz
#useradd -s /sbin/nologin php-fpm
#./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl
#make
#make test
#make install

编辑配置文件:
#cd /usr/local/php/etc/
#cp php-fpm.conf.default php-fpm.conf
#vim /usr/local/php/etc/php-fpm.conf

加入如下配置信息:
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024

检查配置文件语法是否正确:
#/usr/local/php/sbin/php-fpm -t
出现NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful即成功
#cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#chmod 755 /etc/init.d/php-fpm
#chmod php-fpm on

启动php-fpm
#/etc/init.d/php-fpm start

查看进程:
#ps aux | grep php-fpm

至此,php编译安装完成。

以上是关于CentOS7.3编译安装PHP的主要内容,如果未能解决你的问题,请参考以下文章

追月,Linux云服务器编译安装最新ApachePHP和MySQL

如何编译安装PHP扩展

Docker 编译安装php7.3

编译安装 PHP 扩展

PHP8、FPM及部分扩展编译安装

php5.5.38编译安装