[英]Apache 2.4 segmentation fault when accessing certain localhost Symfony 2 PHP files
[英]Apache 2 problems accessing localhost
這是我在這里的第一篇文章,我希望我做對了。
我在我的 ubuntu 14.04 本地機器上安裝了 apache2 用於學習目的,我的所有文件都在我的家 public_html 文件夾中。
當我嘗試訪問像 localhost/~{user}/test/index.php 這樣的站點時,一切正常,但是當我嘗試使用 localhost/home/{user}/public_html/test/index.php 訪問同一個站點時,我得到以下錯誤:
在此服務器上找不到請求的 URL /home/{user}/public_html/test/index.php。
本地主機端口 80 上的 Apache/2.4.7 (Ubuntu) 服務器
我嘗試使用:
$echo dirname(__FILE__);
但它返回 /home/{user}/public_html/test。
那么為什么我不能使用兩個路徑訪問同一個文件呢?
讓我們考慮第二個 URL:
http://localhost**/home/user/test/index.php**
如果您查看 Apache 的配置,您會注意到有一個名為“DocumentRoot”的指令。 該指令指定 apache 將 URL 中的初始“/”映射到的位置。
因此,假設 DocumentRoot 設置為 /var/www/htdocs。 當您請求路徑 /home/user/test/index.php 時,它實際上會尋找.... /var/www/htdocs/home/user/test/index.php,我假設它沒有存在。 見文檔根
好的,那么為什么第一個有效? 因為 Apache 的UserDir模塊。 這個小模塊檢查鏈接的“/~user/test/index.php”部分。 波浪號 (~) 是做什么的:)。 然后它將 /~user/ 映射到 /home/user/,因此 Apache 將在 /home/user/test/index.php 中查找該文件。 瞧。
希望這可以幫助。
我也有同樣的問題。 apache已經啟動。 我停止apache並啟動nginx:
sudo service apache2 stop
sudo service nginx start
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.