標籤:apache主設定檔範本 預設設定檔範本 禁止ip訪問 基於網域名稱虛擬機器主機設定檔範本 記錄
1,主設定檔範本# cat httpd.confServerRoot "/usr/local/apache"Listen 80LoadModule authn_file_module modules/mod_authn_file.soLoadModule authn_core_module modules/mod_authn_core.soLoadModule authz_host_module modules/mod_authz_host.soLoadModule authz_groupfile_module modules/mod_authz_groupfile.soLoadModule authz_user_module modules/mod_authz_user.soLoadModule authz_core_module modules/mod_authz_core.soLoadModule access_compat_module modules/mod_access_compat.soLoadModule auth_basic_module modules/mod_auth_basic.soLoadModule reqtimeout_module modules/mod_reqtimeout.soLoadModule filter_module modules/mod_filter.soLoadModule mime_module modules/mod_mime.soLoadModule log_config_module modules/mod_log_config.soLoadModule env_module modules/mod_env.soLoadModule headers_module modules/mod_headers.soLoadModule setenvif_module modules/mod_setenvif.soLoadModule version_module modules/mod_version.soLoadModule unixd_module modules/mod_unixd.soLoadModule status_module modules/mod_status.soLoadModule autoindex_module modules/mod_autoindex.soLoadModule negotiation_module modules/mod_negotiation.soLoadModule dir_module modules/mod_dir.soLoadModule alias_module modules/mod_alias.soLoadModule rewrite_module modules/mod_rewrite.soLoadModule php5_module modules/libphp5.soAddType application/x-httpd-php .php .php5AddType application/x-httpd-php-source .phps<IfModule unixd_module>User wwwGroup www</IfModule>ServerAdmin [email protected]ServerName localhost<Directory /> AllowOverride none Require all denied</Directory>DocumentRoot "/usr/local/apache/htdocs"<Directory "/usr/local/apache/htdocs"> Options FollowSymLinks AllowOverride None Rquire all granted</Directory><IfModule dir_module> DirectoryIndex index.php index.html</IfModule><Files ".ht*"> Require all denied</Files>ErrorLog "logs/error_log"LogLevel warn<IfModule log_config_module> LogFormat "%h %a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %a %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/ "/usr/local/apache/cgi-bin/"</IfModule><IfModule cgid_module> # # ScriptSock: On threaded servers, designate the path to the UNIX # socket used to communicate with the CGI daemon of mod_cgid. # #Scriptsock cgisock</IfModule><Directory "/usr/local/apache/cgi-bin"> AllowOverride None Options None Require all granted</Directory><IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz</IfModule>Include conf/extra/httpd-mpm.confInclude conf/extra/httpd-multilang-errordoc.confInclude conf/vhosts/*.confInclude conf/extra/httpd-default.conf<IfModule proxy_html_module>Include conf/extra/proxy-html.conf</IfModule><IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>LoadModule remoteip_module modules/mod_remoteip.soRemoteIPHeader X-Forwarded-ForRemoteIPInternalProxy 127.0.0.1 1.1.1.1 2.2.2<Files ~ "\.tar|\.bz2|\.svn|\*.gz"> Require all denied</Files><DirectoryMatch .*\.svn/.*> Require all denied</DirectoryMatch>2,預設設定檔範本# cat defaults.conf #2.4<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /usr/local/apache/htdocs/ <Directory "/usr/local/apache/htdocs/" > Options FollowSymLinks AllowOverride None Require all denied </Directory></VirtualHost>3,禁止ip訪問模板# cat 1.1.1.1.conf<VirtualHost *:80> ServerAdmin [email protected] ServerName 1.1.1.1 ServerAlias 2.2.2.2 DocumentRoot /usr/local/apache/htdocs/ <Directory "/usr/local/apache/htdocs/" > Options FollowSymLinks AllowOverride None Require all denied </Directory></VirtualHost>4,虛擬機器主機設定檔範本# cat www.test.com.conf#www.test.com<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /data/web_root/www.test.com/www ServerName www.test.com ServerAlias iwww.test.com ErrorLog "/data/logs/apache/www.test.com-error_log" CustomLog "|/usr/local/apache/bin/rotatelogs /data/logs/apache/www.test.com-access_log_%Y%m%d.log 86400 480" combined RewriteEngine On <Directory "/data/web_root/www.test.com/www"> Options FollowSymLinks AllowOverride all Require all granted </Directory></VirtualHost>
apache主設定檔範本和基於網域名稱虛擬機器主機設定檔範本