<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
/etc/httpd/conf/httpd.conf
的httpd.conf文件,添加以下代码。<Directory "/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
<Directory "/home/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
在第555行之后(以我的情况为例)检查文件权限并重新启动服务器。
service httpd restart
/etc/selinux/config
中禁用seLinux
,将SELINUX=disabled
更改并像上面提到的那样重新启动服务器,然后再试一次。使用以下命令将 SELinux 设置为宽容模式:
setenforce 0;
请检查/var/www/html目录下的文件权限以及在你的apache配置文件中是否设置了ALLOW指令。
确保所有文件可被web服务器读取,而且ALLOW指令应该如下所示:
<Directory "/var/www/html">
Order allow,deny
Allow from all
</Directory>
首先检查Apache是否正在运行。service httpd restart
用于重新启动。
CentOS 6默认启用SELinux,因此要么更改策略,要么通过编辑/etc/sysconfig/selinux
将其禁用,设置SELINUX=disabled
。然后重新启动。
然后从CentOS本地检查Apache是否正常工作。
wget localhost
,然后用文本编辑器检查响应吗? - jabaldonedosetsebool -P httpd_enable_homedirs true
来启用SELinux,而不是禁用它。 - nyxzsetenforce 0
),并且它起作用(对我有效),那么您可以运行restorecon(sudo restorecon -Rv /var/www/html/
)来永久设置Apache目录中文件的正确上下文,因为setenforce是暂时的。 Apache的上下文是httpd_sys_content_t
,您可以运行命令ls -Z /var/www/html/
来验证它,输出类似于:
-rwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 index.html
如果文件没有正确的上下文,则会出现以下情况:
drwxr-xr-x. root root unconfined_u:object_r:user_home_t:s0 tests
希望这可以帮助您。
附注:请原谅我的英语
请检查httpd.conf中的apache用户和组设置。在AMI/RedHat上默认为apache,在Debian上默认为www-data。
grep '^Group\|^User' /etc/httpd/conf/httpd.conf
然后将apache用户添加到您网站根目录的组设置中。
sudo usermod -a -G <your-site-root-dir-group> apache
<Directory "/usr/local/www/apache24/cgi-bin">
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
对于CentOS 8,您的/etc/httpd/conf.d/awstats.conf文件需要如下所示,并且除非您希望整个世界都能访问它,否则您需要插入您的IP地址并重新启动httpd服务!
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/share/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require <Your IP Address here>
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Allow from <Your IP address here>
Allow from ::1
</IfModule>
</Directory>
# Additional Perl modules
<IfModule mod_env.c>
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>
请记住,如果您的IP地址发生变化,您需要更新文件并重新启动httpd服务器。顺便说一下,您可以通过简单地搜索“我的IP”来查看您的IP地址在外部的样子。
index.html
或 index.php
文件(在您的情况下-/var/www/html
,如@jabaldonedo所述)。