How to tune Apache in seconds with

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 (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 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, 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 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 | 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

Image: Jack Wallen

Solving the reported issues

The most glaring issue 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, was correct, and MaxRequestWorkers is set to 150.

Figure B

Figure B

Configuring mpm_prefork.conf to specs.

Image: Jack Wallen

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

Figure C

Figure C

The script caught my goof.

Image: Jack Wallen

Once MaxRequestWorkers was set to 197, all was well.

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

A must-use script

The 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 a try, and see if it doesn't drastically increase the performance of your Apache deployment.

Also see