Nginx and wordpress with apache
I was getting quiet a bit of traffic on another wordpress site, I’ve been running. I had apache as running php and this started to become an issue. I could upgrade the hardware, but it didn’t seem right - because really it’s not that much traffic… So, I decided to see if I could put nginx in front of apache. Here’s what I have now and it’s working out pretty well with the help of one little note from Millarian.
location / {
index index.html index.htm;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($request_method != GET) {
proxy_pass http://apache;
break;
}
if ( $request_filename ~* .*\.php) {
proxy_pass http://apache;
break;
}
# check if the file exists and serve it
if (-f $request_filename) {
access_log off;
expires 10d;
break;
}
if (!-f $request_filename) {
proxy_pass http://apache;
break;
}
}
Now all static file’s are served directly by nginx. Dynamic requests are passed to apache. I was also able to reduce the value of MaxClients, on the server to avoid running out of memory. MaxClients in apache controls the number of server processes allowed to start. With PHP running each apache process can be as large as 30 - 60 megs per process. This value in fedora core, is set to 256 by default.

Recent Comments