精做高難度防水抓漏/壁癌/油漆等工程
責任施工、合約保固!
保險專業鋁門窗、鍛造門設計及安裝
價格便宜、品質好、設計佳,值得您信賴

首頁  •  j2h 論壇 • 程式設計討論     • 

apache 安裝 mod_limitipconn

房東:阿保
發表時間:2007-02-23
[檢舉]


使用 mod_limitipconn.c 來限制 apache 的並發數
Package: http://dominia.org/djao/limit/
安裝使用說明: http://dominia.org/djao/limitipconn2-README

這裡的安裝建議使用動態 DSO 並 patch apache2.0, 以使得 apache2.0 可以認識在代理後方的 IP 。但是要 重新編譯 apache2.0, 以下是原程式中 INSTALL 的介紹。

## Instructions for building DSO with proxy tracking:
# tar xzvf httpd-2.0.39.tar.gz
# tar xzvf mod_limitipconn-0.22.tar.gz
# cd httpd-2.0.39
# patch -p1 < ../mod_limitipconn-0.22/apachesrc.diff
# ./buildconf
# ./configure --enable-so --enable-speling --enable-rewrite \\
--with-ssl=/usr/local/ssl --enable-forward
# make
# make install
# cd ../mod_limitipconn-0.22
# PATH=/usr/local/apache2/bin:$PATH
# make install

安裝過程
# lynx http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz
# tar -zxvf mod_limitipconn-0.22.tar.gz
# cd httpd-2.0.48
# patch -p1 < ../mod_limitipconn-0.22/apachesrc.diff

patching file configure.in
Hunk #1 succeeded at 373 (offset 55 lines).
patching file include/scoreboard.h
patching file modules/generators/mod_status.c
Hunk #1 succeeded at 746 (offset -1 lines).
patching file server/scoreboard.c# ./configure --enable-so --enable-speling --enable-rewrite \\
--with-ssl=/usr/local/ssl --enable-forward
# make
# make install
# cd ../mod_limitipconn-0.22
# PATH=/usr/local/apache2/bin:$PATH
# make install

----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR\'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH\' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH\' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR\' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf\'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_limitipconn.so
[activating module `limitipconn\' in /usr/local/apache2/conf/httpd.conf]

檢查 httpd.conf 檔案,發現增加了一下一行

LoadModule limitipconn_module modules/mod_limitipconn.so


同時需要設定以下參數在 httpd.conf 中 , 也可以在單個虛擬伺服器中。

ExtendedStatus On
# Only needed if the module is compiled as a DSO
LoadModule limitipconn_module lib/apache/mod_limitipconn.so


MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
# NoIPLimit image/*
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
# OnlyIPLimit audio/mpeg video




注意︰LoadModule limitipconn_module modules/mod_limitipconn.so 必須放在虛擬伺服器之前﹗否則不能啟動。

定製 Apache index 目錄
在 Apache 中設定目錄 有 Options Indexes 屬性的時候,可以索引檔案夾內容,但是如果要定製顯示的內容,就必須添加以下幾行到各個伺服器的設定中去。(可以是全局,也可以是虛擬伺服器或者目錄) MODULE: mod_autoindex

ReadmeName /README.shtml
HeaderName /HEADER.shtml
IndexOptions +SuppressHTMLPreamble FancyIndexing \\
VersionSort FoldersFirst NameWidth=* (Optoional)


但是,我在按照步驟,添加以上設定、設定檔案夾可被索引屬性、製作頁首和頁尾上傳後,仍舊發現不能顯示。最終發現,由於我安裝了 PHP, 為了使得 PHP 代碼可以被嵌入 .html 和 .htm 文檔中,我將 httpd.conf 中的一條屬性設定為︰

AddType application/x-httpd-php .php .html .htm


這使得 apache 不能識別原本設定的 README.html 和 HEADER.html,以下這點是從apache的文檔中找到類似的解說.

參考

Filename must resolve to a document with a major content type of text/* ( e.g. , text/html , text/plain , etc.). This means that filename may refer to a CGI script if the script\'s actual file type (as opposed to its output) is marked as text/html such as with a directive like:

AddType text/html .cgi

Content negotiation will be performed if Options MultiViews is in effect. If filename resolves to a static text/html document (not a CGI script) and either one of the options Includes or IncludesNOEXEC is enabled, the file will be processed for server-side includes (see the mod_include documentation).


我將上述 PHP 的 Type 的最終 .html 和 .htm 去掉以後,就可以正常顯示了。於是想辦法新添加一個種後綴名為 README 和 HEADER 專用︰

AddType text/html .shtml


然後修改 README.html 和 HEADER.html 為 README.shtml 和 HEADER.shtml 即可。要注意的是,因為我要列出的目錄都為 open source, 所以有很多名字為“ README ”的檔案。因此,要將其中的一條配置做小小的修改。(就是隱藏某些檔案的配置)

IndexIgnore .??* *~ *# HEADER.* README.* RCS CVS *,v *,t


參考文檔︰
http://httpd.apache.org/docs-2.0/mod/mod_autoindex.html#headername

http://httpd.apache.org/docs-2.0/mod/mod_autoindex.html#indexoptions







  • 贊助網站       

    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務
    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!



  •  共 0 人回應

    姓名:
    佈告內容: