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..

For my Go For Self website setup above, I first 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!