安装php的依赖包
[root@localhost admin]# unzip libxml2-2.7.8.tar.zip
[root@localhost admin]#tar zvxf libxml2-2.7.8.tar.gz
[root@localhost admin]# cd libxml2-2.7.8
[root@localhost libxml2-2.7.8]# mkdir /usr/local/libxml2
[root@localhost libxml2-2.7.8]# ./configure --prefix=/usr/local/libxml
[root@localhost libxml2-2.7.8]# make && make install [root@localhost admin]# tar zvxf libmcrypt-2.5.8.tar.gz
[root@localhost admin]# cd libmcrypt-2.5.8
[root@localhost libmcrypt-2.5.8]# ./configure --prefix=/usr
[root@localhost libmcrypt-2.5.8]# make && make install [root@localhost admin]# tar zvxf mhash-0.9.9.9.tar.gz
[root@localhost mhash-0.9.9.9]# ./configure --prefix=/usr
[root@localhost mhash-0.9.9.9]# make && make install [root@localhost admin]# tar zvxf libiconv-1.14.tar.gz
[root@localhost admin]# cd libiconv-1.14
[root@localhost libiconv-1.14]# mkdir /usr/local/libiconv
[root@localhost libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@localhost libiconv-1.14]# make && make install [root@localhost admin]# tar zvxf mcrypt-2.6.8.tar.gz
[root@localhost admin]# cd mcrypt-2.6.8
[root@localhost mcrypt-2.6.8]# ./configure --prefix=/usr
[root@localhost mcrypt-2.6.8]# make && make install [root@localhost admin]# tar zvxf php-5.2.27.tar.gz
[root@localhost admin]# cd php-5.2.27
[root@localhost php-5.3.27]# mkdir /usr/local/php
[root@localhost php-5.3.27]# ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-openssl \
--with-zlib \
--enable-bcmath \
--with-bz2 \
--with-gd\
--with-jpeg-dir\
--enable-gd-native-ttf \
--with-gettext \
--with-mhash \
--enable-mbstring \
--with-mcrypt \
--enable-zip \
--with-iconv=/usr/local/libiconv \
--with-curl \
--enable-soap \
--enable-sockets\
--enable-ftp \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql\
--without-pearble
[root@localhost php-5.3.27]# make && make install
如果编译php出现
/usr/bin/ld:cannot find -lltdl
collect2:ld returned l exit status
make:*** [libphp5.la] ? . . l
安装libtool-ltdl-devel既可解决
yum install libtool-ltdl-devel
make && make install
PHP编译参数解释:
--prefix=/usr/local/php : 设置安装路径
--with-apxs2=/usr/local/apache/bin/apxs : 编译共享的 Apache 2.* 模块
--with-config-file-path=/etc : 指定配置文件php.ini地址
--with-config-file-scan-dir=/etc/php.d : 指定额外的ini文件目录
--with-openssl : 编译OpenSSL支持
--with-zlib : 编译zlib支持
--enable-bcmath : 启用BC风格精度数学函数
--with-bz2 : BZip2支持
--with-gd : GD支持
--enable-gd-native-ttf : 启用TrueType字符串函数
--with-gettext : 启用GNU gettext支持
--with-mhash : mhash支持
--enable-mbstring : 启用支持多字节字符串
--with-mcrypt : 编译mcrypt加密支持
--enable-zip : 启用zip 读/写支持
--with-iconv=/usr/local/libiconv : iconv支持
--with-curl : CRUL支持
--enable-soap : SOAP支持
--enable-sockets : SOCKETS支持
--enable-ftp : FTP支持
--with-mysql=/usr/local/mysql : 启用mysql支持
--with-pdo-mysql=/usr/local/mysql : 启用pdo-mysql支持
--without-pear : 不安装PEAR
配置:
#复制配置文件php.ini
[root@localhost php-5.3.27]# cp ./php.ini-development /etc/php.ini
#在apache 中添加对php的支持
[root@localhost etc]# cd /usr/local/apache2/conf/
[root@localhost conf]# vi httpd.conf DocumentRoot "/usr/local/apache2/htdocs" #根据你的需要修改
<Directory "/usr/local/apache2/htdocs"> #根据你的需要修改
#下面是我的环境
DocumentRoot "/home/wwwroot"
<Directory "/home/wwwroot"> <IfModule dir_module>
DirectoryIndex index.html index.php #增加默认页面 index.php
</IfModule> Addtype application/x-httpd-php .php #增加对php的支持 #修改SELINUX
[root@localhost bin]# vi /etc/selinux/config
将SELINUX=enforcing 改成SELINUX=disabled 需要重启
[root@localhost bin]# reboot
[root@localhost conf]# mkdir /home/wwwroot
[root@localhost conf]# cd /home/wwwroot
[root@localhost wwwroot]# /usr/local/apache2/bin/apachectl restart
如果启动apache出现 什么zend什么的 安装bison即可解决
wget https://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
mv bison-2.5.tar.gz /root/
tar -xvf bison-2.5.tar.gz
cd bison-2.5
./configure
make && make install