PHP 官网下载 : http://www.php.net/downloads.php
PHP官网历史版本:http://www.php.net/releases/
=============================================
检查是否 安装过
[root@localhost ~]# rpm -qa|grep php
[root@localhost ~]# ps -ef|grep php
(编译安装)
一.解压
[root@localhost xuezhiqi]# tar -zxvf php-5.2.5.tar.gz
二.编译
进入文件进行编译
[root@localhost xuezhiqi]# cd php-5.2.5 [root@localhost php-5.3.19]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
说明: --prefix=/usr/local/php //安装目录
--with-apxs2=/usr/local/apache/bin/apxs //关联Apache 和PHP,把 /usr/local/apache/bin/apxs 这个关联到--with-apxs2选项
--with-mysql=/usr/local/mysql //关联MySQL和PHP,把/usr/local/mysql关联到 --with-mysql,打开mysql的扩展库。
三.make
四.make install
五.配置 Apache
[root@localhost xuezhiqi]# cd /usr/local/apache [root@localhost apache]# cd conf
[root@localhost conf]# vi httpd.conf
在310行加上 //要执行php文件的扩展名
308 AddType application/x-compress .Z 309 AddType application/x-gzip .gz .tgz 310 AddType application/x-httpd-php .php
重启apache.
在apache/htdoc工作目录下写一个php文档 1.php
<?php mysql_connect("localhost","root","") or die(mysql_error()); echo "<br>Connected to MySQL<br>"; echo phpinfo(); ?>
查看信息,会有:
php.ini 文件不存在,要去源代码包的php.inin 配置文件复制过来
[root@localhost php-5.2.5]# cp -p php.ini-recommended /usr/local/php/lib/php.ini
重启Apache 安装完毕
=============================================