If you have your own cloud server there’s a good chance you’ll be connecting to it remotely using SSH. On unix systems like Mac OS this is super simple, just open the terminal and type ssh. On Windows, it’s not quite so straight forwards. In this post I’ll explain how to get started and setup so you can be as cool as everyone else.
The first thing you need to do is download the program. There are two utilities we need; PuTTY which is used for connecting to servers and PuTTYgen which is used for generating SSH key pairs. You will find the most appropriate file under Package files.
With it installed go ahead and run PuTTYgen so we can generate ourselves what is essentially a very secure username and password. It’s a little more complicated than that, but this is how we can verify ourselves when we connect to the server.
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.
Dropbox is pretty awesome, and enhancing the Automatic WordPress Backup script to send the files to Dropbox is fairly straight forwards.
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.
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.
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.
Nginx or Apache?
Apache has been around since 1995 and powers more websites than any other software. However, under heavy load performance hits a bottleneck and ultimately suffers. Nginx, Engine X, was designed to address some of these issues. If you’ve been on a shared host, chances are you’ve been using Apache. We’re going to setup Nginx – hey, performance matters. We might as well do it right, right?
The first thing you’re going to want to do is ssh into your server.
Nginx is part of the Ubuntu core repositories, which means we can use the
apt package manager for a sleek installation.
sudo apt-get update sudo apt-get install nginx
The first thing we’re going to want to do is update the local index before installing nginx. You’ll be asked to confirm the installation. Type
Y to begin.