Console permission denied mkdir


I’ve got a Console script that use some functions that work perfect in web environment. The mkdir() function is working correct in web.

But when called from console it gives me a: PHP Error[2]: mkdir(): Permission denied

I know that the user that runs the php in web environment is probaly different that from the console script. But I have to be honest that I don’t know much about groups and users in Unix.

Any idea how I should approach this and give the console rights to mkdir in a safe way?

BTW of course it works OK when I run it from shell console as root. But I’m talking about when it runs from cronjob.

Cronjob is something like: /usr/local/bin/php -f /home/theuser/public_html/protected/yiic gogotools createdirs

update: ok the problem was that the path is wrong.

But I cant figure out how to get the correct path from a Console script. I can use the Yii::app()->basePath, this works, but now I am very curious what the path is that a console script is running from.

Just because I want to understand YII

This is the setup:

/content (777)


I run a cronjob like:

/usr/local/bin/php -f /home/theuser/public_html/protected/yiic thescript start

The script simplefied:

public function actionStart()


  $path = 'content/'; // not working

  $path = '../content/'; // not working

  $path = '../../content/'; // not working

  $path = '../../../content/'; // not working

  $path = '../../../../content/'; // not working

  $path = '/home/theuser/public_html/content/'; // working

  $path = Yii::app()->basePath.'/../content/'; // working



I know, it works, why keep digging? Just because I can’t get my head around :rolleyes: :blink:

And maybe I can prevent errors in the future with this knowledge.

Defined in commandPath.