Linux中訪問Apache報403錯誤處理方法


1、先說本地環境,脫離基礎環境的解決策略都是耍流氓

      (1)Linux:CentOS7.5

      (2)Apache: Apache/2.4.6 (CentOS)

      (3)Apache的安裝路徑在 /usr/local/httpd2.4

2、出現錯誤

    按照正常的流程解壓Apache包並完成配置,正常啟動,啟動后,輸入訪問URL:http://IP:端口/,很不幸頁面出現403Forbidden錯誤。You don't have permission to access / on this server。

3、解決措施

    (1) 首先是修改/home/project/soft/apache/conf/httpd.conf。找到<Directory />,並將里面的內容修改如下:

<Directory />
    AllowOverride all
    Require all granted
</Directory>

  (2)此時如果重啟Apache服務,發現仍然是無法訪問,但是頁面報錯增加了一行內容“Server unable to read htaccess file, denying access to be safe”。此時要會去查看Apache的日志。(Apache安裝路徑下log/error_log),發現里面有報錯信息:Fri Sep 28 16:33:22.661903 2018] [core:crit] [pid 16685:tid 139887686231808] (13)Permission denied: [client 172.16.40.224:50470] AH00529: /home/project/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/project/' is executable。按照報錯提示,在/home/project下建立文件.htaccess,並在文件中輸入以下內容:

Order allow,deny
Allow from all
Require all granted


保存並退出。

(3)此時可以直接重啟Apache並嘗試方式是否正常,如果不正常,再執行以下步驟:

chmod 755 /home/project

(4)上述步驟全部執行完后,應該可以正常訪問了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM