我有一個簡單的chdir和require的問題。PHP - chdir並要求失敗
從第一個文件:網絡/ index_cluster.php
我試圖加載第二個:ezpublish_legacy/index_cluster.php
我所需的文件不加載,但我不知道爲什麼...
這是我的配置。
- PHP 5.4.16
- 從升級的eZ發佈4.7升級到EZ Pubslih 5.90.0alpa1(基於SF2)
- 紅帽企業Linux服務器版本6.4(聖地亞哥)
有沒事就ezpublish日誌和Apache的一個允許的內存大小
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 240 bytes) in /path/to/my/www/web/index_cluster.php on line 11
這是我(簡化)樹
www
`-- ezpublish_legacy
|-- index_cluster.php
`-- web
|-- index_cluster.php
這裏的原代碼
$legacyRoot = '/path/to/my/www/ezpublish_legacy';
chdir($legacyRoot);
require 'index_cluster.php';
這是我的固定
$legacyRoot = '/path/to/my/www/ezpublish_legacy';
chdir($legacyRoot);
require '/path/to/my/www/ezpublish_legacy/index_cluster.php';
我用盡了一切我能想到的:
$legacyRoot = '/path/to/my/www/ezpublish_legacy';
require $legacyRoot.'/index_cluster.php';
=>工作
$legacyRoot = '/path/to/my/www/ezpublish_legacy';
echo getcwd() . "\n";
chdir($legacyRoot);
echo getcwd() . "\n";
die()
require 'index_cluster.php';
=>正是我期待
/path/to/my/www/web
/path/to/my/www/ezpublish_legacy
加載以絕對路徑和檢查上加載文件當前目錄正在給期望的結果
網/ index_cluster.php
require '/path/to/my/www/ezpublish_legacy/index_cluster.php';
ezpublish_legacy/index_cluster。PHP
echo getcwd() . "\n";
die();
結果(我很期待)
/path/to/my/www/web
網/ index_cluster.php
$legacyRoot = '/path/to/my/www/ezpublish_legacy';
chdir($legacyRoot);
require '/path/to/my/www/ezpublish_legacy/index_cluster.php';
ezpublish_legacy/index_cluster.php
echo getcwd() . "\n";
die();
結果(我很期待)
/path/to/my/www/ezpublish_legacy
更新:我已經嘗試一些新的東西:
require "/index_cluster.php" => instant fail
PHP的警告:要求(/ index_cluster .php):未能打開流:第11行/path/to/my/www/web/index_cluster.php中沒有此文件或目錄
require "index_cluster.php" => trying loading for 10 seconds then fail
PHP致命錯誤:用盡536870912個字節允許存儲器大小(試圖分配240個字節)/path/to/my/www/web/index_cluster.php第11行
你錯誤消息是關於PHP內存限制。這不是關於chdir和require。 – Taras
是真的,我第一次寫作時忘記了這個apache錯誤,因爲它對我來說並不「相關」......之後添加了它。儘管如此,問題仍然是由chdir/require組合 – Adcaelo
*不相關,因爲我強制我的php內存限制到2G和更多相同的事情! PHP致命錯誤:允許的內存大小爲2147483648字節耗盡(試圖分配130968字節) – Adcaelo