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.

SEE: From start to finish: How to host multiple websites on Linux with Apache (TechRepublic Premium)

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.

Downloading and running the apache2buddy.pl script

Note: The developer of this tool has migrated the script from the original domain to GitHub. Make sure you use the new command below to avoid any issue that might arrive from a bad actor using the original domain for malicious purposes.

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 -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl.
  5. Allow the script to run.

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

Figure A

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

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

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.