技术知识库

编译安装php

 

1、解决依赖关系:

 

请配置好yum源(可以是本地系统光盘)后执行如下命令:

# yum -y groupinstall "X Software Development"

#yum  -y  install bzip2-devel  libmcrypt-devel

如果想让编译的php支持mcrypt扩展,安装如下两个rpm包

libmcrypt-2.5.7-5.el5.i386.rpm

libmcrypt-devel-2.5.7-5.el5.i386.rpm

 

2、编译安装php-5.4.13

到官网下载之后执行如下命令

# tar xf php-5.4.13.tar.bz2

# cd php-5.4.13

# ./configure --prefix=/usr/local/php --with-mysql=/usr/bin/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts

 

 

说明:

1、这里为了支持apacheworkerevent这两个MPM,编译时使用了--enable-maintainer-zts选项。

2、如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQLMySQL开发包了。mysqlndphp 5.3开始可用,可以编译?绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。

# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd

# make

# make install

 

php提供配置文件:

# cp php.ini-production /etc/php.ini

 

3? 编辑apache配置文件httpd.conf,以apache支持php

 

# vim /etc/httpd/httpd.conf

 1、添加如下二行

   AddType application/x-httpd-php  .php

   AddType application/x-httpd-php-source  .phps

 

 2、定位至DirectoryIndex index.html

   修改为:

    DirectoryIndex  index.php  index.html

 

然后重新启动httpd,或让其重新载入配置文件即可测试php是否已经可以正常使用。


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: