CentOS7.0下安裝Apache2.4.20版本,安裝完成之后,報 You don't have permission to access / on this server.(403)
廣告:
今天裝了Apache2.4.20版本的,安裝完成之后,我以后會和以前一樣直接就能訪問默認(rèn)文件htdocs文件夾下的index.html文件,然而并沒有。瀏覽器訪問報的一直是403 Forbidden,網(wǎng)上找了一遍都說是,把
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改成
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
就OK了,NO并不是,上面的那個是Apache2.2+里面的配置。
我的httpd.conf里面的是這樣的:
<Directory />
AllowOverride none
Require all denied
</Directory>
對沒錯就是這樣的,php2.4+中是把Order deny,allow Deny from all兩項合并為Require all denied的。好那么現(xiàn)在我將Require all denied改為允許狀態(tài)Require all granted。然后重啟Apache,還是沒有用,這是為什么呢?
真是氣死寶寶了,經(jīng)過一番折騰之后我才整明白了,記住一定記住:
#<Directory />
# AllowOverride none
# Require all denied
#</Directory>
一定是要注釋的。
注釋之后,再修改下面的路徑為自己要訪問的目錄下,就OK了。
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>
改好后,要重啟apache:
停止httpd: service httpd stop
啟動httpd: service httpd start
還有就是不知道有沒有人想我一樣白癡,裝好Apache之后,使用service httpd restart發(fā)現(xiàn)重啟不了。
那是因為沒有將Apache的運(yùn)行程序添加到系統(tǒng)服務(wù)中去,執(zhí)行:
cp /data/server/apache/bin/apachectl(自己安裝的Apache的目錄) /etc/init.d/apached
就可以了。
廣告: