php論壇服務器架構
Linux下PHP服務器的安裝與配置分類:PHP教程
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,然后在瀏覽器中瀏覽。