Why is www's $PATH only /usr/bin:/bin?

Bertram Scharpf lists at bertram-scharpf.de
Wed Apr 27 12:12:21 UTC 2016

On Tuesday, 26. Apr 2016, 21:40:48 +0200, Niklaas Baudet von Gersdorff wrote:
> I figured that www's $PATH is only /usr/bin:/bin. Why is that if
> /etc/login.conf says the following?
>     default:\
>     --------8<--------
>         :path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\
>     --------8<--------

> The thing is that I want to run something in /usr/local/bin with PHP's
>     shell_exec($cmd);
> but that's not working because it's not in $PATH.

I wondered as well about this behaviour sometimes. The
default path from login.conf will be set at login. Yet, the
www daemon is started from rc and this is not understood to
be a login. The perverse thing is that when you do a
"/usr/local/etc/rc.d/apache24 restart" from the command
line, then the PATH variable will contain the value you

I recommend to include a line into your Apache configuration
(or whichever HTTP server you use) like

  SetEnv PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

Cron does the same by "PATH=..." as you can see in
"/etc/crontab". There is no possibility to do this in lpd,
wherefore I wrote a bug report. Have a look at the



Bertram Scharpf
Stuttgart, Deutschland/Germany

More information about the freebsd-questions mailing list