2013-07-12 58 views
0

文件結構(FYI我的Linux服務器上)沒有包括PHP的錯誤:儘管使用絕對和相對錯誤的目錄中查找包括

錯誤:

Warning: include(./Setup/Setup.php) [function.include]: failed to open stream: No such file or directory in /home/content/22/10350022/html/templates/Home.php on line 1 

Warning: include() [function.include]: Failed opening './Setup/Setup.php' for inclusion (include_path='.:/usr/local/php5_3/lib/php') in /home/content/22/10350022/html/templates/Home.php on line 1 

我嘗試了好幾種不同達到此設置文件的方式。

tried: include('/Setup/Setup.php') - same error 
tried: __DIR__. '/Setup/Setup.php' 
tried: $_SERVER [SITEROOT] and some other variations including the total path. 
tried: Include = path ".:/Setup/Setup.php" 

這三者都產生了相同的錯誤,只有一處不同。錯誤中顯示的路徑包括: /var/chroot/home/.../Setup/Setup.php

我很努力地理解這裏發生了什麼。我不擅長PHP,所以我不確定如何微調相對與絕對路徑。

爲什麼當我告訴它在/安裝程序中查看我的/ templates文件夾?

謝謝!

+0

此腳本在哪個目錄中,以及要包含在哪個目錄中?例如它們的絕對路徑是什麼,'/ path/to/the script.php'和'/ some/other/path/to/the/include/file.php'。 –

回答

1

確保路徑是正確的:

include($_SERVER['DOCUMENT_ROOT']."/Setup/Setup.php"); 

確保PHP用戶有權限:

臨時chmod命令777和測試

chmod 777 /home/content/22/10350022/html/templates/Setup/Server.php 
+0

超越權限!謝謝!我完全忘記了這一點。如此愚蠢。通常我在開始工作之前先做這件事。非常感謝!!! – user2089405

0

試試這個:

include('Setup/Setup.php'); 

以上示例應該很好地工作。但是,不知道如何包括文件和結構,您可能需要使用../跳回目錄。確保你的文件也是可讀的。