Dropbox is pretty awesome, and enhancing the Automatic WordPress Backup script to send the files to Dropbox is fairly straightforward.
This tutorial is going to give us an off-site backup of anything we want. That’ll occur automatically, like magic. :D
As usual, ssh into your server.
I’m a huge fan of Trakt, but I know people who are tempted by VIP solely for the widgets. Now that’s great, but those widgets probably aren’t worth your $5. If supporting websites is important to you, this is probably not the post for you. It’s likely that this method could break in the future, keep that in mind!
We’re going to use our server as a bit of a proxy.
Here’s a couple of examples of what we’ll be creating (they’re live).
Migrating WordPress from one host to another can seem daunting, but unless you’re changing the domain name it’s actually fairly straight forwards. For this tutorial, I will assume you are NOT changing the domain name.
There are 2 important parts to any WP installation, the database and the filesystem. In particular, the wp-content directory. In order to speed things up, my advice is to install the WP software as new (forcing an update to the latest version). Feel free to copy old system files if required, but it’s mostly just a waste of time and bandwidth.
Optimising WordPress is a fairly straight forward process, and in doing so it’s possible to squeeze a serious amount of speed and power out of a cheaper server.
Go ahead and ssh in!
Cron is a system that runs programs (or commands) at scheduled times. WP Cron is the WordPress implementation that mimics this. Due to the necessity for WordPress to be compatible on various systems it’s not, by default, done “natively”. Instead WordPress triggers the appropriate hooks the next time the website is accessed. It’s possible to fake this with tools like Pingdom which hits your site every minute to report downtime, but we’ll go ahead and create a full cron system.
The first step is to disable WP Cron, and it’s crazy simple.
Scroll down and insert this line (near the bottom), feel free to add that other command if you are missing it.
define('FS_METHOD', 'direct'); define('DISABLE_WP_CRON', true); /* That's all, stop editing! Happy blogging. */
Now we can edit the crontab, Linux’s built in cron system
Install all the WordPress
As part of this installation guide I’ll be showing you how to install the cli, setup the database and configure wp. It’ll be a relatively long post, however by the end you’ll have a working WordPress installation. Without further ado!
The CLI is incredibly useful, it allows us to install WordPress, take database backups and anything else you might want to do in the web interface. Installing it is simple! From a server ssh connection:
I always like to work out of the temp directory when downloading and installing files, just incase I mess up or leave a file behind.
So, what we’re going to want to do is download the cli installation script.
Self hosting an email server is generally a bad idea. I’d recommend using Google Apps gmail service for hosting one. And DigitalOcean has a button which will setup the required network settings too! However, for sending email it’s sometimes pretty useful, we’ll setup sendmail for sending only.
sudo apt-get install mailutils
Choose “Internet Site” when prompted. And enter your domain name as the system mail name.
The way to get started is to quit talking and begin doing.— Walt Disney
Free SSL certificate? Don’t mind if I do.
SSL is important, even Google is using it in the ranking algorithms now but historically it could be quite costly. Now that we have full server control, albeit virtual, we can use the Let’s Encrypt client to get a certificate for ourselves. And, as always – in a ridiculously straightforward way.
At this point I’m going to make a few assumptions. In order to get an SSL certificate you must own the domain you are trying to get it for. And additionally, it must be pointed at the server you are trying to authenticate. You can do this by setting an A Record to point the domain to the IP address.
It’s possible to do this step at any stage, but I much prefer doing it before installing WordPress in order to make the process smoother.
Firstly, ssh into your server and then run the following commands.
sudo apt-get update sudo apt-get install letsencrypt
We are updating the repository list and then installing the letsencrypt client. This has actually been renamed to certbot however the version included in the Ubuntu 16.04 repositories is perfectly fine for now!
By default, Nginx doesn’t have native PHP processing. However, getting it up an running is a cinch. We will use php-fpm, fastCGI process manager. We’re going to install this and then tell nginx to pass php processing to this module.
sudo apt-get install php-fpm php-mysql
We’re actually installing 2 packages here, php and a mysql helper package for communicating with the database.
Guess what, you just installed PHP. However, by default it is setup with an insecure setting – we can change that.
MySQL or MariaDB?
MySQL has become the golden standard when working with PHP, however due to concerns about the acquisition by Oracle some of the original developers have forked it and created MariaDB. It is designed to be a “drop in replacement” that follows all the same API standards as MySQL. Let’s get to it!
The first thing you’re going to want to do is ssh into your server.
Now need to know the version of Ubuntu we’re using. At the time of writing this I installed 16.04. But you can check yours by running:
Distributor ID: Ubuntu Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial
MariaDB provides a nice web interface to determine the repository we need to interface.