Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/ cron file-cleanup

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


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
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
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

Your Answer


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.