四、安装PHP
下载php-5.2.14
tar gxvf php-5.2.14.tar.bz2
cd php-5.2.14
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --enable-track-vars --with-sockets --enable-sockets --with-sysvshm --with-sysvsem --with-pdflib-dir=/usr/local/lib --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/lib --enable-mbstring=all --with-zlib-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl --with-libxml-dir=/usr/local/libxml2/lib --with-gettext=/usr/local/gettext/lib --with-gd --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
#make clean
#make
#make test
# make install
Php.ini文件的修改
#cp php.ini-production /usr/local/lib/php.ini
#vi /usr/local/lib/php.ini
查找修改extension_dir='./'的内容(如下)
extension_dir = /usr/local/lib
添加PHP的环境变量:
临时的 #export PATH=$PATH:/usr/local/php/bin
永久性的:在/etc下有个profile的文件,将其打开把“export PATH=$PATH:/usr/local/php/bin”这句放在“export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC”的上一行
立即生效环境配置,不需要重启,用下命令:
. /etc/profile
五、修改apache配置文件httpd.conf
#vi /usr/local/apache2/conf/httpd.conf
查找AddType 大约在DefaultType text/plain
输入如下内容
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php
(不清楚是不是必须输入这么多项)
查找DirectoryIndex index.html 在其后输入 index.php
查找确保有如下两行配置:
LoadModule php5_module modules/libphp5.so
LoadModule rewrite_module modules/mod_rewrite.so
保存文件,退出。