LAMP如何编译安装php-5.4.13

sharpest 阅读:64 2023-03-30 18:16:47 评论:0

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


本文参考链接:https://www.yisu.com/zixun/42471.html
标签:PHP
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号