Linux 安装 php-5.4.1

来源:互联网 发布:室内装修设计图软件 编辑:程序博客网 时间:2024/06/08 06:53
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 / -name"xml2-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 输入代码

<?php

phpinfo();

?>

保存,并启动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

原创粉丝点击