天天看點

LAMP搭建之三:php編譯安裝

1、下載下傳php的穩定源代碼包。我這裡下載下傳的是php-5.2.3。php官網從google一搜就找到了。

2、解壓

tar jxvf php-5.2.3.tar.bz2 -C /usr/src/

cd /usr/src/php-5.2.3/

3、配置程式

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 --with-jpeg-dir --with-png-dir --with-bz2 --with-freetype-dir --with-iconv-dir --with-zlib-dir --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --enable-cgi --disable-cli

4、編譯,安裝

make

make install

5、php與apache整合

檢視<Directory />和<Directory "/usr/local/apache2/htdocs">

    Order deny,allow

    allow from all 檢查這裡,這裡一定是要allow(允許)的,否則會提示權限不夠,和不能找到網站根這兩個錯誤。

檢視以下這一條是不是已經寫進httpd.conf,這是調用php功能塊的語句。

LoadModule php5_module        modules/libphp5.so

查找到

<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>

在“DirectoryIndex index.html”一句後面添加“index.htm index.php”這兩句。

<IfModule mime_module>

    TypesConfig conf/mime.types

    AddType application/x-compress .Z

    AddType application/x-gzip .gz .tgz

在“AddType application/x-gzip .gz .tgz”下面添加

“AddType application/x-httpd-php .php”

上面這些都滿足了的話,就可以再apache的網站根目錄建立一個test測試頁。

vim test.php

<?

  phpinfo();

?>

重新開機httpd服務,/usr/local/apache2/bin/apachectl restart

使用 elinks http://127.0.0.1/test.php

出現php的資訊頁面,表示php元件安裝成功。