• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 590
  • Last Modified:

Configure Apache to use less memory

I'm running a Apache on virtual private server (VPS) that has only 64 MB of RAM. It only needs to serve a few PHP pages per minute. However, Apache quickly uses up all physical ram and fills up swap space, making my web site virtually unusuable. Given that I'm serving so few pages, are there setting I can modify to make Apache use less memory?

Thanks.
0
bobwood2000
Asked:
bobwood2000
3 Solutions
 
basiclifeCommented:
What OS are you using? I'm guessing linux?
0
 
mrielfCommented:
Apache is mandatory or not? If not, then there is many alternatives...

One of them is Boa
There is a page about  Boa + PHP:
http://www.menie.org/georges/DragonEngine/boa-php.html

Another choice is thttpd(small, uses very few resources, but limited in php capabilities)
0
 
brozzisCommented:

I'd comment out most of "LoadModule" directives, you should know what you really need.
Disable SSL if not used.
reduce the number of the StartServer Directive
limit the number of max processes

buy some RAM ;-)
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
hernst42Commented:
Try with the following settings in your httpd.conf:

MinSpareServers 1
MaxSpareServers 1
MaxRequestsPerChild 1

That might not help if a lot of acceses are done to your page, but for very less accesses it should work.
0
 
bobwood2000Author Commented:
I found that all of these modules were currently being loaded by apache. Which don't I need? All I do with my apache server is server up pages that are generated by mod perl, and I really need to conserve ram.

Thanks.


AddModule mod_so.c
AddModule mod_macro.c
LoadModule config_log_module /usr/lib/apache/1.3/mod_log_config.so
LoadModule mime_magic_module /usr/lib/apache/1.3/mod_mime_magic.so
LoadModule mime_module /usr/lib/apache/1.3/mod_mime.so
LoadModule negotiation_module /usr/lib/apache/1.3/mod_negotiation.so
LoadModule status_module /usr/lib/apache/1.3/mod_status.so
LoadModule autoindex_module /usr/lib/apache/1.3/mod_autoindex.so
LoadModule dir_module /usr/lib/apache/1.3/mod_dir.so
LoadModule cgi_module /usr/lib/apache/1.3/mod_cgi.so
LoadModule userdir_module /usr/lib/apache/1.3/mod_userdir.so
LoadModule alias_module /usr/lib/apache/1.3/mod_alias.so
LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so
LoadModule access_module /usr/lib/apache/1.3/mod_access.so
LoadModule auth_module /usr/lib/apache/1.3/mod_auth.so
LoadModule expires_module /usr/lib/apache/1.3/mod_expires.so
LoadModule setenvif_module /usr/lib/apache/1.3/mod_setenvif.so
LoadModule perl_module /usr/lib/apache/1.3/mod_perl.so
0
 
bobwood2000Author Commented:
Yes, I'm using Linux. I did upgrade my RAM to 96 MB, but my server still seems to be going into swap. (MySQL is partially responsible, but Apache is more so.) Don't think I can afford any more ram, cause my hosting company seems to make all their money selling upgrades to ram. (Clever business startegy: Sell cheap VPS, but included so little RAM that your customers must buy upgrades.)

I replaced PHP with Perl, so BOA + PHP won't work. Perhaps BOA supports Perl, too, but I want to stick with Apache in order to ease the transition to a new server once my site (hopefully) becomes poplular.

Thanks for all of the suggestions.
0
 
brozzisCommented:

are you sure you're using mod_perl or you are using perl as cgi ?

you should try to comment out these directives and see if everything works, but
I'd try this:

LoadModule config_log_module /usr/lib/apache/1.3/mod_log_config.so
# LoadModule mime_magic_module /usr/lib/apache/1.3/mod_mime_magic.so
# LoadModule mime_module /usr/lib/apache/1.3/mod_mime.so
# LoadModule negotiation_module /usr/lib/apache/1.3/mod_negotiation.so
# LoadModule status_module /usr/lib/apache/1.3/mod_status.so
# LoadModule autoindex_module /usr/lib/apache/1.3/mod_autoindex.so
# LoadModule dir_module /usr/lib/apache/1.3/mod_dir.so
# LoadModule cgi_module /usr/lib/apache/1.3/mod_cgi.so
# LoadModule userdir_module /usr/lib/apache/1.3/mod_userdir.so
LoadModule alias_module /usr/lib/apache/1.3/mod_alias.so
# LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so
# LoadModule access_module /usr/lib/apache/1.3/mod_access.so
# LoadModule auth_module /usr/lib/apache/1.3/mod_auth.so
# LoadModule expires_module /usr/lib/apache/1.3/mod_expires.so
# LoadModule setenvif_module /usr/lib/apache/1.3/mod_setenvif.so
LoadModule perl_module /usr/lib/apache/1.3/mod_perl.so

I guess some logging is necessary on server, mod_perl is necessary and I'm guessing alias is necessary too...

do you really thing Perl is better than PHP ? I've no evidence on this.


0
 
bobwood2000Author Commented:
I personally like Perl better, because I already know its syntax. It also strikes me as a richer language, though admittedly I don't know much PHP.

Thanks to everyone for the help!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now