Running your own web hosting can be a daunting task. It is normally easier to leave it to a professional hosting company, but the time will come when you realise that you need more control. Either to run something that requires more power, or because the shared hosting platform doesn’t allow you the flexibility you need. I have run on shared-hosting for years with volume plans from the various providers in South Africa. (Hetzner, Web Africa and Afrihost to name a few) In addition I have also used a number of cheaper international alternatives such as Godaddy and siteground.
I host about 50 websites for various friends, family and businesses. I’m always the “go to guy” when it comes to web in my circles so I am constantly helping with some website or another.
I use VPS’s for various things, including hosting multiple websites, VPN’s, web development, remote databases and testing opensource software.
My latest favourite provider for VPS’s is Digital Ocean. They’re easy to use, flexible and can easily be backed-up all from $5 per month. Sign up with this link and get 2 months free – https://m.do.co
Setting Up your first VPS to host a Website
So, the biggest problem with hosting your website on your own server is normally security. I am going to show you how to setup the VPS and manage it for free! This method will allow you to securely run your website including regular backups and easy to use control panel.
- Sign up for your Digital Ocean account – https://m.do.co (2 Months free using the link)
- Sign up for your Server Pilot account – https://serverpilot.io (Its free to use, but get $10 free in case you want to upgrade)
- Setup your first droplet in Digital Ocean
- If you’re going to use Serverpilot.io to manage your server, then select Ubuntu. If you’re hoping to use WordPress, Don’t use the One-Click apps, as you’ll be able to install it from Server Pilot which will give you a more integrated approach.
- Select the size of server you need – If it is for a basic website, wordpress, mautic, sendy or Invoice Plane, then I would start off with a $5 server. If you need to increase the capacity later, you can do it at a click. That’s the beauty of a VPS.
- I normally host my servers in Europe. Europe generally has the lowest latency to South Africa. But choose the location closest to your target audience. Whilst speed and latency is always improving, nothing beats having your content closest to the people who need it. (You can also integrate a CDN to improve your speed and robustness).
- Select any options you may need / want. I generally don’t need any of them, however, backups are a good option. They clone your server weekly and charge 20% of the monthly fee. ($1 on a $5 server), they keep 4 weeks worth of backups. This is especially ideal if you’re hosting live websites as you can easily restore a complete website including files and databases in a couple of clicks.
Ok, you’re done!
Give it some time to create the instance of your VPS (Droplet). It’ll take a couple of minutes and then tell you it is online. Once this has happened, then you will receive an email with the root password. You’ll need this to setup Server Pilot.
Setting up Server Pilot
So why do you need Server Pilot?
In order to run a safe and secure website, you need to have it configured correctly. This is the most important part, and this is normally the reason people stick to hosting providers instead of running their own server or VPS. Server Pilot is the answer to this problem!
Server Pilot will safely configure your VPS to act as a web server. It’ll install the correct software, apply the latest patches and configure the built in firewall to make your VPS a solid platform to host your website without any worries about being compromised.
How does it do this? You’re going to configure server pilot with the root password you received earlier and let it do the rest.
ServerPilot.io will install a LAMP / LEMP stack on your server, setup a separate user, install the necessary patches and configure the firewall to be used as a web server.
What is a LAMP / LEMP stack?
This is the most common configuration for a web server on the internet today. The stack of software required to deliver your website to the internet.
- LAMP = Linux, Apache, MySQL and PHP
- LEMP = Linux, Nginx, MySQL and PHP (Nginx is pronounced Engine X, hence it is a LEMP stack)
This configuration is used to offer a quick and robust server. Apache is a great tool, but by putting Nginx in-between, it significantly reduces the load time of your website.
- So you’ve already setup your Serverpilot.io account, if not you can do so now with this link – https://serverpilot.io
- Click Connect Server and input your Droplet IP address from Digital Ocean.
- Input the root password you receievd via email from Digital Ocean in the root and SFTP fields. Leave the check box blank.
Click – “Connect to ServerPilot”
It’ll take a couple of minutes to install and configure all the necessary software, users and firewall.
So what’s next?
You need to setup an “App” on server pilot.
- Setup an app by tying in the name of your app (It can be anything, but should be lowercase and without .’s and ,’s)
- Input the domain name you plan on using. Keep in mind that you’ll need to change the DNS servers for your existing domain name to point to your new server. It’s not very difficult.
- Select the version of PHP you want to run, or WordPress if that’s what you want to install and create the app
- You’ll now have an internet facing “public” folder for that app with the domain name configured to forward to that directory automatically.
- If you direct your browser to the domain name you used, you should get a welcome page.
- If you need a Database then you can install it through ServerPilot by selecting the app, selecting Database and then create database.
This process might take you a while to complete on your first shot at it, but once you understand how to create the droplets and add then to server pilot you’re well on your way to hosting freedom!
You can host multiple websites on a single VPS. It can be a pain in the …. to move over all your existing websites, but it is well worth it. Quickly and easily scale your websites, easy backups and access to functionality you just can’t get when you’re using shared hosting.
Whilst it might not seem like a big deal to host on shared hosting, you’ll soon find that it is too prohibitive if you’re developing or even hosting opensource software. One of the things to keep in mind is that this is a much more manual way of running your hosting and therefore you will at some point have an issue that is harder to fix than when you host with a professional company.
What else do you need to still learn how to configure?
- SSH into the VPS using Putty in order to configure the more advanced aspects.
- phpMyAdmin – Installing PhpMyAdmin so that you can easily manipulate your databases
- automysqlbackup – Automatic MySQL backups. More regular backups of your databases in case of a problem
- Cronjobs – It’s important to be able to run regular cron’s for some applications. (crontab -e)
- SSL – Installing free SSL certificates. These is a one-click option to do this from Server Pilot. But that is only for paid users. I will write a post soon explaining how you can do this without Server Pilot with an auto-renew cron using Let’s Encrypt.
- Firewall Manipulation – Sometimes you need to have access to certain ports remotely. In order to do that you’ll need to learn how to use ufw on the Ubuntu OS.
- Email – How and where are you going to host your email?