re2323 发表于 2015-6-11 08:48:19

编译安装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
首先下载源码包至本地目录,下载位置ftp://172.16.0.1/pub/Sources/new_lamp。

1
2
3
4
5
6
7
8
9
10
11
12
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开始它就是默认设置了。

1
# ./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提供配置文件:

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




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


1
# vim /etc/httpd/httpd.conf




1、添加如下二行
   AddType application/x-httpd-php.php
   AddType application/x-httpd-php-source.phps
2、定位至DirectoryIndex index.html
   修改为:
    DirectoryIndexindex.phpindex.html
而后重新启动httpd,或让其重新载入配置文件即可测试php是否已经可以正常使用。
页: [1]
查看完整版本: 编译安装LAMP(三)——编译安装php-5.4.13