ServerRoot apache主目錄Listen 監聽端口LoadModule 加載的相關模塊ServerAdmin 管理員郵箱ServerName 服務器名(沒有域名解析時,使用臨時解析。不開啟)ErrorLog "logs/error_log 錯誤日志CustomLog "logs/access_log" common 正確訪問日志DirectoryIndex index.html index.php 默認網頁文件名,優先級順序Include etc/extra/httpd-vhosts.conf 子配置文件中內容也會加載生效主頁的目錄以及權限
DocumentRoot "/usr/local/apache2//htdocs"<Directory "/usr/local/apache2//htdocs"> #Directory關鍵字定義目錄權限 Options Indexes FollowSymLinks #options None:沒有任何額外權限 All:所有權限 Indexes: 瀏覽權限(當此目錄下沒有默認網頁文件時,顯示目錄內容) FollowSymLinks:準許軟連接到其他目錄 AllowOverride None #定義是否允許目錄下.htaccess文件中的權限生效 None:.htaccess中權限不生效 All:文件中所有權限都生效 AuthConfig:文件中,只有網頁認證的權限生效。 Require all granted 訪問控制列表</Directory>注意:(如果修改訪問權限) 例1: 僅允許ip為192.168.127.127的主機訪問 <RequireAll> Require all granted Require ip 192.168.127.127 </RequireAll> -------------------------------------- 例子2.僅允許192.168.0.0/24網絡的主機訪問 <RequireAll> Require all granted Require ip 192.168.1.0/24 </RequireAll> -------------------------------------- 例子3.禁止192.168.127.127的主機訪問,其他的都允許訪問, <RequireAll> Require all granted Require not ip 192.168.127.127 </RequireAll> -------------------------------------- 例子4.允許所有訪問, Require all granted #可以不寫在<RequireAll>。。。</RequireAll>中 -------------------------------------- 例子5.拒絕所有訪問, Require all denied #可以不寫在<RequireAll>。。。</RequireAll>中
新聞熱點
疑難解答