If you are using cPanel/WHM then you've got an option in your WHM to limit memory usage by apache processes (RLimitMEM), the option is under Security -> Modify Apache Memory Usage.
This option executes the script: /scripts/apachelimits. It works fine on dedicated systems, it reads the /proc/meminfo file for the currently installed memory and sets the limit accordingly.
Unfortunately the script is useless on a VPS, since a VPS uses a part of the system memory. As a result, the generated values are wrong and cause problems for many people.
I've written a perl script, based on the original cPanel apachelimits, which is for VPS servers hosted by Jag. The script will properly give you the setting based on the memory your VPS is allowed to use.
The script does NOT modify your configuration, it just prints the setting and it lets you copy/paste it, just in case you are not happy with the result.
Just copy/paste the following code into a file, make it executable with "chmod +x file.pl" and run it with "./file.pl". You may also place it in your ~/bin directory if you want to frequently run it.
Code:#!/usr/bin/perl use lib '/scripts'; use SafeFile; print "\nSearching for VPS Memory Limit.............: "; $file = '/proc/user_beancounters'; open(INFO, $file); @lines = <INFO>; close(INFO); $lines =~ s/\s+/:/g; print $lines."\n"; @words = split(/:/, $lines); $size = $words; print "Found VPS memory limit (estimated).........: ".int($words/1024*4)." MB\n"; $lines =~ s/\s+/:/g; @words = split(/:/, $lines); print "Current VPS memory usage (estimated).......: ".int($words/1024*4)." MB\n"; print "Calculating RLimitMEM......................: "; $size = int( $size / 2 ); $size = int( $size * 1024 ); print "$size"; $size = int( $size / 3 ); print ", $size\n"; $meg = int( $size / ( 1024 * 1024 ) ); print "Suggested apache child process limit.......: ".$meg." MB\n\n"; print "You may add the following into your /etc/httpd/conf/httpd.conf:\n\nRLimitMEM ".$size."\n\n";
- WEB HOSTING
- RESELLER HOSTING
- Cloud VPS HOSTING
- Dedicated Servers
- About Us