6 Easy Steps to Configure Your First VPS Server
Often, when a website outgrows its shared hosting plan, the biggest issue is not the cost associated with an upgrade to a more powerful VPS. Instead, it’s the site owner’s anxiety at the prospect of running an entire server.
But are these fears justified? Is owning and configuring a virtual server really as daunting as it sounds?
Table of Contents:
- What is VPS Hosting?
- When Should You Consider Self-Managed VPS Hosting?
- How Can Your VPS Hosting Provider Help?
- Setting Up Your VPS
- Possible VPS Setup Problems
- ScalaHosting Managed VPS Benefits
What is VPS Hosting?
VPS hosting lets you accommodate web projects on your very own virtual machine. You get better performance thanks to the guaranteed hardware resources and a dedicated IP only you can use.
A managed virtual server comes with a preconfigured setup. Your hosting provider takes care of installing the operating system and every other piece of software required for hosting your website. Usually, you get access to a management platform to control the projects hosted on the server, monitor the server’s health, and stop individual processes.
You usually don’t get root access with a managed VPS because, frankly, you don’t need it. Your hosting provider is responsible for updating and configuring the underlying software while you can focus on running your website. This is by far the more user-friendly option, but it’s not what all admins look for.
Some site owners want to have complete control over the VPS. They want to install and configure specific software, so they need full access to the server’s internals. For them, a self-managed VPS with root access is the best solution.
When Should You Consider Self-Managed VPS Hosting?
Although it’s a relatively new market, the hosting industry has evolved quite a bit. Providers and developers are constantly innovating and using new technologies to make users’ lives easier. There are now GUI-based control panels and management systems, and their range of options and tools is broad enough to cover almost every site owner’s needs.
Usually, these tools come with managed VPS solutions.
Self-managed virtual servers are for projects with specific requirements and are usually preferred by people with more advanced technical skills.
With a self-managed VPS, you are solely responsible for configuring the software required for hosting your website and ensuring the server’s smooth performance. Essentially, you are getting a bare-metal server machine – a blank canvas where you can tweak every little detail of your project.
How Can Your VPS Hosting Provider Help?
It’s up to the host to deploy your virtual machine and install an operating system (usually Linux, though some hosting providers also offer Windows VPS options). Your provider will likely set up Apache or Nginx, as well, before sending you the login instructions and leaving you to it.
From then on, you’re pretty much on your own. Your host’s support team might just be willing to point you to the right resources if you have any specific questions, but you’re going to have to do the legwork yourself.
Let’s see what this involves.
Setting Up Your VPS
The exact steps on setting up your VPS depend primarily on your operating system.
In this guide, we’ll assume it’s running Linux – the dominant OS for web hosting servers. Most site owners prefer it not only because its open-source nature makes it more cost-effective but also because of its versatility.
Now, the first step is to access the server from your personal computer.
Access the server via SSH
Multiple communication protocols let you establish a connection to your VPS. With FTP, for example, you can upload, manage, and edit files. However, to properly configure your VPS, you need SSH (or Secure Shell) – a network protocol that lets you establish an encrypted connection to the server and execute commands on it.
SSH works solely through a command-line interface, and if your computer uses a Unix-based OS like Linux or macOS, you can use the Terminal to establish a connection.
In 2018, Microsoft integrated SSH into Windows PowerShell as well, and if you’re using an older version of Windows – you’ll need to use an SSH client like PuTTY.
Accessing the server via SSH for the first time requires the root login credentials provided by your host. The command you need to use is:
ssh [root username]@[server IP]
The server will receive the request via port 22, identify the username (usually, it’s “root”), and ask for your password. After you provide the correct login details, the server will display a welcome message in the command-line interface.
With that, you have logged into your self-managed VPS for the first time.
Update the server
Remember, you’re responsible not only for the server’s smooth performance but also for the security of the projects hosted on it. Keeping your VPS up-to-date is a major part of this, as it guarantees that all new security patches and features are installed.
Different Linux distributions use different package managers, so the commands vary from distro to distro.
For Ubuntu and other Debian-based distributions, for example, you’ll first use:
For CentOS and RHEL, the command will be:
yum check-update or dnf check-update
The server will go through the operating system’s software packages and single out the ones that need updating. Next, you need to tell it to proceed with the updates.
For Debian-based distributions, the command is:
For CentOS and RHEL, you need to use:
yum update or dnf update
The process may take a while. After the update, it’s a good idea to restart the server using the reboot command.
Regularly updating the server’s software is an essential part of keeping it in good condition. By not applying the latest stable versions, you not only miss out on newly added features and functionalities but leave the server open to security vulnerabilities.
Create a new user
So far, you’ve been working with the server’s root user.
The root user in Linux is basically the system’s owner. Its privileges are unlimited – as long as you’re logged in as root, you can do pretty much anything with the server.
Still, any small mistake could have dire consequences because of the elevated privileges, so it’s generally considered a good idea to create a second account with superuser permissions. With it, you can still configure your server’s most important settings, but you’ll need to add the sudo prefix to every command that requires administrative privileges.
It may seem like a minor difference, but the error messages when you try to execute commands without the required prefix are guaranteed to make you proceed with caution. To create a new user, use:
adduser [the new user’s username]
The server will ask you to pick a password for the new account and provide a few additional details. Next, you need to assign the new user account to the correct group. Here’s the command
usermod -aG sudo [the new user’s username]
To ensure everything works as it should, you can terminate the current SSH session and log in with the new user account.
Change the default SSH port
As mentioned, Port 22 is SSH’s default listening port. That’s a known fact by many SSH users, but pesky hackers as well. Strictly speaking, if your password is strong enough – they’ll have a tough time getting in.
Nevertheless, it’s best not to take any chances and change the SSH default listening port.
Doing this means editing the SSH configuration file. To save yourself a ton of trouble in case something goes wrong, it’s a good idea to back it up before you continue.
Use the following command:
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_old
Most Linux distributions ship with Nano – a command line-based text editor. You’ll use it to edit the SSH configuration file:
Locate the line that says:
Remove the # character, and replace 22 with any number between 1024 and 65535. Make sure you memorize the new port, as you’ll need to use it the next time you log in. Other services can’t utilize the SSH port you’ve just assigned.
To apply the changes, save the SSH configuration file and restart the SSH service with the following command:
systemctl restart ssh
If you’re not logged in with the root account, you’ll need to use the sudo prefix with some of these commands.
Generate SSH keys
Changing SSH’s default listening port protects your servers against automated scripts that scan the internet and try to hack servers on a random basis. To block targeted attacks, however, it’s best to beef up your authentication mechanism.
The traditional user/pass system is often efficient if you choose a strong enough password. Still, SSH can also use a public-and-private key pair to authenticate individual users – an even more secure setup.
To use it, you first need to generate the SSH keys. In Windows, you can easily do this through the PuTTYgen application bundled with the popular SSH client. Open the app and click Generate. PuTTYgen will generate a public and a private key.
The public key is visible in the box at the top. Before you proceed, you also need to set a passphrase that will act as a password, working alongside the key pair.
Click Save Private Key to save the key on your computer. Now for the public one.
Log back into the server as root and open your account’s home directory with the following command:
su – [your username]
First, you need to create a folder that will host your public key and set the permissions allowing you to create the file in it.
The commands are:
chmod 700 ~/.ssh
Next, you need to create a file where you’ll paste the public key generated by PuTTYgen. Once again, we’ll use the Nano text editor:
To use the key pair and connect to your account using PuTTY, open the SSH client settings and go to Connection > SSH > Auth. Use the Private Key File for Authentication field to select your private key and save the changes.
The only thing that’s left is to disable your account’s password authentication.
To do that, you need to edit the SSH configuration file – etc/ssh/sshd_config. It’s as simple as changing the PasswordAuthentication value from Yes to No.
Set up a firewall
A firewall is one of the most important security mechanisms for web hosting servers. Its job is to filter incoming and outgoing traffic and ensure the data is available only to those authorized to access it.
Most Linux distributions use a firewall called iptables to filter traffic to and from the server. In most cases, it’s installed by default. With different distributions, however, you can use various utilities to configure the firewall rules.
For example, Ubuntu’s default firewall configuration tool is called UFW, and CentOS’s equivalent is Firewalld. The purpose of all these tools is to simplify the task of configuring iptables.
They work in different ways, and the syntax they use is not the same. To figure out how they work, you’ll need to go through your OS documentation.
ScalaHosting Managed VPS Benefits
Setting up your virtual server manually wouldn’t be a concern if you choose one of our managed VPS plans. With them, you’ll get a VPS that is already pre-configured and ready to use. The operating system, the firewall, and all the other tools and utilities you’ll ever need to manage your projects – taken care of from the expert ScalaHosting Team.
Our support agents are available 24/7 to answer your questions and resolve any issues. a
As for your server operation – you get a choice of two management platforms to control the hosting account – cPanel and SPanel.
With them, you can start building your website straight away without worrying about server setup and maintenance. Any of the two will give you everything needed to manage your files, databases, email accounts, and subdomains in an intuitive GUI.
Configuring a self-managed VPS is not a set-and-forget task.
It’s up to you to ensure the machine performs at its best at all times, but the internet is awash with helpful resources telling you what you need to do and guide you in the right direction. Provided you invest enough time and effort – you can master the VPS operation without breaking a sweat.
If managing a virtual server is not your cup of tea – simply leave it to the professional and opt for a first-class managed VPS solution.
How does a VPS work?
A VPS is a virtual machine set up and running on a physical server. With guaranteed hardware resources and a dedicated IP, it acts as a completely separate server instance, so configuring it involves the same steps as setting up a regular server – choosing an operating system, installing essential software, security monitoring, etc.
How do I connect to a VPS?
You can connect to your VPS through various protocols, but the one you’ll use to execute commands is called SSH. It provides an encrypted connection through which you can communicate with the server’s operating system and perform a wide variety of different tasks.
What is a VPS used for?
A VPS gives you all the advantages of a dedicated server at a much lower price. If you go for a self-managed VPS, you get root access and are free to install any software for your online project, regardless of its scope. А virtual machine can easily turn into a gaming server, a mail server, an app server, or whatever you may need.
ScalaHosting – 6 Easy Steps to Configure Your First VPS Server