Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've just bought a VPS from Hosting24 (VPSx1). It has 1GB RAM and a 1Ghz core dedicated to the account. I've setup my sites, but every time I load the site, Apache seems to be using 100% of the CPU and creating quite a few processes.

The processes it loads is /usr/sbin/apache2 -k start, but I have no idea what that is - is it just the normal Apache process?

The site is currently running WordPress, and I suspect the problems might be to do with MySQL, as I created a really simple test PHP script with the following, to see if PHP was parsing slowly:


  echo microtime();

  echo "<br><br>Hi!<br><br>";

  echo microtime();


But the times at the top and bottom are exactly the same, indicating that PHP is running quickly.

I currently have the following Apache modules enabled:

  • actions
  • alias
  • auth_basic
  • authn_file
  • authz_default
  • authz_groupfile
  • authz_host
  • authz_user
  • autoindex
  • cache
  • cgi
  • dav
  • daf_fs
  • dav_svn
  • deflate
  • dir
  • disk_cache (I enabled to try and speed things up)
  • env
  • fcgid
  • mime
  • negotiation
  • php5
  • proxy
  • proxy_balancer
  • proxy_connect
  • proxy_http
  • reqtimeout
  • rewrite
  • setenvif
  • ssl
  • suexec

This is my apache2.conf:

# Based upon the NCSA server configuration files originally by Rob McCool.
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "foo.log"
# with ServerRoot set to "/etc/apache2" will be interpreted by the
# server as "/etc/apache2/foo.log".

### Section 1: Global Environment
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
# Do NOT add a slash at the end of the directory path.
#ServerRoot "/etc/apache2"

# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
LockFile ${APACHE_LOCK_DIR}/accept.lock

# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars

# Timeout: The number of seconds before receives and sends time out.
TimeOut 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
KeepAlive on

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
KeepAliveTimeout 10

## Server-Pool Size Regulation (MPM specific)

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    MaxClients          150

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
#              graceful restart. ThreadLimit can only be changed by stopping
#              and starting Apache.
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers         2
    MinSpareThreads      2
    MaxSpareThreads      10
    ThreadLimit          64
    ThreadsPerChild      5
    MaxClients           50
    MaxRequestsPerChild  100

# event MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers         2
    MaxClients           50
    MinSpareThreads      2
    MaxSpareThreads      10
    ThreadLimit          64
    ThreadsPerChild      5
    MaxRequestsPerChild  100

# These need to be set in /etc/apache2/envvars

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.

AccessFileName .htaccess

# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all

# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
DefaultType text/plain

# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog ${APACHE_LOG_DIR}/error.log

# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:
Include httpd.conf

# Include ports listing
Include ports.conf

# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/
SSLProtocol ALL -SSLv2
NameVirtualHost ####:80
NameVirtualHost ####

# Include PHPMyAdmin file
Include /etc/phpmyadmin/apache.conf

# Set root 
DocumentRoot /var/www

And the file in sites-enabled for my site:

<VirtualHost ####:80>
DocumentRoot /var/www/
ServerName ####
<Directory /var/www/>
allow from all
Options +Indexes
Redirect 301 http://#### "http://www.####"
Action application/x-httpd-php5 /cgi-bin/php5.cgi
AddType application/x-httpd-php5 .php5
AddType application/x-httpd-php5 .php
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
SuexecUserGroup "#1001" "#1000"
RLimitCPU 50 80
RLimitNPROC 60 100
LogLevel info

My settings might be incorrect, and I'm using Webmin/Virtualmin to configure this all (plus some manual editing), so I might be best off setting up the virtual host again. Is there anything I'm missing?

Also, when I looked at netstat, watching for port 80, each time I refreshed the site it created like 50 new TCP connections. For the amount of data Wordpress would need to send (which is what the site is running), then I could imagine that being the case. If anyone needs me to, I can run that and give you the output.

If there is any more information I need to give - please ask me for it - I'm experienced in running servers, however I'm not 100% sure about Apache and it's configs

Output of ps auxf | grep apache

root@vps:/etc/apache2/sites-enabled# ps auxf | grep apache
root      3511  0.0  0.0   1776   572 pts/0    S+   00:37   0:00  |       \_ grep apache
root       634  0.0  1.6  55332 16828 ?        Ss   00:12   0:00 /usr/sbin/apache2 -k start
www-data  1205  0.0  0.4  35492  5040 ?        S    00:16   0:00  \_ /usr/sbin/apache2 -k start
www-data  1207  0.0  3.0  76996 31476 ?        S    00:16   0:00  \_ /usr/sbin/apache2 -k start
www-data  1208  0.0  3.1  77932 32624 ?        S    00:16   0:00  \_ /usr/sbin/apache2 -k start
www-data  1209  0.0  3.0  77004 31632 ?        S    00:16   0:00  \_ /usr/sbin/apache2 -k start
www-data  1210  0.0  3.0  77048 32128 ?        S    00:16   0:00  \_ /usr/sbin/apache2 -k start
www-data  1212  0.0  1.0  56532 11012 ?        S    00:16   0:00  \_ /usr/sbin/apache2 -k start
www-data  1833  0.0  3.0  77296 32128 ?        S    00:23   0:00  \_ /usr/sbin/apache2 -k start
www-data  2224  0.0  0.6  55332  6484 ?        S    00:25   0:00  \_ /usr/sbin/apache2 -k start
root       638  0.0  0.0   2240   472 ?        Ss   00:12   0:00 /usr/sbin/htcacheclean -d120 -i -p/var/cache/apache2/mod_disk_cache -l300M
share|improve this question
Can we assume you meant 1GB RAM? Also, can you give a output of 'ps auxf | grep apache' –  rfelsburg Mar 11 '13 at 20:34
Oh wow, how did I miss that? Yea, it's 1GB. I've added the output to the bottom of the post :) –  ToshNeox Mar 11 '13 at 20:39
I forgot to note, this system runs Debian 6 virtually, however I'm going to rebuild the VPS with Ubuntu 12 and install LAMP/Webmin/Virtualmin manually in the hope that it will fix this problem. Default config files are usually a pain in the ass –  ToshNeox Mar 13 '13 at 18:04
Never mind - I've changed the OS from Debian 6 to Ubuntu 12. It handles resources better and there's no lag now. –  ToshNeox Mar 14 '13 at 7:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.