找到問題的緣由了,我把php的版本從5.4.45切換成了 5.6.27,切換回來以後就行了,php文件就能解析了,網站就能訪問了php
和配置實在沒有半毛錢關係html
收穫吧:仔細思考你作了哪些改變因素(在正確和錯誤之間),我忘記我切換了版本git
實際上是我沒有意識到php版本切換會形成網站沒法訪問的問題github
由於php文件自己就是靠服務器來解析的,php版本切換確定有可能會形成網站沒法訪問apache
以前訪問部分網站,會出現這種狀況,若是沒有具體的訪問文件,就會默認跳轉到根目錄,這樣不少文件會暴露。安全
因此要修改httpd.conf文件,服務器
Options Indexes FollowSymLinksmarkdown
修改成app
Options FollowSymLinkside
其實就是將Indexes去掉,Indexes表示若當前目錄沒有index.html就會顯示目錄結構
在」C:\wamp\bin\apache\apache2.4.9\conf「目錄下打開httpd.conf配置文件
大概516行左右在找到
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
把include 的註釋去掉,讓他去加載conf/extra/httpd-vhosts.conf文件
在」C:\wamp\bin\apache\apache2.4.9\conf\extra「目錄打開
httpd-vhosts.conf文件,直接在這裏配置站點
上面所有註釋,第一句
NameVirtualHost *:80(設置端口號)
# #如下是本身配置的站點1
< VirtualHost *:80 >
ServerName www.xiaozheng.com (網站的域名)
DocumentRoot 「C:\wamp\www」 (文件的路徑)
< Directory 「C:\wamp\www」 > (文件的路徑)
Options Indexes
Order allow,deny
Allow from all
Satisfy all
< /Directory >
< /VirtualHost >
3.在「C:\Windows\System32\drivers\etc」的hosts文件裏面配置
就能夠了
前幾天在電腦上配置多站點的後忽然出現了:」You don’t have permission to access / on this server!「 究其緣由是:swampserver默認訪問的是www文件夾的站點,不容許訪問其餘的站點。
first:首先教你如何配置多站點
在」C:\wamp\bin\apache\apache2.4.9\conf「目錄下打開httpd.conf配置文件
大概516行左右在找到
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
把include 的註釋去掉,讓他去加載conf/extra/httpd-vhosts.conf文件
在」C:\wamp\bin\apache\apache2.4.9\conf\extra「目錄打開
httpd-vhosts.conf文件,直接在這裏配置站點
上面所有註釋,第一句
NameVirtualHost *:80(設置端口號)
# #如下是本身配置的站點1
< VirtualHost *:80 >
ServerName www.xiaozheng.com (網站的域名)
DocumentRoot 「C:\wamp\www」 (文件的路徑)
< Directory 「C:\wamp\www」 > (文件的路徑)
Options Indexes
Order allow,deny
Allow from all
Satisfy all
< /Directory >
< /VirtualHost >
3.在「C:\Windows\System32\drivers\etc」的hosts文件裏面配置
就能夠了
若是類似配置的時候出現了這樣的一個問題~~若是說個人文件路徑在wamp\www之外的話,好比「F:\xiaozheng」會出現「You don’t have permission to access / on this server!」問腿!接下來如何解決這個問題
首先:swampserver服務器默認是隻能訪問站內的文件夾,在http.conf文件裏面有
< Directory />
AllowOverride all
Require all denied (拒絕了外部的訪問)
< /Directory >
必須把上面的改爲:
< Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
#Deny from all
Allow from all
#容許全部訪問
Satisfy all
< /Directory>
第二步:
< Directory 「D:/Wamp5/www」>
# # 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.2/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 all # # Controls who can get stuff from this server. # onlineoffline tag - don't remove Order Deny,Allow Deny from all Allow from 127.0.0.1
< /Directory>
修改爲
< Directory 「D:/Wamp5/www」>
# # 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.2/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 all # # Controls who can get stuff from this server. # # onlineoffline tag - don't remove Order Deny,Allow #Deny from all # Allow from 127.0.0.1 Allow from all
< /Directory>
實際上是能夠把一些沒必要要的註釋刪掉的,我是把那些註釋刪掉了,簡潔了好多,配圖
或者還有一種新的解決方法,在httpd-vhosts.conf配置站點的時候這樣配置
< VirtualHost *:80 >
ServerName www.xiaozheng.com
DocumentRoot 「C:\wamp\www」
<Directory "C:\wamp\www">
Options Indexes FollowSymLinks #原先是Options Indexes
AllowOverride all #原先是沒有這句的,這兩句不論是否超出先限制的文件
範圍,均可以訪問,就不會出現權限問題了
Order allow,deny
Allow from all Satisfy all
</Directory>
< /VirtualHost>
而後保存,重啓服務,在訪問就解決了這個問題。
參考:php多站點配置以及Forbidden You don't have permission to access / on this server問題解決 - xiaozhegaa的博客 - CSDN博客
https://blog.csdn.net/xiaozhegaa/article/details/52512477
好久沒用筆記本作開發了(3-4個月),此次換回筆記本開發,本機配置好服務器訪問網站時,能進入目錄,可是進入具體的index.php會出現Forbidden You don't have permission to access /index.php on this server.錯誤
具體以下圖所示:
a、排查出錯位置
分別試了www.blog.com:81和www.mo.com:81都是一樣能訪問目錄不能訪問index.php的問題,推測網站統一配置出現問題的狀況比較大,固然也不排除這兩個網站都設置錯誤的問題
開啓了虛擬配置
# Virtual hosts Include conf/extra/httpd-vhosts.conf
上述兩個網站在conf/extra/httpd-vhosts.conf中的配置以下:
<VirtualHost *:81> DocumentRoot "E:\2017-02-21--SoftWare\PHP\SOFTWARE\phpStudy_New\PHPTutorial\WWW\github\personalBlog\personalBlog\public" ServerName www.blog.com <Directory "E:\2017-02-21--SoftWare\PHP\SOFTWARE\phpStudy_New\PHPTutorial\WWW\github\personalBlog\personalBlog\public"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> <VirtualHost *:81> DocumentRoot "E:\2017-02-21--SoftWare\PHP\SOFTWARE\phpStudy_New\PHPTutorial\WWW\mo\m_Orchestrate\m_Orchestrate\public" ServerName www.mo.com <Directory "E:\2017-02-21--SoftWare\PHP\SOFTWARE\phpStudy_New\PHPTutorial\WWW\mo\m_Orchestrate\m_Orchestrate\public"> Options Indexes FollowSymLinks AllowOverride All Allow from all </Directory> </VirtualHost>
我以前是用這樣的配置進行的開發,沒出現問題,惟一的變量只是好久沒用這臺電腦而已
也多是後面我對apache的配置文件作了什麼修改我忘記了而已
權限配置中三句話的意思爲:
Options Indexes FollowSymLinks
AllowOverride All
Allow from all
參照下面其它的配置,很容易知道這三句話的意思
<Directory "/applications/apache2.2.31/htdocs"> 站點目錄(如下爲默認站點目錄的限制,若是讀者私自配置了站點目錄而沒有配置這裏就會出現 403錯誤) Options Indexes FollowSymLinks FollowSymLinks表示容許符號連接,indexes表示容許目錄瀏覽,如容許目錄瀏覽,容許符號連接 這裏很危險,應禁止目錄瀏覽 應更改成 Options FollowSymLinks或Options -Indexes FollowSymLinks AllowOverride None 表示禁止用戶對目錄配置文件(.htaccess進行修改)重載 儘可能不開啓.htaccess 安全隱患大,規則多了網站訪問性能低 Order allow,deny 拒絕未被明確容許的 (從後往前讀) Allow from all 全部人都能訪問 </Directory>
將www.blog.com:81對用配置中的:Options Indexes FollowSymLinks改爲Options -Indexes FollowSymLinks(在Indexs前面加了-)後,www.blog.com:81對應的目錄沒法訪問:
其實檢查的時候才發現,在在Indexs前面加了-後,apache啓動失敗了,這裏看到的效果是apache啓動失敗
把apache配置文件httpd,conf中的下面這句話前面的#號去掉,以便訪問網站的時候直接進入文件,而不是目錄
<IfModule dir_module> # DirectoryIndex index.html index.php index.htm l.php </IfModule>
.
localhost:81也不行
在apache的配置httpd.conf中,網站根路徑的配置以下:
DocumentRoot "E:\2017-02-21--SoftWare\PHP\SOFTWARE\phpStudy_New\PHPTutorial\WWW" <Directory /> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory>
如今出現的問題就是:apache 網站 目錄能夠訪問 文件不能訪問
進一步檢查,發現txt,xml格式的文件都能訪問,php格式的文件不能訪問
找到問題的緣由了,我把php的版本從5.4.45切換成了 5.6.27,切換回來以後就行了,php文件就能解析了,網站就能訪問了
找到問題的緣由了,我把php的版本從5.4.45切換成了 5.6.27,切換回來以後就行了,php文件就能解析了,網站就能訪問了
和配置實在沒有半毛錢關係
收穫吧:仔細思考你作了哪些改變因素(在正確和錯誤之間),我忘記我切換了版本
實際上是我沒有意識到php版本切換會形成網站沒法訪問的問題
由於php文件自己就是靠服務器來解析的,php版本切換確定有可能會形成網站沒法訪問