Ubuntu 14.04 and Virtualmin Part 1

Ubuntu 14.04 and Virtualmin Part 1

Web Stuff 03.09.2015 8405


Ubuntu 14.04 and Virtualmin Part 1

Today we will show you how to install virtualmin on a fresh Ubuntu 14.04 running on a vps with the new services like digitalocean or vultr.

Virtualmin is free and licensed under the GPL license, with Virtualmin you can run your own hosting environment and have control over your own settings, all of it.

But why should you do it? Well first you will have all the power for yourself. Means what you choose you will get with many managed hosting companies you will share your server with thousands of other customers usually not really secure and if someone hacks your neighbour WordPress your account is most of the time compromised as well. With virtualmin you can run at least 10 busy websites on a 1gb machine and you are the boss over all your virtual servers, emails, accounts, statistics plus your environment is safe against neighbours thanks to 100% KVM Virtualization.

The installation is fairly easy, however a few steps are necessary before we dig into the ssh console.

First you will need a domain name, you can get a domain with alot of resellers, I prefer namecheap because it is priced fair and easy to setup nameservers.

Let's start with signing up (if not already). Choose a provider you like, doesn't matter which one and both usually give you up to 25 USD bonus when you start with them. Both providers (there are many more) provide different locations and packages, choose the one close to you and your website visitors, means it doesn't make sense to choose a server in Sydney when you live in Madrid, always choose the closest one.

After register go to your account settings and add your ssh key from your local machine. SSH Keys are only available for Linux servers, but we won't use any Windows server for now. Let's create a SSH Key on your local machine.

  1. For Linux user, yes Mac as well open your terminal please.
  2. Type ssh-keygen -t rsa or for a more secure key use ssh-keygen -t rsa -b 4096 and hit enter.
  3. Choose default location and enter a passphrase for your key
  4. Now type cat ~/.ssh/id_rsa.pub and copy the key to your clipboard.
  5. Make sure you have a backup from your ssh key because it cannot be recovered that would mean you cannot login to your server if your local machine goes down. Key will be stored in ~/.ssh/id_rsa
  6. For Windows user the easiest way to generate a SSH Key is puttygen.

Now we have a SSH Key for your local machine but what can I do with it and what does it mean? The SSH key is identification for your local machine, means a very strong password but you don't have to enter and remember the key. When you connect to your server your local machine will send your very strong password (ssh key) to authorize the access, only your local machine will have access to your future server, makes it very secure for the ssh end.

Go to your digitalocean or vultr account, go to settings and find the SSH Keys section. Press add SSH Key enter a name (my mac) and paste the code from your clipboard into the textarea, save.

We are now ready to create a vps, quick hey!

  1. Choose a name
  2. Select a size (start with 1GB)
  3. Choose a location (near you)
  4. Choose Ubuntu 14.04 64bit
  5. Enable IPv6
  6. Enable Private Network
  7. Choose your SSH Key created above
  8. Create VPS 

Now this will take a couple of minutes you will receive an email when your server is ready! Congratulations you just created your first virtual server, already pretty secure because only your local machine can connect to this vps via SSH!

After your server is up and running, open your terminal and type:

ssh root@server_ip_address

You will be asked to trust this this server, type yes. You are now connected to your new server, how easy was that? Now we should run a few tasks to set utf-8 to standard, update your vps and set the hostname. In your terminal run each line below, do not copy all of it, just one by one.

hostnamectl set-hostname srv1.yourdomain.com
sudo locale-gen UTF-8
apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get autoremove
reboot

Because we have rebooted the server you will be disconnected from the server. Connect again and now we are ready to install virtualmin, again run only one line at the time.

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
./install.sh

Follow the onscreen instructions, it will take about 5 minutes to install webmin and virtualmin on your server. When it is finished you can login via browser to your new webserver running on Ubuntu 14.04.

Open your preferred browser and go to:

https://your_server_IP:10000

Login with your root account, the password can be found in the email that has been sent to you after the server has been created or in your server dashboard on vultr.

In part 2 we will go through the virtualmin and webmin configuration secure your server and webmin even further and setup your first domain.