Networking

How to tune Apache in seconds with apache2buddy.pl

Discover how to improve the performance of your Apache server configuration with the help of a must-use Perl script.

Image: Jack Wallen

Apache server software, out of the box, is impeccably well designed. By doing very little, you can have a blazingly fast web server up and running with a single command: sudo apt-get install lamp-server^.

But where can Apache admins turn in order to get the most out of their web server? Do you comb through httpd.conf or apache2.conf for possible issues? Do you look through /etc/apache2/sites-enabled to make sure all of your directives are clear and well defined?

What if I told you there is a Perl script that will comb through your Apache setup and report back crucial improvements that can be made to your configuration? The script is apache2buddy.pl (a fork of apachebuddy), and it can do more for your web server in seconds than the hours it would take to sift through everything.

The script doesn't fix your problems—once it's run, the script will suggest fixes for Apache that you can then read through and act upon. The apache2buddy.pl script will check for the following and much more:

  • PHP memory limits
  • Memcache
  • MaxClients
  • Memory usage
  • Max potential memory usage
  • Percentage of total RAM allocated to Apache
  • MaxRequestWorkers

After you fix the issues suggested by apache2buddy.pl, you'll find your Apache server is significantly improved.

Let's download, run, and fix some problems with an Apache server running on Ubuntu Server 16.04.

SEE: Secure equipment repair policy and confidentiality agreement (Tech Pro Research)

Downloading and running

The apache2buddy.pl script is run from the command line. To successfully run the script, follow these steps.

  1. Open a terminal window.
  2. Issue the command sudo su. (If you're running a distribution that doesn't use sudo, omit sudo from the command.)
  3. Type your sudo (or root) password and hit the Enter key on your keyboard.
  4. Issue the command curl -L http://apache2buddy.pl/ | perl.
  5. Allow the script to run.

When the script completes, it will immediately report its findings (Figure A).

Figure A

Figure A

The findings generated by apache2buddy.pl.

Image: Jack Wallen

Solving the reported issues

The most glaring issue apache2buddy.pl found on my test server was a low MaxRequestWorkers setting.

The MaxRequestWorkers directive sets the limit on the number of requests that will be served simultaneously. In my configuration, MaxRequestWorkers was set to 150 (the default); however, the recommended setting is between 179-197. This particular directive is configured in /etc/apache2/mods-enabled/mpm_prefork.conf. As you can see in Figure B, apache2buddy.pl was correct, and MaxRequestWorkers is set to 150.

Figure B

Figure B

Configuring mpm_prefork.conf to apache2buddy.pl specs.

Image: Jack Wallen

After making that change, I restarted Apache with the command service apache2 restart and re-ran the apache2buddy.pl test. I intentionally set MaxRequestWorkers to 199 to see how apache2buddy.pl would react. Sure enough, it declared the directive set was too high (Figure C).

Figure C

Figure C

The apache2buddy.pl script caught my goof.

Image: Jack Wallen

Once MaxRequestWorkers was set to 197, all was well.

Go through the entirety of the apache2buddy.pl findings and resolve all the reported issues, and then restart Apache—your web server will perform like never before.

A must-use script

The apache2buddy.pl script is a must for anyone that administers an Apache server. With very little time and effort, you can tune your web server to near perfection.

Give apache2buddy.pl a try, and see if it doesn't drastically increase the performance of your Apache deployment.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox