安装php-5.2.3
[root @ test root] # tar -zvxf php-5.2.3.tar.gz
[root @ test root] # mkdir -p /usr/local/php
[root @ test root] # cd php-5.2.3
[root @ test php-5.2.3] # ./configure —prefix=/usr/local/php
—with-apxs2=/usr/local/apache/bin/apxs —with-mysql=/usr/local/mysql
—with-mysqli=/usr/local/mysql/bin/mysql_config —with-xml —with-png
—with-jpeg —with-zlib —with-freetype —with-gd —enable-track-vars —enable-mbstring=all
做上一步时会报错libpne.(a | so)not found ,原因是没有安装libpng-devel,在第三张光盘中,安装一下即可.
[root @ test php-5.2.3] # make
[root @ test php-5.2.3] # make install
[root @ test php-5.2.3] # cp php.ini-dist /usr/local/php/lib/php.ini
注:编辑apache配置文件httpd.conf,以apache支持php
[root @ test php-5.2.3] # vi /etc/httpd/httpd.conf
# 添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# 定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
# 这里将网站根目录指定到/var/www:
找到DocumentRoot “/usr/local/apache/htdocs”
修改为:DocumentRoot “/var/www”(后文中我们还会注释掉此行,以启用虚拟主机)
找到<Directory “/usr/local/apache/htdocs”>
修改为:<Directory “/var/www”>