Tarball Apache2 & PHP5

安裝apach和php有很多方法,像是利用rpm檔來裝,或是使用yum安裝,本篇介紹使用tarball 方式來安裝apache和php, 使用tarball安裝的方式比較麻煩一點,建議初學者可以使用yum的方式安裝


Apache 安裝
安裝:
./configure –prefix=/usr/local/apache –enable-so –enable-ssl –enable-rewrite
make
make install

註:
–prefix=/usr/local/apache/ : 安裝apache的位置
–enable-so : 啟用模組
–enable-ssl : 啟用ssl
–enable-rewrite : 啟用rewrite

PHP 安裝
安裝:
./configure –prefix=/usr/local/php/ –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql/ –with-gd –with-jpeg-dir=/usr/lib –with-zlib-dir=/usr/lib –with-libxml-dir=/usr/lib –enable-ftp –enable-socket –enable-magic-quotes –enable-libgcc –enable-ftp –enable-mbstring –enable-debug –enable-fastcgi –enable-module=so
make
make install

註:
–prefix=/usr/local/php/ : 安裝php的位置
–with-apxs2=/usr/local/apache/bin/apxs : apache2的目錄位置
–with-mysql=/usr/local/mysql/ : mysql的目錄位置
–with-gd  : 安裝gd模組
–with-jpeg-dir=/usr/lib
–with-zlib-dir=/usr/lib
–with-libxml-dir=/usr/lib
–enable-ftp :啟用ftp
–enable-socket :啟用socket
–enable-magic-quotes
–enable-libgcc
–enable-mbstring
–enable-debug
–enable-fastcgi
–enable-module=so

設定 Apache
設定檔 :  /usr/local/apache/conf/httpd.conf

檢查是否有下面這段
LoadModule php5_module modules/libphp5.so

更改 ServerName
ServerName 192.168.1.102:80

更改 DirectoryIndex
找到DirectoryIndex,設定首頁名稱加上 index.php index.phtml index.php3

增加AddType項目,找到並增加以下三行:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml

設定User home directories
找到 Include conf/extra/httpd-userdir.conf 並將前面的 # 去掉

設定PHP
設定檔 :  /usr/local/php/lib
複製php.ini-dist 到 /usr/local/php/lib/php.ini
cp php.ini-dist /usr/local/php/lib/php.ini

設定extensions
extension_dir = "/usr/local/php/lib/php/extensions"
找到 extensions_dir  , 並設定extensions的目錄

操作&啟動
啟動: /usr/local/apache/bin/apachectl start
重啟: /usr/local/apache/bin/apachectl restart
停止: /usr/local/apache/bin/apachectl stop

開機啟動APACHE
設定檔: /etc/rc.d/rc.local
加入這一段 /usr/local/apache/bin/apachectl start

Related Posts with Thumbnails

相關文章

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>