我有一个 cron 任务设置来运行以下命令:
php /var/www/vhosts/examplesite.com/index.php cron processCategoryItemCount
当我在我的生产服务器(通过 MediaTemple dv4 托管)上运行它时,ssh 窗口上会闪烁以下错误:
您的系统文件夹路径似乎设置不正确。请打开以下文件并更正:index.php
当我在我的开发 Mac 上运行 php CLI 命令时,我根本没有收到任何错误。
据我所知,我的 system_path 设置正确.. 这是片段。
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
*
*/
$system_path = 'system';
手动测试
我做了一些测试来检查 CI 用来确定system_path
和application_path
. 据我所知,它工作正常..
CodeIgniter 使用以下代码进行路径验证
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
结果,我制作了一个 test.php 文件并将其卡在我的httproot中。
<?php
$system_path = 'system';
echo "index.php dir is: ".dirname(__FILE__)."\n";
chdir(dirname(__FILE__));
echo "System Dir is: ".realpath($system_path)."\n";
if ( ! is_dir($system_path)){
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}else{
echo "System Path Set Properly\n";
}
sleep(30);
我使用以下命令通过命令行运行它:
/usr/bin/php /var/www/vhosts/examplesite.com/client/stage/test.php`
这就是我得到的:
index.php dir is: /var/www/vhosts/examplesite.com/client/stage
System Dir is: /var/www/vhosts/examplesite.com/client/stage/system
System Path Set Properly
因此,进行了更多测试,我发现问题出在这部分:
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}