#cd /usr/local/src
#wget http://mirrors.sohu.com/php/php-5.4.44.tar.gz
#tar zxf php-5.4.44.tar.gz //解压源码包
#./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
错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
解决办法是:yum install -y libxml2-devel
错误:
configure: error: Cannot find OpenSSL's <evp.h>
解决办法是:yum install -y openssl openssl-devel
错误:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解决办法:yum install -y bzip2 bzip2-devel
错误:
configure: error: png.h not found.
解决办法:yum install -y libpng libpng-devel
错误:configure: error: freetype.h not found.
解决办法:yum install -y freetype freetype-devel
错误:
configure: error: jpeglib.h not found.
解决方法: yum install libjpeg-devel
错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源,解决办法:
rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
yum install -y libmcrypt-devel
3方rpm包,安装对应的rpm包
centos5 32位epel源下载地址: www.lishiming.net/data/attachment/forum/epel-release-5-4_32.noarch.rpm
64位下载地址: www.lishiming.net/data/attachment/forum/epel-release-5-4_64.noarch.rpm
centos6
32位epel yum源下载地址: www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm
64位下载地址: www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
#make //编译
#make install //安装
#cp php.ini-production /usr/local/php/etc/php.ini //拷贝php配置文件
# vi /usr/local/apache2/conf/httpd.conf //修改apache配置文件
修改:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改为:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all //不修改访问网站会禁止访问,显示403
</Directory>
找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
添加:
AddType application/x-httpd-php .php //支持php解析,加上对应类型
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
改为:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php //针对php索引,默认页为index.php,需加上index.php
</IfModule>
找到:
#ServerName www.example.com:80
改为:
ServerName localhost:80
查看配置文件是否有文化:
#/usr/local/apache2/bin/apachectl –t //显示syntax OK,配置没问题
# /usr/local/apache2/bin/apachectl start //启动服务
# ps aux|grep httpd //检查是否有进程列表