root@localhost down]#tar –zxvf php-5.2.12.tar.gz
//解压php-5.2.12.tar.gz安装包
![](http://img1.51cto.com/attachment/201001/201001121263290242453.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost down]#cd php-5.2.12
[root@localhost down]#./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –with-apxs2=/usr/local/apache/bin/apxs –with-mcrypt=/usr/local/mcrypt
//
指定
php
安装路径,同时指定连接
apache,mysql,phpmcrypt
扩展路径,
![](http://img1.51cto.com/attachment/201001/201001121263290287437.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#make
//
编译
php
源代码
![](http://img1.51cto.com/attachment/201001/201001121263290314765.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#make install
//
安装
php
![](http://img1.51cto.com/attachment/201001/201001121263290338687.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#cp php.ini-dist /usr/local/lib/php.ini
//
拷贝
php.ini-dist
文件到
/usr/local/lib
目录下
![](http://img1.51cto.com/attachment/201001/201001121263290365765.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#vi /usr/local/lib/php.ini
//
编辑
php.ini
配置文件
![](http://img1.51cto.com/attachment/201001/201001121263290401203.jpg?x-oss-process=image/resize,w_1400/format,webp)
//
按
J
式下移一行,按
K
上移一行,按
H
左移一个字符,按
L
右移一个字符
点击
i
键进行编辑文件
将
register_globals=Off
该为
register_globals=On
按
Esc
键
:wq
保持退出
![](http://img1.51cto.com/attachment/201001/201001121263290429375.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#vi /usr/local/apache/conf/httpd.conf
//
编辑
httpd.conf
配置文件
![](http://img1.51cto.com/attachment/201001/201001121263290468937.jpg?x-oss-process=image/resize,w_1400/format,webp)
//
也可以按光标实现向左,向右,向上,向下移动
点击
i
键进行编辑
DirectoryIndex index.html
再添加
index.php
用空格隔开
![](http://img1.51cto.com/attachment/201001/201001121263290515328.jpg?x-oss-process=image/resize,w_1400/format,webp)
在
AddType application/x-gzip .gz .tgz
的下面添加一句
AddType application/x-httpd-php .php .php3 .php4 .php5
//.php .php3 .php4 .php5
这些要用空格分开
把
Addhandler cgi-script .cgi
前面的
#
号去掉,打开
CGI
脚本服务
按
Esc
键
:
wq
保存退出
![](http://img1.51cto.com/attachment/201001/201001121263290541828.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#/usr/local/apache/bin/apachectl restart
//
重启
apache
服务
![](http://img1.51cto.com/attachment/201001/201001121263290567750.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost php-5.2.12]#vi /etc/rc.d/rc.local
//
设置启动文件,在末尾添加
/usr/local/apche/bin/apachectl start
![](http://img1.51cto.com/attachment/201001/201001121263290596859.jpg?x-oss-process=image/resize,w_1400/format,webp)
![](http://img1.51cto.com/attachment/201001/201001121263290622562.jpg?x-oss-process=image/resize,w_1400/format,webp)
//
按
Esc
键
:
wq
保存退出
[root@localhost php-5.2.12]#/etc/rc.d/init.d/xinetd restart
//
配置重新导入
![](http://img1.51cto.com/attachment/201001/201001121263290649125.jpg?x-oss-process=image/resize,w_1400/format,webp)
测试
php
是否配置成功,进入
apachen
默认主目录
/usr/local/apache/htdocs
,在该目录下键一个
phpinfo.php
文件
[root@localhost php-5.2.12]#cd /usr/local/apache/htdocs
//
切换到
htdocs
目录下
[root@localhost htdocs]#vi phpinfo.php
//
建立一个
phpinfo.php
文件
![](http://img1.51cto.com/attachment/201001/201001121263290687015.jpg?x-oss-process=image/resize,w_1400/format,webp)
点击
i
键开设编辑
输入
<?php
Phpinfo();
?>
按
Esc
键
:wq
保存退出
![](http://img1.51cto.com/attachment/201001/201001121263290724609.jpg?x-oss-process=image/resize,w_1400/format,webp)
然后打开浏览器,在地址栏输入
: http://localhost/phpinfo.php
出现下面界面说明配置成功了
![](http://img1.51cto.com/attachment/201001/201001121263290788921.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost htdocs]#/usr/local/apache/bin/apachectl restart
//
如果出现这个提示界面,请重启
apache
服务
![](http://img1.51cto.com/attachment/201001/201001121263290819187.jpg?x-oss-process=image/resize,w_1400/format,webp)
![](http://img1.51cto.com/attachment/201001/201001121263290842906.jpg?x-oss-process=image/resize,w_1400/format,webp)
//
测试
php
是否和
mysql
关联
![](http://img1.51cto.com/attachment/201001/201001121263290878562.jpg?x-oss-process=image/resize,w_1400/format,webp)
//
点击
i
键进行编辑
<?php
$conn=mysql_connect(“localhost”,”root”,”123456”);
//
主机名:
localhost
数据库用户
:root
,密码
:123456
If($conn) echo “<h1>succeed<h1>”;
如果连接成功显示最大号成功
else echo “<h1>fail</h1>”;
//
否则显示失败
?>
//
按
Esc
键
:wq
//
保存退出
![](http://img1.51cto.com/attachment/201001/201001121263290904828.jpg?x-oss-process=image/resize,w_1400/format,webp)
![](http://img1.51cto.com/attachment/201001/201001121263290933593.jpg?x-oss-process=image/resize,w_1400/format,webp)
成功了!
接下来配置
ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
[root@localhost htdocs]#cd /home/down
[root@localhost down]#ll
![](http://img1.51cto.com/attachment/201001/201001121263291522687.jpg?x-oss-process=image/resize,w_1400/format,webp)
6.ZendOptimizer
的安装
[root@localhost down]#tar –zxvf ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
//
解压
ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
安装包
![](http://img1.51cto.com/attachment/201001/201001121263291558734.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost down]#cd ZendOptimizer-3.2.8-linux-glibc21-i386
//
切换到
ZendOptimizer-3.2.8-linux-glibc21-i386
目录
[root@localhost ZendOptimizer-3.2.8-linux-glibc21-i386]#./install
//
启动安装
Zend Optimizer
![](http://img1.51cto.com/attachment/201001/201001121263291755093.jpg?x-oss-process=image/resize,w_1400/format,webp)
进入如下的
ZendOptimizer
安装界面
.
点击回车
![](http://img1.51cto.com/attachment/201001/201001121263291943062.jpg?x-oss-process=image/resize,w_1400/format,webp)
点击回车
![](http://img1.51cto.com/attachment/201001/201001121263291986609.jpg?x-oss-process=image/resize,w_1400/format,webp)
点击回车
![](http://img1.51cto.com/attachment/201001/201001121263292017765.jpg?x-oss-process=image/resize,w_1400/format,webp)
按
tab
键进行切换选择
Yes
回车
安装路径为
/usr/local/ZendOptimizer
选择
OK
回车
![](http://img1.51cto.com/attachment/201001/201001121263292099765.jpg?x-oss-process=image/resize,w_1400/format,webp)
这里选择
php.ini
所在位置
.
我们在之前的安装中已经将
php.ini
复制到了
/usr/local/lib
下
.
所以这里不用修改
.
在
OK
上点击回车
![](http://img1.51cto.com/attachment/201001/201001121263292160609.jpg?x-oss-process=image/resize,w_1400/format,webp)
我们用的正是
apache.
在
Yes
上点击回车
![](http://img1.51cto.com/attachment/201001/201001121263292190343.jpg?x-oss-process=image/resize,w_1400/format,webp)
这里是指明
apache
的启动
apachectl
文件位置
/usr/local/apache/bin/apachectl
选择
OK
回车
![](http://img1.51cto.com/attachment/201001/201001121263292227812.jpg?x-oss-process=image/resize,w_1400/format,webp)
回车
![](http://img1.51cto.com/attachment/201001/201001121263292262140.jpg?x-oss-process=image/resize,w_1400/format,webp)
回车
![](http://img1.51cto.com/attachment/201001/201001121263292287015.jpg?x-oss-process=image/resize,w_1400/format,webp)
选择
Yes
回车重启
apache
![](http://img1.51cto.com/attachment/201001/201001121263292312937.jpg?x-oss-process=image/resize,w_1400/format,webp)
回车完成
ZendOptimizer
的安装
![](http://img1.51cto.com/attachment/201001/201001121263292339515.jpg?x-oss-process=image/resize,w_1400/format,webp)
再次重启apache.执行 /usr/local/apache/bin/apachectl -k restart
![](http://img1.51cto.com/attachment/201001/201001121263292369656.jpg?x-oss-process=image/resize,w_1400/format,webp)
7.phpMyAdmin
的安装
[root@localhost ZendOptimizer-3.2.8-linux-glibc21-i386]#cd ..
[root@localhost down]#ll
![](http://img1.51cto.com/attachment/201001/201001121263292519765.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost down]#tar –jxvf phpMyAdmin-3.2.0.1-all-languages.tar.bz2
![](http://img1.51cto.com/attachment/201001/201001121263292545312.jpg?x-oss-process=image/resize,w_1400/format,webp)
[root@localhost down]#cp –r phpMyAdmin-3.2.0.1-all-languages /usr/local/apache/htdocs/phpmyadmin
![](http://img1.51cto.com/attachment/201001/201001121263292598062.jpg?x-oss-process=image/resize,w_1400/format,webp)
出现下面界面说明
phpmyadmin
安装成
![](http://img1.51cto.com/attachment/201001/201001121263292630656.jpg?x-oss-process=image/resize,w_1400/format,webp)
用
mysql
的用户和密码登陆
用户是
root
密码:
123456
![](http://img1.51cto.com/attachment/201001/201001121263292665281.jpg?x-oss-process=image/resize,w_1400/format,webp)
![](http://img1.51cto.com/attachment/201001/201001121263292688390.jpg?x-oss-process=image/resize,w_1400/format,webp)
本文转自 chen138 51CTO博客,原文链接:http://blog.51cto.com/chenboqiang/264331,如需转载请自行联系原作者