我使用 Webmin 创建了以下虚拟主机:
<VirtualHost *:80>
DocumentRoot "/var/www/whatever"
ServerName whatever.ourdomain
<Directory "/var/www/whatever">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
当重新启动 Apache 时,我得到
Starting httpd: Warning: DocumentRoot [/var/www/whatever] does not exist
Run Code Online (Sandbox Code Playgroud)
问题是,该目录绝对存在。我正盯着它看。pwd向我显示这是我当前的目录等。拼写正确并不难。我在 httpd 日志中找不到任何其他错误或警告。apache:apache 拥有目录和所有子目录/文件。这里没有任何符号链接或任何涉及的东西。我错过了什么,或者我还应该看什么来确定这是为什么?
操作系统是 CentOS 6.0
这是我第一次使用 Amazon EC2。我正在使用 Apache 2.4.6 运行服务器,但在访问公共 DNS 或弹性 IP 地址时似乎无法使其正常工作。我得到的错误信息是:
Forbidden 您无权访问此服务器上的 /index.html。
我已经检查了这个文件的权限 (755)。VirtualHost我的httpd.conf文件中有一个块,如下所示:
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName my-ec2-public-dns-url
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
对于 HTTP 和 HTTPS ,AWS 中的我的安全组设置都设置为Anywhere。
当我检查错误日志时,它说:
AH00132:文件权限拒绝服务器访问:/var/www/html/index.html
我究竟做错了什么?
我的 CentOS 7 机器上运行着 nginx。每天我都会运行一个 cron 作业来生成新的 Diffie-Hellman 参数。它们保存在/etc/ssl/dh/dhparam.pem. 但是 SELinux 正在阻止 nginx 读取此文件。
这是 nginx 错误日志中的一行:
nginx[3189]: nginx: [emerg] BIO_new_file("/etc/ssl/dh/dhparam.pem") failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/ssl/dh/dhparam.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)
这是审计日志:
type=AVC msg=audit(1473285202.181:334): avc: denied { open } for pid=1393 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473285832.647:743): avc: denied { open } for pid=2958 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473287010.821:803): avc: denied { open } for pid=3083 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646316 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file …Run Code Online (Sandbox Code Playgroud)