1.系统环境(最小化安装)
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@c72 /]# uname -a
Linux c72 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
1.1.准备:
1.2.所有wget下载的包默认都放在/tmp目录下
安装必要工具
# yum install -y wget "vim-e*"
1.3.一、安装gcc gcc-c++ libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libxslt-devel
# yum install -y gcc gcc-c++ libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libxslt-devel
注:如不安装以上的包,将会出现报错信息,具体见下文
1.4.二、解压php-5.6.36并进入解压目录
# tar -xzvf php-5.6.36.tar.gz
# cd php-5.6.36
1.5.三、开始生成php的编译配置文件并解决各类报错
# ./configure –prefix=/usr/local/php56 –with-curl –with-freetype-dir –with-gd –with-gettext –with-iconv-dir –with-kerberos –with-libdir=lib64 –with-libxml-dir –with-mysql –with-mysqli –with-openssl –with-pcre-regex –with-pdo-mysql –with-pdo-sqlite –with-pear –with-png-dir –with-xmlrpc –with-jpeg-dir –with-xsl –with-zlib –enable-fpm –enable-bcmath –enable-libxml –enable-inline-optimization –enable-gd-native-ttf –enable-mbregex –enable-mbstring –enable-opcache –enable-pcntl –enable-shmop –enable-soap –enable-sockets –enable-sysvsem –enable-xml –enable-zip
如果不进行第一步的安装,报错处理方法如下
分割条头:****************************************************************************************************开始
报错1:
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
处理方法1:
# yum install -y libxml2-devel
报错2:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
处理方法2:
# yum install -y libcurl-devel
报错3:
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-vpx-dir=
configure: error: jpeglib.h not found.
处理方法3:
# yum install -y libjpeg-devel
报错4:
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
处理方法4:
# yum install -y libpng-devel
报错5:
configure: error: freetype-config not found.
处理方法5:
# yum install -y freetype-devel
报错6:
checking for XSL support... yes
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
处理方法6:
# yum install -y libxslt-devel
报错处理分割条尾:****************************************************************************************************结束
生成编译的配置文件成功之后显示如下信息:
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
1.6.四、开始编译及安装
# make && make install
报错7:
处理方法7:
# yum install -y openssl-devel
安装完成如下图:
1.7.五、配置chkconfig管理php-fpm并设置开机自启动
php.ini-production 线上版本使用
php.ini-development 开发版本使用
# cp /tmp/php-5.6.36/php.ini-development /usr/local/php56/etc/php.ini
# cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
# cp /tmp/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# cd /etc/init.d/
# chmod 755 php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
# vim /usr/local/php56/etc/php-fpm.conf
;pid = run/php-fpm.pid
取消前面的注释;
# service php-fpm start
1.8.六、测试是否成功,php-fpm默认端口9000
# netstat -nultp |grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 32633/php-fpm: mast
IT博客站版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:CentOS7.2环境源码编译安装Php5.6.36