Installing On Bluehost

I just installed yii 1.1.14 on BlueHost.

This script must be run from the command line Error

I got the following error:

[indent]This script must be run from the command line[/indent]

The problem was in CConsoleApplication in the following function:




protected function init()

{

	parent::init();

	if(!isset($_SERVER['argv'])) // || strncasecmp(php_sapi_name(),'cli',3))

		die('This script must be run from the command line.');

	$this->_runner=$this->createCommandRunner();

	$this->_runner->commands=$this->commandMap;

	$this->_runner->addCommands($this->getCommandPath());

}



It turned out that the command line arguments were not being passed to yiic.php when I submitted the following command line:

[indent]php /home1/mydomain/public_html/yii/framework/yiic.php webapp /home1/mydomain/public_html/app[/indent]

I selected the BlueHost PHP 5.4 (Single php.ini) configuration, and modified the php.ini file in the public_html directory as follows , so that argc_argv is set to On:


;register_argc_argv = Off

register_argc_argv = On

That did not fix the problem so i explicitly referenced the php.ini file in the yiic command line as follows:

php -c /home1/mydomain/public_html/php.ini /home1/mydomain/public_html/yii/framework/yiic.php webapp /home1/mydomain/public_html/app

That fixed the problem.

The .htaccess file in public_html has the following lines:




# Use PHP5.4 Single php.ini as default

AddHandler application/x-httpd-php54s .php



This seems to make the php.ini file apply to all Web accesses of PHP files but not to command line accesses and thus (as I said above) I had to explicitly reference the php.ini file in the command line.

I am wondering if there is a more elegant way to reference the php.ini file in command line invocations of PHP.

Found a better approach. Use

php-cli yiic.php

You don’t even need to modify php.ini with this approach.