Digital Ocean WordPress Permalinks


  • How to fix permalink issues on a Ubuntu 14.04 Digital Ocean server

Setting up custom permalink on a Digital Ocean server is something that I’ve had to do time and time again. And each time I come to do it, I’ve forgotten how. So I’ve decided to document it, mostly for my own benefit to stop me losing my mind when I inevitably come to do it 6 months from now, but also in the hope it will help out someone else.

So perquisites:

  • Firstly, this is not about how to set up MySQL, phpMyAdmin etc.
  • Nor is it about how to install WordPress from stat to finish, only about setting up custom permalinks.
  • This is on a clean Ubuntu 14.04 x64 server, not going down the auto setup option for wordpress that Digital Ocean offers. I would assume that image would come already configured appropriately, but haven’t tried it myself.
  • This should work with both the ip url or a custom domain url.

Firstly make sure the root directory of your install (where your wp-config.php file lives) contains a .htaccess file. . The contents of the file should look like this:

If for some reason it doesn’t, you can just create a new file in your chosen script editor and save it as ‘.htaccess’.

You need to enable the server rewrite module. To do this log into your droplet in the terminal and run the following command:

You need to make a small change to the apache2.conf file. You can do this via the terminal or logging into the server with an FTP client editing the file with a text editor. Either way the file you need is located in the /etc/apache2/ directory and called apache2.conf.

Full path: /etc/apache2/apache2.conf

You need to make a subtle but important change. Locate the block of code that looks like this:

Make sure you’re in the correct code block as there are three that look similar, make sure it starts with ‘Directory /var/www’ as this is the public root of the server. In my case the block started at line 164.

Change the AllowOverride line to:

Finally, any changes made to the server servings require a server restart in order to take affect. Do this with this command:

With that done, your “pretty urls” should now work. One final note is sometimes its worth going into the permalink setting and hitting save, even if its just reapplying the same settings.