Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Within our application we make use of a environment variable named SERVER_ENV that is used to set whether we are in a production or development environment. This is set through the httpd.conf file for apache. The issue we are having is that using the scheduled task command below set through the Plesk administration interface there is of course no interaction with apache and so the environment variable is not set.

The command used is as follows:

/usr/bin/php -d safe_mode=Off  /var/www/vhosts/example.com/httpdocs/index.php cron file-cleanup

Having spent some time researching it would appear that I could set the variable using:

SERVER_ENV="production"

but I've tried various methods and this does not appear to be picked up.

Can anybody shed any light as to where I can include this within the command string?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You could try something like

export SERVER_ENV="production"; /usr/bin/php -d ...

which sets the environment variable SERVER_ENV to production which can then bve read by php $server_environment=getenv("SERVER_ENV");

share|improve this answer
    
that seems to work thanks. Excuse my stupidity though, could you offer a quick explanation as to what "export" is actually doing here? –  Simon Bennett Dec 20 '11 at 10:09
1  
the export causes the environment variable SERVER_ENV to be passed into the environment of child processes. Without the export your php wouldn't see it. –  Iain Dec 20 '11 at 10:25
    
excellent thank you, that clears it up. –  Simon Bennett Dec 20 '11 at 10:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.