1.获取安装文件: http://www.php.net/downloads.php php-5.3.8.tar.gz
获取安装php需要的支持文件:http://download.youkuaiyun.com/download/netlong339/1351852 libxml2-2.6.32.tar.gz
2.安装libxml2
1 tar zxvf libxml2-2.6.32.tar.gz 2 cd libxml2-2.6.32 3 ./configure --prefix=/usr/local/libxml2 4 make 5 make install
如果安装成功以后,在/usr/local/libxml2/目录下将生成bin、include、lib、man和share五个目录。在后面安装PHP5源代码包的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/ local/libxml2"选项,用于指定安装libxml2库文件的位置。
3.安装php5 (--with-mysql 和--with-apxs的路径 根据自己实际情况写,用下面的查询命令查找)
#tar zvxf php-5.3.8.tar.gz #cd php-5.3.8 #./configure \ --prefix=/usr/local/php \ --with-mysql=/usr/local/mysql \ --with-apxs=/usr/local/apache2/bin/apxs \ --with-libxml-dir=/usr/ local/libxml2 #make #make install
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... no
checking for Apache 1.x module support... no
checking whether to enable Apache charset compatibility option... no
checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS...
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed 刚开始没有apxs这样报错
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
rpm安装的apache没有apxs文件吗 没有,需要安装httpd-devel才有apxs
apxs: /usr/sbin/apxs /usr/share/man/man8/apxs.8.gz 装了httpd-devel 才有这个!!!!!
- 配置 httpd.conf 让apache支持PHP:
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php (.前面有空格)
AddType application/x-httpd-php-source .phps (.前面有空格)
- 然后CPOPY PHP的配置文件
cp php-5.3.8/php.ini.dist /usr/local/php/lib/php.ini
(如果没有php.ini.dist 则把php.ini-development php.ini-production中的任何一个重命名为php.ini.dist即可。)
修改php.ini文件 register_globals = On
- 重启apache
service apache restart
5.测试php是否成功安装
写一个php测试页info.php,放到apache2/htdocs中。
<?php
phpinfo();
?>;
在浏览器中输入:服务器地址/info.php
如果能正常显示出php的信息,则说明Apche+Mysql+PHP安装成功!