Memory in php.ini, How Does the Site php.ini Interact With the Server php.ini?

6 posts / 0 new
Last post
#1 Sat, 09/28/2013 - 11:41
MTUser2012

Memory in php.ini, How Does the Site php.ini Interact With the Server php.ini?

Do settings in a particular site (virtual server) php.ini override the settings in the Virtualmin installation php.ini? Or are they just a limit on what is available from the installation to that particular virtual server?

Example: Virtualmin, Webmin-> Others->PHP Configuration-> Resource Limits-> Maximum Memory Allocation = 128mb

Virtual Server: Virtualmin, mysite.com, Services->PHP Configuration-> Resource Limits -> Maximum Memory Allocation = 256mb

How much memory would be available to php at mysite.com? I am guessing 128mb, Virtualmin overrides the site. Is that right? if the numbers were reversed in the above example, I believe the answer would still be 128MB. So to get mysite more memory, both would have to be 256mb?

Next Level: If mysite runs a cronjob on the Virtualmin Installation, is the memory available to php for that cronjob controlled by mysite.com or Virtualmin?

I am guessing for cronjobs the memory is controlled by Virtualmin.

What command could I run at the command level to see the answers?

Sun, 09/29/2013 - 08:03
andreychek

Howdy,

If you're using FCGID or CGI for that particular domain, which is the default, than that domain's php.ini file is used for all PHP configuration.

In your example above, that means 256MB.

You could make changes to that config either in $HOME/etc/php.ini, or in Virtualmin using what you described above, Services->PHP Configuration -- both of those are editing the same file.

To use the system-wide php.ini file, you could switch the domain to use mod_php... but we don't recommend that for security reasons :-)

To see what the values look like for your website, you could create a file named test.php, and for it's contents, add the following into it:

<?php phpinfo(); ?>

And then access that in your browser... that will show you the PHP config variables being used.

Regarding the cron job -- that's a trickier question. It depends on how the cron job is being run :-)

Do you have an example of how the cron job looks?

-Eric

Mon, 09/30/2013 - 11:26 (Reply to #2)
MTUser2012

Thanks for the help. I tried the test.php file. It worked great. I can see that my site has 256MB memory available to it.

For the chronjob memory question, I am running a plugin in one of my WordPress sites:

/usr/bin/php /home/mysite.com/public_html/wp-content/plugins/nameofplugin/grab_ads.php

I've received notices the chronjob failed to finish due to a lack of memory, so I was trying to figure out what controls the memory available to run this job.

Mon, 09/30/2013 - 13:14 (Reply to #3)
andreychek

Okay, that makes sense then... try changing that command to look like this:

PHPRC=/home/mysite.com/etc/php5/ /usr/bin/php /home/mysite.com/public_html/wp-content/plugins/nameofplugin/grab_ads.php

And see if that does the trick for you.

-Eric

Sun, 09/29/2013 - 09:48
jimdunn

(you could also edit some or all domain php.ini files using a shell script, calling the command line functions)

# virtualmin list-php-ini

# virtualmin modify-php-ini

Mon, 09/30/2013 - 11:22 (Reply to #5)
MTUser2012

Thanks for the help. I tried the list command from the Virtualmin interface:

virtualmin list-php-ini --domain name | --user name | --all-domains [--php-version number] <--ini-name name>+ <--ini-value value>+ [--name-only]

and when I list a domain name on the installation, I get unknown command. Please can you tell me what I am doing wrong?

Topic locked