Background
We recently encountered a heavily used Virtualmin server with many powerful Elementor websites. What turns out happening is quite a few of the sites give 500 errors. Tailing a few log files showed that “Allowed memory size of 134217728 bytes exhausted” errors are all over the show.
It turns out this server was set to defaults, namely a PHP memory limit of 128M. Although this might have been a fine default for many years, these days it’s not. According to Elementor:
https://elementor.com/help/requirements
WP Memory limit of 256 MB (Elementor and Elementor Pro only), 512 MB recommended, 768 MB for best performance.
Well I would be really hesitant to set a shared server to 512 MB or more, but 256M seems like a good idea.
To solve this problem for the most pressing sites, what can we do? The solution is grep
. Run the following grep
command to see which sites are giving memory issues:
grep -r -i --include *_log --include *.log "allowed memory size"
Explanation:
-r = recursive
-i = case insensitive search
–include = include those files and directories
Conclusion
Running the above command allowed us to quickly get on top of the situation for a few key sites. The next steps was the use the Virtualmin Pro functionality to set the rest of the sites.
You can also change the default for each site that is launched with Virtualmin.
Follow Up
How to grep for other values
There are times that you actually want remove configuration lines from a server.
For example, if you’re prepping a Virtualmin server for mdm_event
or mdm_worker
, you want to remove all legacy PHP configuration values.
Here are some examples for removing those lines:
# sed -i '/php_value memory_limit 32M/d' *.conf # sed -i '/php_value suhosin.session.encrypt Off/d' *.conf # sed -i '/php_value max_execution_time 300/d' *.conf # sed -i '/php_value /d' *.conf # sed -i '/php_admin_value /d' *.conf
Note: Do not run these commands as they will radically alter a lot of configuration files.
Reference
- The
sed
command syntax was obtained from ChatGPT