tags:

views:

44

answers:

4

Hi,

I have a need to start the Apache service with a parameter so that I can later access that parameter via PHP. Is this possible?

+1  A: 

You can set an environment variable. See also: getenv

fviktor
+1  A: 

Based on the comments on your question, I'd say that using shared memory is an acceptable alternative. Take a look at shmop_open() et alia.

Ignacio Vazquez-Abrams
A: 

the httpd program will take a 'directive' when you start it up using -c, so experiment with that and SetEnv.

Greg
+2  A: 

pass the parameter to httpd with the -C or -c (process the configuration directive before/after reading config files) command line option and the SetEnv directive:

httpd -C "SetEnv FOO bar"

FOO can now be accessed from PHP like so:

<?php
print getenv('FOO');

prints

bar
ax