Linux下编译安装PHP

WBOY
Release: 2016-06-23 14:28:48
Original
847 people have browsed it

在linux(ubuntu)环境下, 编译安装PHP的步骤.

注: 不同操作系统下, 安装路径不同,请注意!

1. 下载php源码

$cd /usr/local/src

$wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror

2. 解压缩并安装

$tar jxvf php-5.3.6.tar.bz2 

$cd php-5.3.6/

$./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/home/service/mysql --with-zlib

$make

$make install

3. 修改apache配置,使得apache可以识别".php"文件

$cd /etc/apach2

$vi apache2.conf

在文件末尾增加如下内容:

 1 LoadModule php5_module  modules/libphp5.so 2 <IfModule !mod_php5.c> 3 LoadModule php5_module lib/modules/libphp5.so 4 </IfModule> 5  6 <IfModule mod_php5.c>  7     AddType application/x-httpd-php .php  8     AddType application/x-httpd-php .php5  9     AddType application/x-httpd-php-source .phps 10     AddType application/x-httpd-php-source .php5s 11     DirectoryIndex index.php 12     DirectoryIndex index.php5 13 </IfModule>
Copy after login

保存退出.

$/usr/local/apache2/bin/apachectl restart

重启apche,然后用phpinfo()函数就能看到安装的php模块了.

附:

linux下编译php中configure参数具体含义

http://apps.hi.baidu.com/share/detail/34997687

参考文档:

http://blog.csdn.net/lanyd/article/details/6037927

http://hi.baidu.com/comeon010/blog/item/983b29cbab80f912bf09e6a1.html

http://hi.baidu.com/travel981cn/blog/item/2514bf34069031b0d0a2d30e.html

http://www.phpbegin.com/html/96/n-4296.html

http://www.cnblogs.com/qingfeng2010/archive/2011/01/07/1930333.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template