How to setup Nginx for WordPress on DigitalOcean

I decided to switch from Apache to Nginx.

I have a couple of WordPress sites on a DigitalOcean droplet, so I needed to reconfigure them to be used with Nginx. I basically followed this guide which was great for most of it, but I was still not getting the sites loading properly (404 errors, forbidden).

I needed to tweak the server block files to get it working, and this is what I came up with..

In /etc/nginx/sites-available create a separate file for each domain you’re hosting. For one of mine, I called it goforself.me to correspond with my Go For Self website, and this is the contents of that file…

Then in /etc/nginx/sites-enabled/ create a symlink like so

ln -s ../sites-available/goforself.me .

I like to have my sites being only accessed over HTTPS, so there are a couple more steps to get this going. I basically followed this guide, and this is the essence of what needs to be done..

First install certbot

For my Go For Self website setup above, I then type

sudo certbot --nginx -d goforself.me -d www.goforself.me

and I choose option 2 to always redirect to HTTPS.

And that is pretty much it. You’ll need to restart nginx to get it going.. so I go

service nginx restart

Any questions, let me know!

By |2018-06-05T19:25:28+00:00January 4th, 2018|blog|1 Comment

About the Author:

Andrew Golightly is the lead web developer here at Golightly+. He is a passionate fullstack JavaScript developer. And creates native apps too using React Native. To balance his love for coding, he also works as a counsellor.

One Comment

  1. […] If you want to create a new certificate, have a look at the end of this article. […]

Leave A Comment