Report this

What is the reason for this report?

WordPress SEO causing error on Nginx server

Posted on July 19, 2014

Hi there

I’m having a little problem after migrating from shared hosting (Apache) to a 512mb Droplet running a LEMP stack (I used the excellent EasyEngine to create a WordPress site).

After following the guide over at EasyEngine for migration I managed to import everything correctly. I then pointed the DNS to my Droplet (changed nameservers etc) and was all set to go.

Weirdly, I can access my wp-admin area of my site and everything about it, but when I try to load my homepage or a specific article - I get this:

http://gyazo.com/6c2cd53386844b3862a8dbb5b58a5407

After carefully deactivating each and every plugin I honed the error down to Yoast’s WordPress SEO. After deactivating that, the site functions perfectly, however, that plugin is an essential part of my site so I have to get it all working together.

The problem is, I do not know where the error lies.

I have examined my Nginx config files both on /etc/nginx/sites-available & /etc/nginx/sites-enabled as well as the default nginx config files but I cannot seem to find a solution.

I have transferred over my sitemap which Yoast creates, and it works fine. But that begs the question - what part of the plugin is causing the error on Nginx?

It’s literally just that problem and otherwise the site functions perfectly (or at least I think so!)

Any help would be massively appreciated.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

It seems that Yoast’s WordPress SEO requires rewrite rules and writes an Apache style .htaccess file in the site’s root directory.

In your Niginx config (likely /etc/nginx/sites-enabled/default), try adding the following in side of your server block:

rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

See here.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.