Setting global php memory limit on FCGID execution mode

1 post / 0 new
#1 Sat, 10/06/2012 - 10:06
StoneFreeIT

Setting global php memory limit on FCGID execution mode

A few moments short of asking my question here, i answered it myself so i thought i'd share. Hope this helps anyone!

Short version, to globally limit memory to 128M for all users, regardless of what they put in their php.ini, while in FCGID execution mode:

--1. Check if your php was compiled with support for additional config directories to be scanned. Do this by creating a phpinfo() script. to do this:

Create a file named phpinfo.php in your public_html, and add this line:

<?php
 print_r (phpinfo());
?>

now call phpinfo.php from your browser and check for this line :

Scan this dir for additional .ini files

If there is a directory listed, proceed to --2, otherwise wou will have to compile php with --with-config-file-scan-dir option set.

--2. Create mem.ini (or call it whatever you like) in the directory found at step 1 (for me this was /etc/php5/cgi/conf.d/) and have it contain "memory_limit = 128M" without the quotes.

--3. Restart apache.

The reason i wanted to do this, is because i do like for my virtualserver owners to be able to edit their php.ini, but i do not want them potentially using an exorbitant amount of memory. I assume this solution holds for all php settings, does anybody know this for sure?

Cheers!

Guido

--edit: i mixed up the apache and php directories --edit2: the include in apache2.conf is not the correct one, it is not an option in a configuration file, but it has to be compiled with it. Also now i found a reference to this method in the documentation :) see this page http://virtualmin.com/documentation/webdev/php , check step one above to see if it applies to you