问题
I have a cron task setup to run the following:
php /var/www/vhosts/examplesite.com/index.php cron processCategoryItemCount
When i run this on my production server (hosted via MediaTemple dv4) the following error flashes on the ssh window:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
When i run the php CLI command on my development mac, i dont get any errors at all.
As far as i can tell my system_path is set properly.. here is the snippet.
/*
*---------------------------------------------------------------
* 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';
Manual Testing
I did some testing to go through the code that CI uses to determine system_path
and application_path
. From what i can tell its working properly..
CodeIgniter Uses The Following Code For path validation
// 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));
}
As a result I made a test.php file and stuck it in my 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);
I ran this via command line with this command:
/usr/bin/php /var/www/vhosts/examplesite.com/client/stage/test.php`
This is what i get back:
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
So, a bit more testing and i discover the problem is in this part:
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));
}
回答1:
I`d like to write just a comment, but I couldn't.... I'm new in here and I don't have the option to add a comment on the question.
Well... I had the same problem 1 year ago with my dedicated server.
The solution was to leave the $system_path blank...
$system_path = '';
you can try this instead:
$system_path = './system';
回答2:
The problem was permissions related. I never thought of this, but when pulling from github if im logged in as root obviously the ownership is root
. As a result php cannot execute properly.
i ran: chown exampleuser:psacln index.php
and alls good now!
So as a lesson to others running into this issue.. if you're getting the same problem make sure ownership and file permissions are right!
回答3:
Another better solution is to use dirname() like,
Change the below 2 lines
$system_path = 'system';
$application_folder = 'application';
By
$system_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'system';
$application_folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'application';
回答4:
/*
*---------------------------------------------------------------
* 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';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
*/
$application_folder = '../application';
you can try this bro if dont work add another ../
definitely the error reporting will not say that so if the path is set correctly :)
just helping ^_^ hope thiss will
回答5:
Are you sure that nothing got screwed around in FTP transfer? i.e. system is actually in the same directory as index.php?
Also, are you sure you are calling php from the right place? and is the path right?
I had this problem recently: CodeIgniter + Command Line + Cron + Cpanel
Try running it:
/usr/local/bin/php your/path/to/index.php <controller> <method>
For the path, it probably should be a full path? not the www.example.com/index.php? i.e. mine is something like:
/usr/local/bin/php /home/account_name/public_html/index.php <controller> <method> /dev/null 2>&1
回答6:
In index.php
I have made these changes and worked for me.
$system_path = '../system/';
$application_folder = '../application/';
回答7:
To change all the directories to 755 (-rwxr-xr-x):
find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
To change all the files to 644 (-rw-r--r--):
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
Fix codeigniter 3.0.0 distributive plz!
来源:https://stackoverflow.com/questions/10353611/codeigniter-cli-giving-system-path-error-path-does-not-appear-to-be-set-correct