linux 版本: redhat6.2
php版本 : php-5.4.1
之前写过: linux apache 安装
linux 安装 php-5.4.1
1. 下载 php-5.4.1.tar.gz
2. 解压
[root@test31~] tar -zxvf php-5.4.1.tar.gz
3. 进入安装文件目录
[root@test31~] cd php-5.4.1
4. 执行
[root@test31 php-5.4.1]# ./configure --prefix=/usr/local/php5--with-apxs2=/usr/local/web/apache/bin/apxs--with-mysql
注意:绿色标记为你 apache的安装目录
出现问题:
configure: error: xml2-config not found.please check your libxml2 installation.
检查是否安装了libxm包
[root@test31 php-5.4.1]# rpm -qa |grep libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12
重新安装libxml2和libxml2-devel包
yum install libxml2
yum install libxml2-devel -y
安装完之后查找xml2-config文件是否存在
[root@test31 php-5.4.1]# find / -namexml2-config
/usr/bin/xml2-config
如果存在的话重新安装php
[root@test31 php-5.4.1]# ./configure --prefix=/usr/local/php5--with-apxs2=/usr/local/web/apache/bin/apxs--with-mysql
执行如果报错: “cannot find mysql header files under yes”
需要指定mysql的安装路径
[root@test31 php-5.4.1]# ./configure --prefix=/usr/local/php5--with-apxs2=/usr/local/web/apache/bin/apxs --with-mysql=/usr/local/mysql
安装成功的标志是:
出现
+--------------------------------------------------------------------+
|license: |
| this software is subject to the php license, available inthis |
| distribution in the file license. by continuingthis installation |
| process, you are bound by the terms of this licenseagreement. |
| if you do not agree with the terms of this license, you mustabort |
| the installation process at thispoint. |
+--------------------------------------------------------------------+
thank you for using php.
5.然后执行
[root@test31 php-5.4.1]# make
[root@test31 php-5.4.1]# make install
6. 配置 php.ini
[root@test31 php-5.4.1]# cp php.ini-development /usr/local/lib/php.ini
7. 编辑 httpd.conf 文件以调用 php 模块。loadmodule 表达式右边的路径必须指向 系统中的 php。以上的make install 命令可能已经完成了这些,但务必要检查。
[root@test31 php-5.4.1]# vi/usr/local/web/apache/conf/httpd.conf
loadmodule php5_module modules/libphp5.so
再加入一行让apache正确处理apache文件
addtype application/x-httpd-php.php
再找到 directoryindex关键字:添加 index.php
开启.httaccess功能
allowoverrideall
保存对httpd.conf的修改。
8. 查看是否安装成功
在apache的htdocs目录下建立文件phpinfo.php 输入代码
保存,并启动apache。
[root@test31 bin]#./apachectl start
9.打开网址: http://192.168.2.9/phpinfo.php
出现php相关的信息,说明php-5.4.1 安装成功了!
参考 php 官方文档: http://www.php.net/manual/zh/install.unix.apache2.php
