Data-First development is an idea that I’ve had for a while and it’s the way I approach most development projects these days. I’m sure that you will have done it too, but just never quite thought about it.
The way I see development is to start with the data. At the very beginning of a project it’s important to get the specification right, and as part of that – design the data store and models. That makes sense, but once they are designed they are inherently forgotten about until they need to be changed.
Instead, I propose a simple workflow that at the start of the project admin interfaces to manage the data is the first thing that is built. There are a few reasons.
Amateurs sit and wait for inspiration, the rest of us just get up and go to work.— Stephen King
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!