I have a dedicated server with apache/php on ubuntu serving my WordPress blog with about 10K+ pageviews a day. I have W3TC plug in installed with APC.
But every now and then server stop responding or goes dead slow and i have to restart apache to get it back.
Heres my config what am i doing wrong?
ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
TimeOut 40
KeepAlive on
MaxKeepAliveRequests 200
KeepAliveTimeout 2
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 8
ServerLimit 80
MaxClients 80
MaxRequestsPerChild 1000
</IfModule>
<IfModule mpm_worker_module>
StartServers 3
MinSpareServers 3
MaxSpareServers 3
ServerLimit 80
MaxClients 80
MaxRequestsPerChild 1000
</IfModule>
<IfModule mpm_event_module>
StartServers 3
MinSpareServers 3
MaxSpareServers 3
ServerLimit 80
MaxClients 80
MaxRequestsPerChild 1000
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel error
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
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
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
Best Answer
My WordPress Performance and Caching Stack
This is a great WordPress performance stack for a low to mid range single server or VPS. I am classifying mid range as single core with around 1G of memory and fairly fast drives.
On your box this would be capable of serving over 10K page views per hour
Server Stack
PHP Cache
WordPress Performance Plugin Stack
With W3 Total Cache we are using disk for page cache and minify because Nginx will be serving our static files very fast.
How to configure Nginx to serve static files and pass PHP to Apache
The problem with using Apache alone is that it opens up a connection and hits php on every request even for static files. This wastes connections because Apache will keep them open and when you have lots of traffic your connections will be bogged down even if they are not being used.
By default Apache listens for requests on port 80 which is the default web port. First we are going to make changes to our Apache conf and virtual hosts files to listen on port 8080.
Apache Config
httpd.conf
set KeepAlive to off
ports.conf
Per Site Virtual Host
You should also install mod_rpaf so your logs will contain the real ip addresses of your visitors. If not your logs will have 127.0.0.1 as the originating ip address.
Nginx Config
On Debian you can use the repositories to install but they only contain version 0.6.33. To install a later version you have to add the lenny backports packages
$ nano /etc/apt/sources.list
Add this line to the file
deb http://www.backports.org/debian lenny-backports main
$ nano /etc/apt/preferences
Add the following to the file:
Issue the following commands to import the key from backports.org to verify packages and update your system's package database:
Now install with apt-get
apt-get install nginx
This is much easier than compiling from source.
Nginx conf and server files config
nginx.conf
Now you will need to set up your Nginx virtual hosting. I like to use the sites-enabled method with each v host sym linked to a file in the sites-available directory.
default.conf
Note:
The static cache settings in the following files will only work if the Nginx proxy cache integrator plugin is enabled.
Per WordPress site conf (For multi site you will only need one vhost)
Self Hosted CDN conf
For your self hosted CDN conf you only need to set it up to serve static files without the proxy pass
Now start the servers
The Benchmark Results
On Apache Bench this setup can theoretically serve 1833.56 requests per second