May 2020
« Mar    


WordPress Quotes

History is a relentless master. It has no present, only the past rushing into the future. To try to hold fast is to be swept aside.
John F. Kennedy
May 2020
« Mar    

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (40)
Ansibile (19)
Apache (135)
Asterisk (2)
cassandra (2)
Centos (211)
Centos RHEL 7 (270)
centos8 (3)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (30)
Eassy (11)
ELKS (1)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
health (2)
horoscope (23)
Hyper-V (10)
IIS (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (7)
Ldap (5)
Linux (188)
Linux Commands (166)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (35)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (35)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (62)
Ubuntu (1)
Uncategorized (30)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

0 visitors online now
0 guests, 0 bots, 0 members

Hit Counter provided by dental implants orange county

Apache webserver


The default with Centos/Redhat is 2.2.x (CentOS like the Red Hat OS it derives from, are geared towards stability and so tend to lag behind what’s cutting edge)

2.4 is available and offers improved performance
2.4 moves away from Prefork MPM and moves to “event” mpm which uses a lot less memory

new features are listed here

If you want to upgrade source compiling seems the mist popular way although here is a link to do it via yum

Terminology and how it all fits together

An apache thread is essentially another term for an apache child process and can be used interchangeably.

Apache has a root process, and then for each client (i.e. whenever any separate user goes to your website) it creates a “child” process.

Each of these processes will use a certain amount of memory (which is dictated by your application). This memory usage is not static, so can vary between each process. It can also vary depending on what the application is serving to each client.

Apache doesn’t allow multiple versions of PHP using mod_php, so you need to compile it using fastcgi support. This will allow us to configure multiple sites, each one with a different version of PHP

If you are using Name Based Virtual Hosting for SSL, if a domain is unconfigured for the ip:port it will be sent to a default virtual host.
Apache defaults the first virtual host it sees for an ip:port combination to be the default. This can be confirmed with the command httpd -S


httpd –S # show the virtuahost settings (taken from the config file)
httpd –M # list of loaded Static and Shared Modules.
httpd –l # Output a list of modules compiled into the server. This will not
list dynamically loaded modules
httpd –X # run in debug mode
httpd -k start -c “DocumentRoot /var/www/html_debug/” Start up Apache using an alternative DocumentRoot.
This is useful if you’re trying out alternative versions of your web site, as it avoids editing the DocumentRoot option.
You can also use -c to set any other directive. Note that -c processes the directive after reading the config files (so it will overwrite config file settings),
whereas -C will process the directive before the config files.
httpd -k start -e debug# While you are debugging an issue, you can change the LogLevel of the Apache temporarily, without modifying the LogLevel directive in the httpd.conf as shown below using option -e.
the LogLevel is set to debug.Possible values you can pass to option -e are: debug, info, notice, warn, error, crit, alert, emerg


The main apache config is /etc/httpd/conf/httpd.conf
A lot lot of the parameters in that file can be tweaked to improve performance.
Some of the more useful settings (with typically assigned values):

StartServers 8

MinSpareServers 5

MaxSpareServers 20

ServerLimit 256

MaxClients 50

The StartServers, MinSpareServers, MaxSpareServers, and MaxClients regulate how the parent process creates children to serve requests.
In general, Apache is very self-regulating, so most sites do not need to adjust these directives from their default values.

MaxSpareServers and MinSpareServers determine how many child processes to keep while waiting for requests. If the MinSpareServers is too low and a bunch of requests come in, then Apache will have to spawn additional child processes to serve the requests. Creating child processes is relatively expensive. If the server is busy creating child processes, it won’t be able to serve the client requests immediately. MaxSpareServers shouldn’t be set too high, it can cause resource problems since the child processes consume resources.
Tune MinSpareServers and MaxSpareServers such that Apache need not frequently spwan more than 4 child processes per second (Apache can spwan a maximum of 32 child processes per second). When more than 4 children are spawned per second, a message will be logged in the ErrorLog.

The StartServers directive sets the number of child server processes created on startup. Apache will continue creating child process until the MinSpareServers setting is reached. Doesn’t have much effect on performance if the server isn’t restarted frequently. If there are lot of requests and Apache is restarted frequently, set this to a relatively high value. has some good hints

To know which fork (prefork MPM or worker MPM to alter) normally its prefork mpm

run httpd -l and you can see what appache was compiled with
Compiled in modules:

a good page on performance tuning

appache full status is a great help in troubleshooting, the following pages cover basic setup and troubleshooting when it doesn’t work if you have multiple vhosts it can get a bit messy –

RedirectMatch 301 ^/ # the following can be added to .htaccess or httpd.conf

Useful Modules

Modules allow you to add features to the default service, here are some of the more useful: example of how to use at

mod_limitipconn.c can be used to limit the amount of download from an IP

mod_log_forensic This module provides for forensic logging of client requests. Logging is done before and after processing a request, so the forensic log contains two log lines for each request.

Useful bits of code

ps aux | grep [h]ttpd | awk ‘{sum+=$6} END {print “httpd mem:”,sum /1024}’ – shows amount of memory being taken up by apache

apachectl fullstatus|grep -Eo ‘[1-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}’|grep -v “|sort -n|uniq -c|sort -nr|head -1 – shows who is connected at present by most connections

grep -c ’13/Jan/2014:14? /etc/httpd/logs/* | sort -t’:’ -nk 2 | grep -v :0 – good to see which logs files where populated at a certain hour

grep -c “Invalid URI in request” /etc/httpd/logs/* – check all logs for text displays number of instances each was found

awk ‘{print $4}’ access_log | cut -d: -f1 | uniq -c -shows number of requests per day

grep “13/Jan” access_log | cut -d[ -f2 | cut -d] -f1 | awk -F: ‘{print $2?:00?}’ | sort -n | uniq -c – shows number of connections per hour

grep “13/Jan/2014:19? access_log | cut -d[ -f2 | cut -d] -f1 | awk -F: ‘{print $2?:”$3}’ | sort -nk1 -nk2 | uniq -c | awk ‘{ if ($1 > 10) print $0}’ – number of requests per minute

cat error_log | grep “Jan 16? | grep “01:[0-9][0-9]:”|awk ‘{print $4}’ | awk -F: ‘{print $1 “:” $2}’ | uniq -c -show number of events at 15:xx on the 14 Jan

cut -d\” -f 2 /etc/httpd/logs/access_log | sort | uniq -c | sort -rnk 1 | head -n 30 -shows most popular pages

cat access.log |grep wp-login # check what wp-login pages have been called

cat ./access_list grep bot > bot_report.txt # output any mentions of the word bot

grep -e “01/Jun/2014? -e “31/May/2014? access_log* | awk ‘{print $1}’ | cut -d\? -f1 | sort | uniq -ic | sort -rn | head -25 check the access logs for connections via IP on the dates specified , order via number of connections

to log when appache hits a high number of users

if [ $number -gt 150 ]
date >> $log_path
echo “number of indivdual connections” >> $log_path
/usr/sbin/apachectl fullstatus | awk ‘{print $11}’ | grep -v “::1? | grep -v ^$ | sort | uniq -c | sort -n | tail >> $log_path
echo “pages being view” >> $log_path
/usr/sbin/apachectl fullstatus | awk ‘{print $11,$12,$13,$14}’ | grep -v “::1? | grep -v ^$ | sort | uniq -c |sort -n >> $log_path

Apache Bench

To load test your system use appache bench, check the performance (memory and load) and then retest.

Apache Bench (ab) is installed by default

(n= number of requests c=councurent connections i.e current clients)


ab – apache bench ab –n 100 –c 10 url (100 requests, and concurrency 10)

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




Blue Captcha Image


Protected by WP Anti Spam