httpd配置


httpd重要文件

/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
/etc/logrotate.d/httpd
/etc/rc.d/init.d/htcacheclean
/etc/rc.d/init.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
/usr/lib64/httpd


/usr/sbin/apachectl
/usr/sbin/htcacheclean
/usr/sbin/httpd
/usr/sbin/httpd.event
/usr/sbin/httpd.worker

/usr/sbin/httxt2dbm
/usr/sbin/rotatelogs
/usr/sbin/suexec

/usr/share/doc/httpd-2.2.15

/var/cache/mod_proxy
/var/lib/dav
/var/log/httpd
/var/run/httpd
/var/www
/var/www/cgi-bin
/var/www/error


/var/www/html
/var/www/icons


下面主要說一下配置

主要是修改/etc/httpd/conf/httpd.conf文件達到

配置文件:
        /etc/httpd/conf/httpd.conf
            ### Section 1: Global Environment
            ### Section 2: 'Main' server configuration
            ### Section 3: Virtual Hosts    

    修改:
        httpd命令:
            -t:檢測httpd.conf配置文件的語法錯誤
            -M:編譯的所有的模塊
            -l:靜態編譯的模塊

        reload:重讀配置文件
        restart:重啓

        修改監聽端口:
            Listen[ip:]port
                可以定義多個監聽端口
                省略ip表示0.0.0.0
        持久連接:
            KeepAlive off | on            持久連接開關
                MaxKeepAliveRequests        最大連接數
                KeepAliveTimeout 15        最長連接時間
        MPM:多路處理模塊
            prefork
            worker
            event
        DSO:LoadModule
            LoadModule Mod_name Mod_path(相對Server Root)

        Main' Server
        定義主機
            ServerName

            DocumentRoot:站點路徑

        站點資源訪問控制
            目錄
            <Diectory "目錄路徑">
            </Directory>

            文件
            <File ""></File>
            <FileMatch "正則表達式"></FileMatch>

            url

            <Location "/PATH/TO/SOME_URL">
	    </Location>
				
            <LocationMatch "URL_PATTERN">
	    </LocationMatch>

        目錄中的常用指令:
            Options:展開方式,空白隔開
                Indexes:索引
                Includes:包含
                FollowSymLinks:鏈接,不在根目錄也能訪問
                SymLinksifOwnerMatch:允許跟蹤機制
                ExecCGI:執行CGI腳本
                MultiViews:
                None
            AllowOverride:允許訪問的資源。不建議啓用

            order和allow/deny form
                Deny,Allow :Deny指令在Allow指令之前被評估。默認允許所有訪問。任何不匹配Deny指令或者匹配Allow指令的客戶都被允許訪問。
                Allow,Deny :Allow指令在Deny指令之前被評估。默認拒絕所有訪問。任何不匹配Allow指令或者匹配Deny指令的客戶都將被禁止訪問。

        定義站點主頁面
            DirectoryIndex。多個值得話,左面優先
        路徑別名
            DocumentRoot " "
            Alias            定義路徑別名

        日誌:
            錯誤日誌:
                ErrorLog logs/error_log
                LogLevel warn            錯誤級別
                
            定製日誌:
                %h:遠程主機名
                %l:
                %u:
                %t:

        基於用戶的訪問控制
            <Diectory "控制的目錄路徑">
                Options None
                AllowOverride None
                AuthType Basic
                AuthName ""
                AuthUserFile "密碼文件"
                Require user 用戶列表
            </Directory>
            htpasswd -m 密碼文件 賬戶
                -c:創建文件
                -m:md5加密
                -s:sha加密
                -D:刪除指定用戶

        基於組賬號認證
            <Diectory "控制的目錄路徑">
                Options None
                AllowOverride None
                AuthType Basic
                AuthName ""
                AuthUserFile "密碼文件"
                AuthGrouprFile "組文件"
                Require group 組列表
            </Directory>
            vim一個組文件。一行一個組定義,格式爲:
                groupName 用戶列表





        虛擬主機:多站點基於不同信息進行表示。現在一般用FQDN
            <VirtualHost IP:PORT>
                ServerName        主機名
                DocumentRoot         網站文件路徑
            </VirtualHost>

            Errorlog            日誌
            CusomLog        
            Alias            別名
            ServerAlias        主機別名
            

        /etc/httpd/conf/*.conf
            虛擬主機的信息一般寫在一個conf文件中,一個主機一個conf文件,便於維護。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章