Apache httpd的配置信息和目录
httpd默认的配置文件目录为/etc/httpd/;主配置文件是/etc/httpd/conf/httpd.conf;配置存储在的/etc/httpd/conf.d/目录。
主配置文件httpd.conf里的主要配置项。
#服务器根目录
ServerRoot "/etc/httpd"
#端口
#Listen 10.41.10.110:80
Listen 80
#域名+端口来标识服务器,没有域名用ip也可以
#ServerName www.example.com:80
#不许访问根目录
<Directory />
AllowOverride none
Require all denied
</Directory>
# 文档目录
DocumentRoot "/var/www/html"
# 对 /var/www目录访问限制
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# 对/var/www/html目录访问限制
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# 默认编码
AddDefaultCharset UTF-8
#EnableMMAP off
EnableSendfile on
# include进来其它配置文件
IncludeOptional conf.d/*.conf
#vi /etc/httpd/conf/httpd.conf
Linsten 81 #修改默认80端口为81
#vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require ip 10.41.10
</Directory>
##systemctl restart httpd
日志
[Fri Apr 19 13:22:56.011836 2019] [authz_core:error] [pid 17547] [client 10.41.10.59:64181] AH01630: client denied by server configuration: /var/www/html/noindex, referer: http://10.41.10.110/noindex/css/open-sans.css
创建虚拟主机配置文件
# vi /etc/httpd/conf.d/v1.conf
<VirtualHost *:80>
ServerName qzulab.cn
DocumentRoot "/www/qzulab/"
</VirtualHost>
##systemctl restart httpd
Require all granted 无条件允许访问。 Require all denied 访问被无条件拒绝。 Require env env-var [env-var] … 只有在给定的环境变量之一被设置的情况下才允许访问。 Require method http-method [http-method] … 只有给定的HTTP方法才允许访问。 Require expr expression 如果表达式计算结果为true,则允许访问。 Require user userid [userid] … 只有指定的用户才能访问资源。 Require group group-name [group-name] … 只有指定组中的用户才能访问资源。 Require valid-user 所有有效的用户都可以访问资源。 Require ip 10.41.10 指定IP地址范围内的客户端可以访问资源。
None:不支持任何选项 Indexes:允许索引目录 FollowSymLinks:允许访问符号链接指向的原文件 Includes:允许执行服务端包含(SSI) ExecCGI:允许允许CGI脚本 ALL:支持所有选项