[英]403 Errors on Apache server
我將Apache“ / var / www / html”的主目錄更改為“ / gwanwoonam / web”。此后,Web服務器返回403錯誤-禁止訪問您無權訪問此服務器上的/info.php。 我該如何解決
我搜索了一下,找到了關於許可和SELinux的解決方案。 我關閉了SELinux,因此已禁用。
[gwanwoonam@localhost web]$ getenforce
Disabled
其次,我嘗試編輯conf文件sudo vim /etc/httpd/conf/httpd.conf
<Directory />
AllowOverride none
#Require all denied
Require all granted
Allow from all
</Directory>
...
DocumentRoot "/home/gwanwoonam/web"
...
<Directory "/home/gwanwoonam/web">
AllowOverride None
# Allow open access:
Require all granted
Allow from all
</Directory>
...
<Directory "/home/gwanwoonam/web">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
Allow from all
</Directory>
...
而且,我將777權限放在Web目錄,其子文件夾和文件中。
drwxrwxrwx. 2 gwanwoonam gwanwoonam 40 Jul 21 12:19 web
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 106 Jul 21 11:52 index.html
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 66 Jul 21 12:19 info.php
但是,我無法解決此問題。如何找到解決方案?
日志
[Sun Jul 21 14:04:57.852935 2019] [core:error] [pid 1918] (13)Permission denied: [client ::1:51512] AH00035: access to /favicon.ico denied (filesystem path '/home/gwanwoonam/web') because search permissions are missing on a component of the path, referer: localhost
[Sun Jul 21 14:05:00.422975 2019] [core:error] [pid 1923] (13)Permission denied: [client 127.0.0.1:42228] AH00035: access to / denied (filesystem path '/home/gwanwoonam/web') because search permissions are missing on a component of the path
在您的問題中,您顯示了以下內容:
drwxrwxrwx. 2 gwanwoonam gwanwoonam 40 Jul 21 12:19 web
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 106 Jul 21 11:52 index.html
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 66 Jul 21 12:19 info.php
請注意, index.html
和info.php
不在 web
目錄下。 因此,Apache找不到它們,因為您將其DocumentRoot "/home/gwanwoonam/web"
。
將文件移到/home/gwanwoonam/web
,然后Apache會看到它們。
然后,為確保沒有權限問題,請在文件系統級別運行以下命令:
chmod 755 /home/gwanwoonam/web
find /home/gwanwoonam/web -type d -exec chmod 755 {} \;
find /home/gwanwoonam/web -type f -exec chmod 644 {} \;
這會將權限drwxr-xr-x
放在所有目錄(包括/home/gwanwoonam/web
)上,並將-rw-r--r--
放在文件上。
這樣,您的Apache應該能夠讀取web
下的所有文件,並將它們返回給您。
將以下行添加到現有代碼中:
restorecon -r /home/gwanwoonam/web
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.