6
6
655362018-05-14 23:15:08
PHP
65536, 2018-05-14 23:15:08

How to make PHP under Apache understand the user's home directory?

Used by mpm_itk, exec('whoami') gives the correct username. exec('ls ~ 2>&1') gives ls: cannot access '~': No such file or directory. That is, apparently, php running under Apache does not own the $HOME value.
Because of this, aliases do not work, for example, or git commands requiring a user config, or file operations starting with a tilde.
In console mode, everything works as it should, and php.ini is identical for both Apache and CLI.
Is there a way to fully run commands from PHP on behalf of the user? Nothing helped from what I found
UPD:I managed to solve it by adding the export HOME=/home/ss line to /etc/apache2/envvars, everything works except for aliases. Anyway, if anyone knows, please write. Since this option is working as long as Apache is used by only one user.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2018-05-14
@sidni

I'm not sure, of course, but under my ubuntu, Apache runs under the www-data user, and it doesn't have a home directory, and everything seems to be fair in my case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question