CentOS7 编译安装php5.6

1. 安装依赖环境

yum install epel-release -y
 yum install libicu-devel libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel -y

2. 下载源码包

wget https://www.php.net/distributions/php-5.6.40.tar.gz

3. 编译安装

[root@localhost php-5.6.40]# ./configure \
--prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/etc \
--with-config-file-scan-dir=/usr/local/php56/conf.d \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--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 \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--enable-fileinfo \
--enable-opcache \
--enable-intl \
--with-xsl

[root@localhost php-5.6.40]# make && make install
cp php.ini-production /usr/local/php56/etc/php.ini
cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php56-fpm
[root@localhost php-5.6.40]# chmod +x /etc/init.d/php56-fpm
[root@localhost php-5.6.40]# /etc/init.d/php56-fpm start

4. 配置环境变量

[root@localhost php-5.6.40]# vim /etc/profile
PATH=$PATH:/usr/local/php56/bin
export PATH

5. 添加运行用户组

useradd www -M -d / -s /usr/sbin/nologin

6. 配置开机启动

[root@localhost wwwroot]# chkconfig --add php56-fpm
[root@localhost wwwroot]# chkconfig php56-fpm on
[root@localhost wwwroot]# systemctl enable php56-fpm
php56-fpm.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig php56-fpm on
[root@localhost wwwroot]# 

7.PHP进程数的设置

[root@localhost php-5.6.40]# vim /usr/local/php56/etc/php-fpm.conf
pm.max_children = 100
pm.start_servers = 30
pm.min_spare_servers = 20
pm.max_spare_servers = 100
pm.max_requests = 500

8.PHP禁用危险函数

在 /usr/local/php56/etc/php.ini 下添加
disable_functions = phpinfo,passthru,chroot,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen,symlink,popen,stream_socket_server

讨论数量: 0

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!