我已經在我的Fedora中配置了httpd,我檢查了所有的東西都是真實的,但是我得到了
禁止訪問
我已經測驗了所有關于.htaccess的內容,但是仍然得到了禁止訪問的結果。 我在安裝httpd的時候測驗了一個樣本專案,它完美地作業,沒有 "禁止訪問 "的資訊。
這是我的httpd配置
<虛擬主機 *:80>
服務器名稱 test.com
服務器別名 www.test.com
DocumentRoot /home/myuser/gitlab/register/ public Directory /home/myuser/gitlab/register/public>
目錄索引 index.php
AllowOverride All
Require all granted
允許,拒絕的順序
允許來自全部
</Directory>
</VirtualHost>。
這是我在laravel公共檔案夾中的htaccess
。<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
重寫引擎開啟
# 處理授權頭。
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 。
# Redirect Trailing Slashes If Not A Folder...重定向尾部斜線。
RewriteCond %{REQUEST_FILENAME}! !-d
RewriteCond %{REQUEST_URI}(. )/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME}! !-d
RewriteCond %{REQUEST_FILENAME}! !-f
RewriteRule ^ index.php [L] 。
</IfModule>
uj5u.com熱心網友回復:
你的問題可能是由舊的Apache語法和新的Apache語法混合造成的,現代版本的Apache應該是這樣的...
<虛擬主機 *:80>
服務器名稱 test.com
服務器別名 www.test.com
DocumentRoot /home/myuser/gitlab/register/ public Directory /home/myuser/gitlab/register/public>
目錄索引 index.php
AllowOverride All
Require all granted
# Order allow,deny
# Allow from all
</Directory>
</VirtualHost>。
uj5u.com熱心網友回復:
我找到了問題所在。
它是因為
SELinux
ubuntu默認不使用SELinux,但RedHat發行版默認使用它。為了安全起見,SELinux阻止apache訪問主目錄,所以如果你禁用或將其設為允許模式,apache就可以訪問你的主目錄來加載Web專案。如果你不想禁用SELinux,那么Web應用程式的正確位置是在/var/www/檔案夾。 所以,如果我們把httpd配置改為
<VirtualHost *:80>
服務器名稱 test.com
服務器別名 www.test.com
DocumentRoot /var/www/gitlab/register/public。
<Directory /var/www/gitlab/register/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
允許,拒絕的順序
允許來自全部
</Directory>
</VirtualHost>。
它作業正常
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/310722.html
標籤:
