1、#cp httpd-2.0.47.tar.gz 到/usr/local/
2、#tar zxvf php-4.3.3.tar.gz
3、#cd php-4.3.3
4、#./configure --with-mysql --with-apxs2=/usr/local/apache/bin/apxs
#./configure -with-apache=/path/to/apache/dir -with-mysql=/usr/local/mysql
5、#make
6、#make install (一邊等待一邊保佑吧)
7 、#cp php.ini-dist /usr/local/lib/php.ini
8 、#vi /usr/local/apache2/conf/httpd.conf
9 、在addtype application/x-tar.tgz下面,添加以下內容:
addtype application/x-httpd-php .php
loadmodule php4_module /var/www/modules/libphp4.so (如果沒有的話加上)
10 、#vi /usr/local/apache2/htdocs/test.php
<?
echo phpinfo();
?>
11 、瀏覽http://ip/test.php。出現php信息。恭喜這一步成功了。
php和apache安裝后的基本配置
1.apache的配置
apache的配置文件是/usr/local/apache2/conf/httpd.conf,編輯httpd.conf 文件,在文件結尾加上以下兩行:
loadmodule php4_module modules/libphp4.so
addtype application/x-httpd-php .php .php3
同時修改directoryindex為:
directoryindex index.htm
directoryindex index.html
directoryindex index.php
directoryindex index.php3
directoryindex index.php4
apache的配置內容比較豐富,其它apache相關配置請參考apache的相關文檔。
2.php的配置
apache的配置文件是/usr/local/lib/php.ini,編輯php.ini文件來配置php的選項。特別注意的是,安裝完成后register_globals變量默認設置為off,需要將它改成on。否則會出現php讀不到post的數據的現象。
zlib.output_compression=on
register_globals=on
其它php的選項請參考相關文檔。
3.測試
可以寫一個簡單的php文件來測試安裝,文件包含下列一行:
將其保存為/usr/local/apache2/htdocs/info.php,啟動apache,然后在瀏覽器中瀏覽。
新聞熱點
疑難解答