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.
bobwood2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.