What is being left out here is dealing with PHP, which is actually a huge factor in all of this.
Nginx doesn't have any kind of module for dealing with PHP natively the way Apache does via mod_php. This gives you essentially two choices: either run PHP via FastCGI or have Nginx proxy PHP requests to Apache (and let Nginx handle the rest). Each has its benefits and drawbacks which you can easily research in detail, however I've found it generally a better choice to proxy PHP scripts to Apache.
"But wait!" you cry. "Isn't the point here to get away from Apache?"
Well, the point is to run a more efficient server. When configured to solely serve PHP pages (by disabling most of Apache's modules), Apache becomes quite efficient. And the major benefit of Apache over FastCGI for PHP is that it can scale needed script processes on demand, whereas FastCGI must have a number of processes set beforehand.
Also, it's really, really easy to set Nginx to proxy scripts to Apache. You start Apache on a separate port (8080 is a common one), add some lines to your Nginx config, maybe setup an Apache virtual host, and you're good to go.
Serving PHP with FastCGI, in my experience, is quite the opposite. Among other things, you need to write a FastCGI-PHP init script. Or find one. And, really, the overall process is still very poorly documented.
Either way, you'll need to look into either of these options if you're going to run Wordpress and Nginx.
You'll want to edit the following files to have Apache listen in on port 8080:
in /etc/apache2/ports.conf:
NameVirtualHost *:8080
Listen 8080
And then in your virtual host files (/etc/apache2/sites-available/)
<VirtualHost *:8080>
Then add something like this to your Nginx config's 'server' area:
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
Truthiness, you may want to read this thread.
Posted By: roshamboYou'll want to edit the following files to have Apache listen in on port 8080:
in /etc/apache2/ports.conf:
NameVirtualHost *:8080 Listen 8080And then in your virtual host files (/etc/apache2/sites-available/)
<VirtualHost *:8080>Then add something like this to your Nginx config's 'server' area:
location ~ \.php$ { proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; }