apache主配置文件模板和基于域名虚拟主机配置文件模板
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache主配置文件模板和基于域名虚拟主机配置文件模板相关的知识,希望对你有一定的参考价值。
1,主配置文件模板 # cat httpd.conf ServerRoot "/usr/local/apache" Listen 80 LoadModule authn_file_module modules/mod_authn_file.so LoadModule authn_core_module modules/mod_authn_core.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule authz_core_module modules/mod_authz_core.so LoadModule access_compat_module modules/mod_access_compat.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule reqtimeout_module modules/mod_reqtimeout.so LoadModule filter_module modules/mod_filter.so LoadModule mime_module modules/mod_mime.so LoadModule log_config_module modules/mod_log_config.so LoadModule env_module modules/mod_env.so LoadModule headers_module modules/mod_headers.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule version_module modules/mod_version.so LoadModule unixd_module modules/mod_unixd.so LoadModule status_module modules/mod_status.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule dir_module modules/mod_dir.so LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php .php5 AddType application/x-httpd-php-source .phps <IfModule unixd_module> User www Group 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.conf Include conf/extra/httpd-multilang-errordoc.conf Include conf/vhosts/*.conf Include conf/extra/httpd-default.conf <IfModule proxy_html_module> Include conf/extra/proxy-html.conf </IfModule> <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> LoadModule remoteip_module modules/mod_remoteip.so RemoteIPHeader X-Forwarded-For RemoteIPInternalProxy 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主配置文件模板和基于域名虚拟主机配置文件模板的主要内容,如果未能解决你的问题,请参考以下文章
CentOS 7.3 源码安装apache 2.4.16配置基于域名的虚拟主机