HostOnNet Blog

Apache Optimization

Looking for Linux Server Admin or WordPress Expert? We can help.

Apache Configuration

To optimize Apache, you can use perl script available at

https://github.com/richardforth/apache2buddy/

Download and run

wget https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl
perl apache2buddy.pl

You will see detailed analysis of your Apache web server installation with recommendations.

[root@server12 ~]# perl apache2buddy.pl 

                             |           ___ \   |                 |      |                   |     
   _` |  __ \    _` |   __|  __ \    _ \    ) |  __ \   |   |   _` |   _` |  |   |     __ \   |     
  (   |  |   |  (   |  (     | | |   __/   __/   |   |  |   |  (   |  (   |  |   |     |   |  |     
 \__,_|  .__/  \__,_| \___| _| |_| \___| _____| _.__/  \__,_| \__,_| \__,_| \__, | _)  .__/  _|     
        _| Apache Tuning and Advisories for Professional Administrators.    ____/     _|            


About...
[ INFO     ] apache2buddy.pl is a fork of apachebuddy.pl.
[ INFO     ] MD5SUMs now availiable at https://raw.githubusercontent.com/richardforth/apache2buddy/master/md5sums.txt
[ INFO     ] SHA256SUMs now availiable at https://raw.githubusercontent.com/richardforth/apache2buddy/master/sha256sums.txt
[ INFO     ] apache2buddy.pl is now released under the Apache 2.0 License. See https://raw.githubusercontent.com/richardforth/apache2buddy/master/LICENSE
[ INFO     ] apache2buddy.pl is now hosted from github. See https://github.com/richardforth/apache2buddy
[ INFO     ] Changelogs and updates in github. See https://raw.githubusercontent.com/richardforth/apache2buddy/master/changelog

Performing Auto-Discovery, and Pre-Flight Checks...
[ OK       ] This script is being run as root.
[ OK       ] The utility 'pmap' exists and is available for use: /usr/bin/pmap
[ OK       ] The utility 'netstat' exists and is available for use: /bin/netstat
[ OK       ] 'php' exists and is available for use: /usr/bin/php
[ OK       ] The utility 'apachectl' exists and is available for use: /usr/sbin/apachectl
[ OK       ] The port (port 80) is a valid port.
[ INFO     ] We are attempting to discover the operating system type and version number ...
[ INFO     ] OS Name: CentOS
[ INFO     ] OS Release: 6.8
[ OK       ] Apache2buddy supports this OS Release/Version.
[ INFO     ] Hostname: server12
[ INFO     ] Primary IP: 188.40.131.92
[ INFO     ] We are checking the service running on port 80...
[ INFO     ] The process listening on port 80 is nginx:
[ INFO     ] The process running on port 80 is not Apache. Falling back to process list...
[ INFO     ] Apache is actually listening on port 8080
[ INFO     ] The process running on port 8080 is Apache/2.2.15 (Unix).
[ INFO     ] Apache has been running 12d 22h 59m 07s.
[ INFO     ] The full path to the Apache config file is: /etc/httpd/conf/httpd.conf
[ INFO     ] Apache is using prefork model.
[ INFO     ] pidfile setting is run/httpd.pid.
[ INFO     ] Actual pidfile is /var/run/httpd/httpd.pid.
[ INFO     ] Parent PID: 20357.
[ OK       ] Memory usage of parent PID is less than 50MB: 6392 Kilobytes.
[ INFO     ] Your server has 31970 MB of PHYSICAL memory.
[ INFO     ] Your ServerLimit setting is 256.
[ INFO     ] Your MaxClients setting is 256.
[ OK       ] Current Apache Process Count is 9, including the parent PID.
[ INFO     ] Number of vhosts detected: 11.
[ OK       ] Current Apache vHost Count is less than maxclients.
[ INFO     ] Your MaxRequestsPerChild setting is 4000.

Detecting Control Panels...
[ INFO     ] This server is NOT running Plesk.
[ INFO     ] This server is NOT running cPanel.

Detecting PHP Memory Limits...
[ INFO     ] Your PHP Memory Limit (Per-Process) is 128 MB.

Detecting additional services for consideration...
[ INFO     ] Mysql Detected => Using 358.58 MB of memory.
[ INFO     ] Redis Detected => Using 15.56 MB of memory.

Detecting Large Log Files...
PRO TIP: This is a precursor to the following  2 checks that may appear to hang if there are very large error logs.
PRO TIP: If those process do appear to hang, press CTRL + c to exit the program, and then go check the logs we report below, if any.
[ OK       ] No large logs files were found in /var/log/httpd.

Detecting If Maxclients or MaxRequestWorkers has been hit recently....
[ OK       ] MaxClients has not been hit recently.

Detecting PHP Fatal Errors....
[ WARNING  ] PHP Fatal errors were found, see the most recent entries below (CHECK THE DATESTAMPS!)
[ ADVISORY ] Check the logs manually, there may be much more.

Apache Logs (LAST 5 ENTRIES):
/var/log/httpd/error_log-20170122:[Thu Jan 19 21:15:58 2017] [error] [client 138.197.202.197] PHP Fatal error:  Call to undefined function imagecreate() in /home/bizhat_s4/signup/captcha.php on line 11, referer: http://www.absba.org/showthread.php
/var/log/httpd/error_log-20170122:[Thu Jan 19 21:16:04 2017] [error] [client 88.201.58.40] PHP Fatal error:  Call to undefined function imagecreate() in /home/bizhat_s4/signup/captcha.php on line 11, referer: http://www.absba.org/showthread.php?t=945510
/var/log/httpd/error_log-20170122:[Thu Jan 19 23:29:59 2017] [error] [client 108.59.8.70] PHP Fatal error:  Class 'sql_db' not found in /home/bizhat_s2/includes/db.php on line 60
/var/log/httpd/error_log-20170122:[Fri Jan 20 11:08:46 2017] [error] [client 141.8.142.72] PHP Fatal error:  Class 'sql_db' not found in /home/bizhat_s2/includes/db.php on line 60
/var/log/httpd/error_log-20170122:[Sat Jan 21 14:52:46 2017] [error] [client 141.8.142.165] PHP Fatal error:  Class 'sql_db' not found in /home/bizhat_s2/includes/db.php on line 60

Detecting Package Updates for Apache or PHP...
[ OK       ] No package updates found.
[ ADVISORY ] I only checked for "apache specific" package updates (eg php, httpd, httpd24u, or apache2 packages only).

Analyzing apache memory use...
[ INFO     ] httpd is currently using 286.89 MB of memory.
[ INFO     ] The smallest apache process is using 9.80 MB of memory
[ INFO     ] The average apache process is using 30.40 MB of memory
[ INFO     ] The largest apache process is using 38.68 MB of memory

Results...
[ OK       ] Going by the average Apache process, Apache can potentially use 7782.40 MB RAM:
		Without considering services: 24.35 % of total installed RAM
		Considering extra services: 24.64 % of remaining RAM
[ OK       ] Going by the largest Apache process, Apache can potentially use 9902.08 MB RAM:
		Without considering services: 30.98 % of total installed RAM
		Considering extra services: 31.34 % of remaining RAM

Generating reports...
### GENERAL FINDINGS & RECOMMENDATIONS ###
--------------------------------------------------------------------------------
Apache2buddy.pl report for server: server12 (188.40.131.92):

Settings considered for this report:
	Your server's physical RAM:                                   31970 MB
	Remaining Memory after other services considered:             31595 MB
	Apache's MaxClients directive:                                256      <--------- Current Setting    
	Apache MPM Model:                                             prefork
	Largest Apache process (by memory):                           38 MB
[ !! ] 	Your MaxClients setting is too low.
	Your recommended MaxClients setting is between 734 and 816.            <------- Acceptable Range (10% of MAX)

	Max potential memory usage:                                   9902 MB
	Percentage of TOTAL RAM allocated to Apache:                  30.98  %
	Percentage of REMAINING RAM allocated to Apache:              31.34  %
--------------------------------------------------------------------------------
A log file entry has been made in: /var/log/apache2buddy.log for future reference.

Last 5 entries:

2017/01/26 02:51:04 Model: "Prefork" Memory: "31970 MB" Maxclients: "256" Recommended: "816" Smallest: "9.80 MB" Avg: "30.40 MB" Largest: "38.68 MB" Highest Pct Remaining RAM: "31.34%" (30.98% TOTAL RAM)

[root@server12 ~]# 

Posted in Apache

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.