我正在自己配置 Apache,并试图强迫自己(重新)学习配置过程。已经很久了!
版本为在 Amazon Linux 上运行的 Apache/2.2.21
我计划从该服务器运行一些站点。
我已经创建:
- /home/ec2-用户/站点
- /home/ec2-用户/sites/www.domain.ca
- /home/ec2-用户/日志
前两个包含 index.html 文件。在我的实验过程中,我将树设置为 777 但没有成功,并将目录和文件的所有权和组更改为 apache(这是 httpd.conf 中发送的内容)。
我删去了 httpd.conf 文件中的一些相关部分:
DirectoryIndex index.html index.html.var
DocumentRoot "/home/ec2-user/sites"
<Directory "/">
Options None
AllowOverride None
</Directory>
<Directory "/home/ec2-user/sites">
Options Indexes
Order Allow,Deny
Allow from All
# Any other directory-specific stuff
</Directory>
<Directory "/home/ec2-user/www.domain.ca">
Order Allow,Deny
Allow from All
# Any other directory-specific stuff
</Directory>
# Default for when no domain name is given (i.e. access by IP address)
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/ec2-user/sites
ErrorLog /home/ec2-user/logs/error_log
TransferLog /home/ec2-user/logs/access_log
</VirtualHost>
# Add a VirtualHost definition for your domain which was once the system default.
<VirtualHost www.domain.ca>
ServerName www.domain.ca
ServerAlias domain.ca
ServerAdmin [email protected]
DocumentRoot /home/ec2-user/sites/www.domain.ca
ErrorLog /home/ec2-user/logs/domain.ca.error_log
TransferLog /home/ec2-user/logs/domain.ca.access_log
</VirtualHost>
在错误日志中,我仅收到:
Sun Dec 11 02:50:11 2011] [error] [client 174.95.145.253] (13)Permission denied: access to / denied
[Sun Dec 11 02:50:14 2011] [error] [client 174.95.145.253] (13)Permission denied: access to / denied
[Sun Dec 11 02:54:27 2011] [error] [client 174.95.145.253] (13)Permission denied: access to / denied
[Sun Dec 11 02:54:32 2011] [error] [client 174.95.145.253] (13)Permission denied: access to / denied
无可否认,这不是一个非常有趣的问题,但是我被难住了,现在只是翻转设置试图确定问题的原因。
答案1
你的整个目录树是否都设置为 777?
chmod 755 父目录
答案2
您可能还想研究修改或禁用 selinux
看: https://stackoverflow.com/questions/1225594/apache-13-permission-denied-in-users-home-directory