關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • Linux 下編譯 Apache 的 mod_rewrite

    Posted on December 28th, 2011 Sam Tang No comments

    要為 Apache 加載 mod_rewrite 模組,如果 Apache 並未安裝,可以在編譯時加上 –enable-rewrite 便可以,但如果 Apache 已經安裝好,而又不想重新編譯 Apache 的話,可以用以下方法:

    1. 首先 cd 到 Apache 的源代碼目錄並到 mod_rewrite.c 檔案,

    1. 在apache的源码安装目录中寻找mod_rewrite.c文件

    # find ./ -name mod_rewrite.c

     
      
    2. 進入 mod_rewrite.c 的目錄並用 apxs 編譯 mod_rewrite.c

    # cd PATH/to/mod_rewrite.c
    # /usr/local/apache/bin/apxs -c mod_rewrite.c
    # /usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.la

     

    3. 編譯好 mod_rewrite.c 後,便開啟 httpd.conf 加入以下內容:

    LoadModule rewrite_module modules/mod_rewrite.so

    然後重新啟動 Apache 便可以了。


    Comments are closed.