Professional Documents
Culture Documents
Now!
Blog
Your
Start
×
Join Over 300K+ Linux Users
by Gabriel Cánepa | Published: November 23, 2015 | Last Updated: March 4, 2016
Vi/Vim Editor BEGINNER'S GUIDE
Learn vi/vim as a Full Text Editor
Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators | 4 Free
Shell Scripting eBooks
Linux Foundation CertiLjcation
According to a recent report by Netcraft (a well-known Internet Exam Study Guide to LFCS and LFCE
company that provides among other services web browser
usage statistics), Apache continues to be the most widely
used web server among sites and Internet-facing computers.
installations, you need to know how to make sure your web Tecmint’s Guide to Red Hat RHCSA / RHCE
CertiLjcation Preparation Study Guide
server performs at the best of its capacity according to your
(or you client’s) needs.
In this article we will discuss a few tips that will help you
ensure that Apache will run smoothly and be able to handle the
number of requests you are expecting from remote clients.
However, there may be a recent improvement or a bug Ljx that Add to Cart - $69
has been added to a newly-released stable version, which is 257,757 11,967 39,682
Ending In: 3 days
then made available to download and install from source. Are you subscribed?
Compilation and installation instructions
4 Free are
Shellalso provided
Scripting eBooks for Newbies and Administrators
https://www.tecmint.com/apacheperformancetuning/ 3/21
5/7/2017 5 Tips to Boost the Performance of Your Apache Web Server
here – just remember that if you choose this update method, Computer Hacker Professional
you may want to back up your current conLjguration Ljles / sites CertiLjcation Course (96% Off)
/ virtual hosts as a precaution.
Add to Cart - $59
In any event, you can check your currently installed version as
Ending In: 4 days
follows:
TIP #2: If you are using a Kernel older 257,757 11,967 39,682
than 2.4, consider upgrading now Are you subscribed?
4 Free Shell Scripting eBooks for Newbies and Administrators
https://www.tecmint.com/apacheperformancetuning/ 4/21
5/7/2017 5 Tips to Boost the Performance of Your Apache Web Server
Why? Kernel versions 2.4 and above have the sendLjle kernel Never Miss Any Linux Tutorials,
system call enabled by default. That, in turn, facilitates high Guides, Tips and Free eBooks
performance network Ljle transfers (which are desired in the Join Our Community Of 150,000+ Linux Lovers
context of web server-client communications) and enables and get a weekly newsletter in your inbox
# uname r
threads per child process but with an advantage: it causes Are you subscribed?
KeepAlive or idle connections (while they remain in that
4 Free Shell Scripting eBooks for Newbies and Administrators
https://www.tecmint.com/apacheperformancetuning/ 6/21
5/7/2017 5 Tips to Boost the Performance of Your Apache Web Server
# httpd V
The image below show that this particular web server is using
the prefork MPM.
×
Join Over 300K+ Linux Users
# /etc/httpd/conf.modules.d/00mpm.conf [On RedHat/CentOS based systems]
# /etc/apache2/modsavailable/<mpm>.load [On Debian/Ubuntu based systems]
and uncomment the line that loads the desired module like so:
LoadModule mpm_event_module modules/mod_mpm_event.so
Note: To make the event MPM work in Debian, you may have to
install the libapache2-mod-fastcgi package from the non-free
repositories.
Additionally, for CentOS you will need php-fpm (along with fcgi
and mod_fcgid) whereas in Debian it’s called php5-fpm (along
with apache2-mpm-event).
×
Last, but not least, restart the web server and the newly Join Over 300K+ Linux Users
installed php-fpm (or php5-fpm) service:
On RedHat/CentOS
257,757 11,967 39,682
On Debian/Ubuntu
SHARE
+
# systemctl restart apache2 php5fpm && systemctl enable apache2 php5fpm
0
Although you can set Apache to use a speciLjc MPM, that
conLjguration can be overridden on a per-virtual host basis in
the same fashion as indicated earlier.
0
Just drop the corresponding tags into the conLjguration Ljle for
each virtual host and you’re ready to go – but make sure you’re
using one and only one MPM per vhost. 75
This is what I see after changing the default MPM from prefork
to event in the same box shown in the previous image:
257,757 11,967 39,682
In CentOS 7, you will need to make sure that the http and https
services are enabled through the Ljrewall, and that the network
interface(s) are properly added to the default zone.
For example:
×
# firewallcmd zone=internal addinterface=tun6to4
Join Over 300K+ Linux Users
# firewallcmd zone=internal addinterface=tun6to4 permanent
# firewallcmd setdefaultzone=internal
# firewallcmd addservice=http
# firewallcmd addservice=https
# firewallcmd addservice=http permanent
# firewallcmd addservice=https permanent 257,757 11,967 39,682
# firewallcmd reload
Are you subscribed?
4 Free Shell Scripting eBooks for Newbies and Administrators
https://www.tecmint.com/apacheperformancetuning/ 10/21
5/7/2017 5 Tips to Boost the Performance of Your Apache Web Server
This is the php code that I’ve saved into a Ljle named
checkiffileexists.php :
×
Join Over 300K+ Linux Users
<?php
$filename = 'test.php';
if (file_exists($filename)) {
echo "The file $filename exists";
} else { 257,757 11,967 39,682
echo "The file $filename does not exist";
} Are you subscribed?
?>
4 Free Shell Scripting eBooks for Newbies and Administrators
https://www.tecmint.com/apacheperformancetuning/ 11/21
5/7/2017 5 Tips to Boost the Performance of Your Apache Web Server
Then we will run the Apache benchmark tool (ab) with 200
simultaneous requests until 2000 requests are completed:
# ab k c 100 n 2000 localhost/checkiffileexists.php
Let’s run the test and compare the results. Pay attention to the
performance statistics:
×
Join Over 300K+ Linux Users
<IfModule mpm_event_module>
StartServers 3
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 30
MaxConnectionsPerChild 1000
</IfModule>
×
Join Over 300K+ Linux Users
In any event, it is highly recommended that you refer to the
Apache 2.4 docs to see which directives are allowed for your
chosen MPM.
# httpd M [On RedHat/CentOS based systems]
# apache2ctl M [On Debian/Ubuntu based systems]
# a2dismod module_name
Summary
In this article we have reviewed 5 tips that will help you tune
the Apache web server and increase its performance. In
addition, you should remember that optimization and
performance without security is pointless, so you may want to
refer to the install mod_pagespeed to improve webserver
performance and Apache hardening tips article in
Tecmint.com as well.
×
Join Over 300K+ Linux Users
1. Stay Connected to: Twitter | Facebook | Google Plus Are you subscribed?
4 Free Shell Scripting eBooks for Newbies and Administrators
https://www.tecmint.com/apacheperformancetuning/ 16/21
5/7/2017 5 Tips to Boost the Performance of Your Apache Web Server
($3.95/month).
format.
Tags: Apache
5 Things I Dislike and Love About How to Setup Name-based and IP-
GNU/Linux based Virtual Hosts (Server Blocks)
with NGINX
7 44 0
×
Join Over 300K+ Linux Users
20 RESPONSES
Comments 1 Pingbacks 0
You don’t need to compile from Source unless you need to do something
differently to the package maintainer!
And having your server drop a connection and force a user to refresh? WTF are
you on!?
Reply
« Older Comments
Website
Notify me of followup comments via e-mail. You can also subscribe without
commenting.
Post Comment
How to Limit the Network Bandwidth 10 Useful Interview Questions on Linux Atom – A Hackable Text and Source
Used by Applications in a Linux System Services and Daemons Code Editor for Linux
with Trickle 10 MAR, 2014 29 JUN, 2015
25 FEB, 2015
10 Core Linux Interview Questions and Install Wine 2.2 (Development Release)
Install IfTop (Bandwidth Monitoring) Answers to Run Windows Games and Apps on
Tool in RHEL / CentOS / Fedora 26 JAN, 2014 Linux ×
Join Over 300K+ Linux Users
5 OCT, 2012 31 OCT, 2015
10 Useful “Squid Proxy Server”
20 Useful Commands of ‘Sysstat’ Interview Questions and Answers in Install Joomla 3.6 Using LAMP (Linux,
Utilities (mpstat, pidstat, iostat and Linux Apache, MySQL, PHP) on RHEL,
sar) for Linux Performance Monitoring 28 JUL, 2014 CentOS257,757
& Fedora 11,967 39,682
screenFetch – An Ultimate System 11 Basic Linux Interview Questions and 2013: The Golden Year for Linux – 10
Information Generator for Linux Answers Biggest Linux Achievements
7 JUL, 2014 18 NOV, 2013 31 DEC, 2013
Tecmint: Linux Howtos, Tutorials & Guides © 2017. All Rights Reserved.
This work is licensed under a (cc) BY-NC
The material in this site cannot be republished either online or o�ine,
without our permission.
×
Join Over 300K+ Linux Users