=====Step 1 從網路下載要安裝的檔案=====
cd /usr/local
//切換到/use/local目錄下
wget ftp.twaren.net/Unix/Web/apache//httpd/httpd-2.2.22.tar.gz
//從網路下載Apache 2.2.22版
tar zxvf httpd-2.2.22.tar.gz
//解壓縮Apache 2.2.22, 因此在/usr/local目錄下可以看到httpd-2.2.22的檔案
wget tw2.php.net/get/php-5.4.6.tar.gz/from/tw.php.net/mirror
//從網路下載PHP 5.4.6版
tar zxvf php-5.4.6.tar.gz
//解壓縮PHP 5.4.6, 因此在/usr/local目錄下可以看到php-5.4.6的檔案
service httpd stop
//停止既有的Apache服務
=====Step 2 安裝Apache 2.2.22=====
cd /usr/local/httpd-2.2.22
//切換到/usr/local/httpd-2.2.22目錄下
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite
//./configure --prefix=/usr/local/httpd 指定安裝目錄
//--enable-so 啟用動態模組功能(DSO, Dynamic Shared Object, 程式需要呼叫時,才載入的模組)
//--enable-rewrite 啟用Apache重寫規則及URL重定向
make
//編譯
make install
//安裝
=====Step 3 設定Apache執行檔=====
執行完上面的步驟後,此時Apache已安裝在 /usr/local/httpd
vi /usr/local/httpd/conf/httpd.conf
//編輯Apache設定檔
檢查下列httpd.conf的設定檔內容
ServerRoot "/usr/local/httpd"
//Apache Server 的根目錄,此為預設值,檢查是否正確(一般不須更改)
DocumentRoot "/var/www/html"
//網頁根目錄,更改至網路放置的目錄
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
//在此訂定來源IP存取網頁與否
<Directory "/var/www/html">
//參照DocumentRoot "/var/www/html"設定
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
//設定首頁檔案,讀取順序為index.php優先於index.html
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
//載入php5的函式庫
AddType application/x-httpd-php .php .phtml .inc .php3
//指定php執行的副檔名
AddType application/x-httpd-php-source .phps
//AddType application/x-httpd-php-source .phps
=====Step 4 安裝 PHP 5.4.6=====
cd /usr/local/php-5.4.6
//切換到/usr/local/php-5.4.6目錄下
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysql --with-apxs2=/usr/local/httpd/bin/apxs
//./configure --prefix=/usr/local/php 指定安裝目錄
make
//編譯
make install
//安裝
cp php.ini-development /usr/local/lib/php.ini
//將php.ini-development檔案複製到/usr/local/bib底下,並改名為php.ini
=====Step 5 重新啟動 http service=====
/usr/local/httpd/bin/apachectl start
//啟動新版Apachectl