Where to configure php_value auto_prepend_file?

SYSTEM INFORMATION
OS type and version Debian 11
Virtualmin version 7.5-1

Hi,
I would like to configure a WAF for some of my sites and need to add the following to the php configuration:

php_value  auto_prepend_file  "/usr/share/shadowd/php/shadowd.php"

Can someone tell me where I have to configure this? I tried in website directives and inside the php.ini inside the etc folder of the virtual host. But unfourtunately this doesn’t work. Either nothing happens, or Apache won’t start again.

Both Debian and Virtualmin are fresh installs, except the WAF I installed later.

Thanks in advance!

php_value used like this is a mod_php directive. You should not be using mod_php. (You should never be using mod_php. I feel the need to be very emphatic about this.)

How you set it on your system depends on which execution mode you’re using. php-fpm is recommended for most deployments, and that would be set in Services->PHP-FPM Configuration->Edit Configuration Manually for that domain. (Or editing it from the command line in /etc/php-fpm.d or somewhere along those lines.)

Then add:

php_value[auto_prepend_file] = "/usr/share/shadowd/php/shadowd.php"

To the config file. Though I’m not at all confident php-fpm will allow you to run that. You probably need a copy of this PHP in your user home and owned by the user (PHP-FPM has a variety of security protections to prevent you from doing risky stuff, like running other user’s code). I don’t have any experience with the specific tool you’re using, and have never run outside code this way, so I may be wrong. I’m just guessing.

If you’re using fcgid execution mode, you can set it in the php.ini for the domain in question which is in /home/domain/etc/php<version>/php.ini probably. Also different syntax when set in php.ini.

Thank you for your great answer, you were totally right.
Worked exactly how you described it.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.