下载php
[root@localhost ~]# cd /usr/local/src[root@localhost src]# lshttpd-2.2.31 mysql-5.6.29-linux-glibc2.5-x86_64.tar.gzhttpd-2.2.31.tar.bz2[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.24.tar.gz[root@localhost src]# lshttpd-2.2.31 mysql-5.6.29-linux-glibc2.5-x86_64.tar.gzhttpd-2.2.31.tar.bz2 php-5.6.24.tar.gz
解压
[root@localhost src]# tar zxf php-5.6.24.tar.gz[root@localhost src]# lshttpd-2.2.31 php-5.6.24httpd-2.2.31.tar.bz2 php-5.6.24.tar.gzmysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
配置编译参数
[root@localhost src]# cd php-5.6.24[root@localhost php-5.6.24]# ./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-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 \> --disable-ipv6
错误1
configure: error: xml2-config not found. Please check your libxml2 installation.
解决方案
yum install -y libxml2-devel
错误2
configure: error: Cannot find OpenSSL's
解决方案
yum install -y openssl openssl-devel
错误3
checking for BZip2 in default path... not foundconfigure: error: Please reinstall the BZip2 distribution
解决方案
yum install -y bzip2 bzip2-devel
错误4
configure: error: png.h not found.
解决方案
yum install -y libpng libpng-devel
错误5
configure: error: freetype.h not found.
解决方案
yum install -y freetype freetype-devel
错误6
configure: error: jpeglib.h not found.
解决方案
[root@localhost php-5.6.24]# yum install -y libjpeg-devel
错误7
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方案
cd /usr/local/srcwget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gztar -zxvf libmcrypt-2.5.7.tar.gzcd libmcrypt-2.5.7./configure --prefix=/usr/localmakemake install
重新配置编译参数
[root@localhost src]# cd /usr/local/src/php-5.6.24/[root@localhost php-5.6.24]# ./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-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 \> --disable-ipv6
编译
[root@localhost php-5.6.24]# make[root@localhost php-5.6.24]# echo $?0
安装
[root@localhost php-5.6.24]# make install[root@localhost php-5.6.24]# echo $?0
查看
[root@localhost php-5.6.24]# ls /usr/local/php/bin etc include lib php
模块
[root@localhost php-5.6.24]# /usr/local/php/bin/php –m
配置信息
[root@localhost php-5.6.24]# /usr/local/php/bin/php –i
如果Apache在运行,重启Apache
[root@localhost ~]# /usr/local/apache2/bin/apachectl restart
如果没有运行Apache,启动Apache
[root@localhost ~]# /usr/local/apache2/bin/apachectl start
修改Apache配置文件
[root@localhost htdocs]# vim /usr/local/apache2/conf/httpd.conf
找到
AddType application/x-gzip .gz .tgz 在该行下面添加 AddType application/x-httpd-php .php 找到 DirectoryIndex index.html 将该行改为 DirectoryIndex index.html index.htm index.php 找到 Options FollowSymLinks AllowOverride None Order deny,allow Deny from all 改为 Options FollowSymLinks AllowOverride None Order deny,allow Allow from all[root@localhost htdocs]# /usr/local/apache2/bin/apachectl -tSyntax OK[root@localhost htdocs]# /usr/local/apache2/bin/apachectl graceful
拷贝php配置文件
[root@localhost htdocs]# cp /usr/local/src/php-5.6.24/php.ini-production /usr/local/php/etc/php.ini[root@localhost htdocs]# /usr/local/apache2/bin/apachectl graceful