2011-12-26 131 views
2

我在Ubuntu 11.10上,並安裝了Apache服務器來承載我的本地網站,然後我從公司託管它。Linux/php需要父目錄

我的網站根目錄爲 「/家庭/ a1a4a /網絡/」

我在/home/a1a4a/www/account/account_info.php一個PHP文件」

,我想他包括在「/home/a1a4a/www/include/fg_membersite.php」文件

這是我從account_info.php

require_once('./include/fg_membersite.php'); 

沒有和我得到這個錯誤

Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in /home/a1a4a/www/account/account_info.php on line 10 Fatal error: require_once(): Failed opening required './include/fg_membersite.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a1a4a/www/account/account_info.php on line 10 

那麼我做錯了什麼?怎麼修 。 我有完整的權限(sudo chown -R www-data)。

感謝和節日快樂:)

回答

11

始終使用絕對路徑,也將面臨因調用腳本錯誤。

require_once('./include/fg_membersite.php'); 

實際上應該是

require_once(dirname(dirname(__FILE__)).'/include/fg_membersite.php');