[英]You don't have permission to access / on this server
我有 CentOS 6.1 服務器,並在其上安裝了 apache 2.2.15。 現在,當我嘗試從 IE (http:// / ( =centos ip)) 的另一台電腦(Windows 7)訪問它時,我收到“您無權訪問 / 在此服務器上的權限”。 錯誤。 我什至在“var/www/html”上創建了內容為“”的 phpinfo.php 文件,當我嘗試在 IE 中使用“http://*/phpinfo.php”訪問它時,我沒有發現錯誤。 我該怎么辦? 我的 httpd.conf 目錄是這樣的:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
編輯 httpd.conf 文件,該文件位於/etc/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 conf 中的 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 是否正常工作。
嘗試使用以下命令:chmod +rx /home/*
如果您將 SELinux 設置為許可模式(命令setenforce 0
)並且它有效(對我sudo restorecon -Rv /var/www/html/
),那么您可以運行 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
希望它可以幫助你。
PD:請原諒我的英語
在根目錄中創建index.html
或index.php
文件(在您的情況下 - /var/www/html
,如@jabaldonedo 所述)
右鍵單擊您的 www 文件夾,然后單擊屬性。 導航到權限並將所有更改為讀取和寫入,然后單擊“對封閉文件應用權限”,您就完成了!! 也許為時已晚,但這肯定會幫助其他人
檢查 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
嘗試編輯 httpd.conf
<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 地址
在 /etc/httpd/conf/httpd.conf 中設置所需的所有授予
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.