apache 設定檔詳解

來源:互聯網
上載者:User

標籤:apache設定檔描述

                                apache  設定檔詳解

1、由於設定檔中的空行和注釋很多所以要排除

    主設定檔:httpd.conf;( 注意備份)

     grep -Ev  "#|^$"  httpd.conf ;

    ServerRoot "/application/apache2.2.27"

    #服務的根目錄;軟體安裝位置;

    Listen 80 

    #web服務監聽連接埠,使用者訪問使用;

    <IfModule !mpm_netware_module>

    <IfModule !mpm_winnt_module>

    #模組的開頭

    User daemon

    Group daemon

    #每個進程都有使用者,預設使用者daemon(編譯安裝)

    </IfModule>

    </IfModule>

    ServerAdmin [email protected]

    #網站管理員的郵箱(當網站出問題時方便聯絡)

    DocumentRoot "/application/apache2.2.27/htdocs"

    #預設的網站目錄

    <Directory />

    #許可權控制;/表示根

    Options FollowSymLinks

    #可以帶符號連結

    AllwOverride None

    #禁止相關的一些功能 

    Order deny,allow

    Deny from all

    #不讓任何人訪問根目錄

        </Directory>

       <Directory> "/application/apache2.2.27/htdocs" 

#如果沒有首頁會展示目錄結構

    Options Indexes FollowSymLinks

    # 最佳化 ,-Indexes 不對外展示目錄結構

            AllwOverride None

            Order deny,allow

            Deny from all

        </Directory> 

        報錯403 找不到目錄

    <IfModule dir_module>

        DirectoryIndex index.html

    #指定訪問的首頁;如果有多個用空格分開;

    </IfModule>

    <FilesMatch "^\.ht">

        Order allow,deny

        Deny from all

        Satisfy All

    </FilesMatch>

    ErrorLog "logs/error_log"

    #錯誤記錄檔

    LogLevel warn

    #日誌的層級

    <IfModule log_config_module>

        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

        LogFormat "%h %l %u %t \"%r\" %>s %b" common

        <IfModule logio_module>

         LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"     combinedio

    #日誌的類型

        </IfModule>

        CustomLog "logs/access_log" common

    </IfModule>

    <IfModule alias_module>

        ScriptAlias /cgi-bin/ "/application/apache2.2.27/cgi-bin/"

    </IfModule>

    <IfModule cgid_module>

    </IfModule>

    <Directory "/application/apache2.2.27/cgi-bin">

    #cgi的配置 ,已不使用;

        AllowOverride None

        Options None

        Order allow,deny

        Allow from all

    </Directory>

    DefaultType text/plain

    #預設的類型;

    <IfModule mime_module>

        TypesConfig conf/mime.types

        AddType application/x-compress .Z

        AddType application/x-gzip .gz .tgz

    #壓縮控制

    </IfModule>

    <IfModule ssl_module>

    SSLRandomSeed startup builtin

    SSLRandomSeed connect builtin

    </IfModule>

2、擴充設定檔的資訊(/conf/extra 路徑)一般只瞭解;650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0011.gif" alt="j_0011.gif" />

    重點 :httpd-mpm.conf                 

           httpd-vhosts.conf

           httpd-default.conf  

    1)、 httpd-vhosts.conf    (需注意的地方)

        19 NameVirtualHost *:80 #連接埠配置

        27 <VirtualHost *:80>

             28     ServerAdmin [email protected]

             29     DocumentRoot "/application/apache2.2.27/docs/dummy-host.example.com"

             30     ServerName dummy-host.example.com

             31     ServerAlias www.dummy-host.example.com

             32     ErrorLog "logs/dummy-host.example.com-error_log"

             33     CustomLog "logs/dummy-host.example.com-access_log" common

             34 </VirtualHost>

            #虛擬機器主機的配置;

-------------------------------------------------------------------------------------------

    2)、httpd-mpm.conf      鎖檔案;

         36 <IfModule mpm_prefork_module> #工作模式(常見的work和prefork模式);編譯安裝時沒有指定工作模式,預設是prefork模式;

         37     StartServers          5

         38     MinSpareServers       5

         39     MaxSpareServers      10

         40     MaxClients          150#並發

         41     MaxRequestsPerChild   0

         42 </IfModule>

     <IfModule mpm_worker_module>#工做模式(編譯的時候指定工作模式--with-    mpm=worker)

         52     StartServers          2

         53     MaxClients          150

         54     MinSpareThreads      25

         55     MaxSpareThreads      75

         56     ThreadsPerChild      25

         57     MaxRequestsPerChild   0

         58 </IfModule>


-------------------------------------------------------------------------------------------

    3)、httpd-default.conf 包括逾時參數

        使用命令:cat -n httpd-default.conf  | grep -v "#"

        10Timeout 300

        11# 連線逾時

        16KeepAlive On

        17# 串連保持

        23MaxKeepAliveRequests 100

        24# 最大接受永久串連請求;

        29KeepAliveTimeout 5

        30      #在同一個串連等待下一個請求的時間

        38UseCanonicalName Off

        39# 偽靜態相關,開發使用;

            (<Directory "/application/apache2.2.27/cgi-bin">

            AllowOverride None此處控制

        Options None)

        45AccessFileName .htaccess

        46

        55ServerTokens Full

        56#隱藏版本,跳整為Pord;

        65ServerSignature On

        66#控制不顯示版本號碼,off關閉

        75HostnameLookups Off







 


本文出自 “一個檔案一個命令” 部落格,謝絕轉載!

apache 設定檔詳解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.