linux下讓apache支援mod_rewrite模組__linux

來源:互聯網
上載者:User
如果你的伺服器apache還沒有安裝,那很簡單,在編譯apache時將 mod_rewrite模組編譯進去就可以如果你的apache已經安裝好了,現在只想編譯出mod_rewrite.so模組,在apache中進行載入,下面我們就介紹這個方 法。 1)首次安裝apache,在編譯時間增加–enable-rewrite選項。 如./configure –prefix=/opt/apache –enable-so –enable-mods-shared=all –enable-rewrite –enable-cache 2)增加mod_rewrite模組 # find . -name mod_rewrite.c //在apache的源碼安裝目錄中尋找mod_rewrite.c檔案 (2.2.8在目錄httpd-2.2.8/modules/mappers下) # cd PATH/to/mod_rewrite.c //進入包含mod_rewrite.c檔案的目錄 # /opt/apache/bin/apxs -c mod_rewrite.c //apxs應指定絕對路徑,在你當前正在使用apache的bin目錄裡 # /opt/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.la 如果沒有什麼錯誤的話,應該在你的apache的modules目錄中編譯出一個mod_rewrite.so檔案。 編輯httpd.conf檔案,確認httpd.conf中已經包含mod_rewrite.so的載入語句,如下: LoadModule rewrite_module modules/mod_rewrite.so
################################################### 如果出現這個錯誤
Syntax error on line 329 of /usr/local/apache2/conf/httpd.conf:
Can`t loacte API module staructure `mod_rewrite_module` in file
/usr/local/apache2/modules/mod_rewrite.so:/usr/local/apache2/lib/libapr-
0.so.0:undefined symbol:mod_rewrite_module
修改http.conf
原來:httpd.conf裡面寫的mod_rewrite_module
改成 rewrite_module

如果重啟apache出現這個錯誤module rewrite_module is built-in and can`t be loaded
表示模組是內建的,不用再調入,注釋掉
#LoadModule rewrite_module modules/mod_rewrite.so
##################################################### 檢查: [root@www httpd-2.2.8]# ../bin/apachectl configtest
Syntax OK 這時,你的apache應該已經支援rewrite了。
vicos註:完成之後,記得重啟伺服器apache。
注意下一步,配置虛擬機器主機的時候要類似如下設定才可以生效: <VirtualHost *:80>
DocumentRoot /var/www/www/www.fastu.cn/
ServerName [url]www.fastu.cn[/url]
<Directory /var/www/www/www.fastu.cn/>
Options FollowSymLinks
AllowOverride All
order allow,deny
Allow from all
</Directory>
</VirtualHost>
如果AllowOverride設定為none的話,apache會不讀取網站的.htaccess檔案。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.