1.下載httpd2.4.4,存放目錄:/home/aaron/httpd-2.4.4.tar.gz,解壓 tar -zxvf httpd-2.4.4.tar.gz
2.安裝
進入解壓後的/home/aaorn/httpd-2.4.4目錄,執行./configure --prefix=/home/aaron/httpd,提示:
checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9
configure: WARNING: skipped APR at apr-1-config, version not acceptable
no
configure: error: APR not found. Please read the documentation.
查看apache安裝文檔:http://httpd.apache.org/docs/2.4/install.html 需要新的apr,按照嚮導下載apr-1.4.6.tar.gz,apr-util-1.5.1.tar.gz,按照說明,分別解壓到:
httpd2.4.4/srclib/apr和httpd2.4.4/srclib/apr-util(絕對路徑省略),
tar -zxvf apr-1.4.5.tar.gz -C /home/aaron/httpd-2.4.4/srclib/
tar -zxvf apr-util-1.5.1.tar.gz -C /home/aaron/httpd-2.4.4/srclib/
注意解壓後apr和apr-util目錄是帶版本號碼的,把目錄分別重新命名成apr和apr-util(不帶版本號碼) mv apr-1.4.5 apr ,mv apr-util-1.5.1 apr-util
再到httpd-2.4.4目錄下./configure --prefix=/home/aaron/httpd --with-included-apr
注意這一步,網上有很多人是把apr和apr-utils先編譯安裝,然後再用參數--with-apr=/xx/apr --with-apr-util=/xx/apr-util/bin,我沒有測試,應該效果是一樣的
make && make install
執行成功!httpd安裝成功!
3.下載php-5.4.12.tar.gz,解壓到/home/aaron/php-5.4.12,進入解壓後的目錄
./configure --prefix=/home/aaron/php --with-apxs2=/home/aaron/httpd/bin/apxs --with-mysql
成功後:make && make install
執行成功,php安裝成功!
參考:http://www.php.net/manual/en/install.unix.apache2.php
cp php.ini-development /usr/local/lib/php.ini // /usr/local/lib需要有許可權,或者在安裝前指定ini檔案的目錄 --with-config-file-path=/some/path
4.修改httpd配置
添加:
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
注釋掉LoadModule中的rewrite_module
在上面的<FilesMathc/>後再添加:
RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]
5.配置完成,啟動httpd:./bin/apachectl start
checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9
configure: WARNING: skipped APR at apr-1-config, version not acceptable
no
configure: error: APR not found. Please read the documentation.