PHP,是英文超文本预处理语言Hypertext Preprocessor的缩写。PHP 是一种 HTML 内嵌式的语言,是一种在服务器端执行的嵌入HTML文档的脚本语言。官网:www.php.net
[root@zlinux bin]# cd /usr/local/src/
[root@zlinux src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
[root@zlinux src]# tar jxf php-5.6.30.tar.bz2
[root@zlinux src]# cd php-5.6.30/
[root@zlinux php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
参数说明:
–prefix=/usr/local/php 指定的安装目录;
–with-apxs2=/usr/local/apache2/bin/apxs 该文件是Apache的一个工具,可以将扩展模块添加到Apache的module文件;
–with-config-file-path=/usr/local/php/etc 指定配置文件所在路径;
–with-mysql=/usr/local/mysql 指定mysql的路径;
–with-mysqli=/usr/local/mysql/bin/mysql_config
–with-pdo-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config 上面两项参数是指定相关mysql库
–with-libxml-dir –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-iconv-dir –with-zlib-dir –with-bz2 –with-openssl –with-mcrypt –enable-soap –enable-gd-native-ttf –enable-mbstring –enable-sockets –enable-exif
configure: error: xml2-config not found. Please check your libxml2 installation.
解决方法:
[root@zlinux php-5.6.30]# yum list | grep libxml2
[root@zlinux php-5.6.30]# yum install -y libxml2-devel
configure: error: Cannot find OpenSSL‘s <evp.h>
解决方法:
[root@zlinux php-5.6.30]# yum install -y openssl-devel
configure: error: Please reinstall the BZip2 distribution
解决办法:
[root@zlinux php-5.6.30]# yum install -y bzip2-devel
configure: error: jpeglib.h not found.
解决方法:
[root@zlinux php-5.6.30]# yum install -y libjpeg-devel
configure: error: png.h not found.
解决方法:
[root@zlinux php-5.6.30]# yum install -y libpng-devel
configure: error: freetype-config not found.
解决方法:
[root@zlinux php-5.6.30]# yum install -y freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法:
[root@zlinux php-5.6.30]# yum list |grep libmcrypt
libmcrypt.x86_64 2.5.8-13.el7 epel
libmcrypt-devel.x86_64 2.5.8-13.el7 epel
[root@zlinux php-5.6.30]# yum install -y libmcrypt-devel
如果没有这个安装包,则需要安装下yum扩展包:
[root@zlinux php-5.6.30]# yum install epel-release
[root@zlinux php-5.6.30]# make //编译
[root@zlinux php-5.6.30]# echo $? //检查上一条命令是否正确
[root@zlinux php-5.6.30]# make install //安装
[root@zlinux php-5.6.30]# echo $? //检查上一条命令是否正确,也就是安装是否出错
[root@zlinux php-5.6.30]# cp php.ini-
php.ini-development php.ini-production
[root@zlinux php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini //正常情况下使用php.ini-production,开发环境可以使用php.ini-development
[root@zlinux php-5.6.30]# /usr/local/php/bin/php -i | less
[root@zlinux php-5.6.30]# cat /usr/local/apache2/conf/httpd.conf | grep php
LoadModule php5_module modules/libphp5.so
安装过程与PHP5安装过程类似。
需要注意的是:
apache服务器可以存在2种版本的php,通过在apache的配置文件中注释掉相应的行来关闭某个版本的php模块.
[root@zlinux ~]# vim /usr/local/apache2/conf/httpd.conf
如果不使用PHP7,在LoadMoudle
前面加#
即可。
原文地址:http://blog.51cto.com/3069201/2074020