Solved

Configure Apache to use less memory

Posted on 2004-10-27
581 Views
Last Modified: 2008-03-03
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
Question by:bobwood2000
    8 Comments
     
    LVL 5

    Expert Comment

    by:basiclife
    What OS are you using? I'm guessing linux?
    0
     
    LVL 5

    Expert Comment

    by:mrielf
    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
     
    LVL 2

    Assisted Solution

    by:brozzis

    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
     
    LVL 48

    Accepted Solution

    by:
    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
     

    Author Comment

    by:bobwood2000
    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
     

    Author Comment

    by:bobwood2000
    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
     
    LVL 2

    Assisted Solution

    by:brozzis

    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
     

    Author Comment

    by:bobwood2000
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Foundations of Front-End Development

    Jump-start a lucrative career in front-end web development, with zero previous coding experience required. This course covers the basic programming concepts and languages required for creating engaging websites from scratch.

    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now