LAMP如何编译安装php-5.4.13

2023-05-14,

这篇文章主要介绍了LAMP如何编译安装php-5.4.13,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

1、解决依赖关系:
如果想让编译的php支持mcrypt扩展,需要下载如下两个rpm包并安装之:
libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm

注:www.rpmfind.net

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/local/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
# make
# make test
# make intall

说明:
(1、这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。
(2、如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。

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

(3、--with-apxs2=/usr/local/apache/bin/apxs表示将php编译为httpd模块,如果要要以fcgi模式与http结合需将此项替换为--enable-fpm

为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是否已经可以正常使用。

感谢你能够认真阅读完这篇文章,希望小编分享的“LAMP如何编译安装php-5.4.13”这篇文章对大家有帮助,同时也希望大家多多支持本站,关注本站行业资讯频道,更多相关知识等着你来学习!