path for user www

Mel Flynn mel.flynn+fbsd.questions at mailing.thruhere.net
Mon Jun 15 16:49:54 UTC 2009


On Monday 15 June 2009 06:15:11 Pieter Donche wrote:

> Now I see from reading the apache start-up script /usr/local/sbin/apachectl
> that one can create a file with instructions to be executed at
> startup of Apache: any file in /usr/local/etc/apache22/envvars.d is
> sourced into the start up environment of apache.

Nope, you didn't read it right.

> This directory was empty for the moment.
> So I could put in there a file,
> /usr/local/etc/apache22/envvars.d/mysettings
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
> export PATH

> I don't see what rules of precedence acutally apply ...
> Anyone can explain me?
>
> And will SetEnv in /etc/httpd.conf also work at boot ???
> Or will only /usr/local/etc/apache22/envvars.d/mysettings work at boot ??

It will never work:
1) Your file needs to end in .env.
2) graceful does not restart the root process and the environment is kept in 
the root httpd process, thus you need to restart apache.

% alias aprestart
aprestart='sudo /usr/local/etc/rc.d/apache22 restart'

% cat /usr/local/etc/apache22/envvars.d/path.env
#!/bin/sh
export PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

% aprestart
Performing sanity check on apache22 configuration:
Syntax OK
Stopping apache22.
Waiting for PIDS: 85453.
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.

% curl -s http://localhost/info.php |sed -ne '/PATH / s,<[^>]*>,,gp' |head -1
PATH /sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

-- 
Mel


More information about the freebsd-questions mailing list