How to Set Up a VPS Server: Step-by-Step Beginner's Guide

If you've just bought or are about to buy a VPS, the first thing that comes to mind is: how do I configure and set up a VPS server? It sounds complicated and a little techy to a newcomer, and perhaps you're used to shared hosting, but setting up a VPS is a different deal.
To set up a VPS server, you start by connecting to it via SSH using the IP address and root password provided by your hosting provider. From there, you update the operating system, create a non-root user with sudo privileges, and secure access with SSH key authentication and a firewall. Once the server is hardened, you install a web server like Nginx, set up a DNS A record to point your domain to it, and enable a free SSL certificate.
However, with the right guidance, setting up a VPS is not nearly as difficult as it appears. In this guide, we will walk through the process in a simple, step-by-step manner. When you acquire a KVM VPS, you receive a blank server that you must configure yourself.
This involves logging in, configuring security settings, and publishing your website. Initially, this sequence of steps might seem extensive, but each step serves a distinct and clear purpose. We will explain everything in simple language to ensure you can proceed with confidence.
Key Takeaways from the Article
-
Setting up a VPS server is a step-by-step process that becomes easy when you follow the correct sequence.
-
Securing your VPS (non-root user, SSH keys, firewall) is just as important as setting it up.
-
A properly configured VPS gives you full control, better performance, and flexibility compared to shared hosting.
-
Once your VPS is ready, you can use it for websites, applications, email servers, or even AI projects.
What You Get When You Order a VPS?
With a KVM VPS purchase from HostSailor, you are provided with a ready-to-use server. But the server itself comes up blank. There will be no websites or software installed. You are provided with a public IP address and a login username and password, as well as an operating system (such as Ubuntu or Debian).
This server has an internet connection, allowing access from all locations. In addition to access from any location, you have complete control over your VPS, which sets it apart from shared hosting. You alone control the software that you install and how it is configured and maintained.
A VPS offers dedicated resources like memory, CPU, and space. This leads to consistent performance. That’s because setting up a VPS isn't the easiest of jobs, but the performance gained is that much higher.
Prerequisites for Setting Up a VPS Server
It is important to have a few basic things ready before you start to set up your VPS.
|
Requirement |
Details |
|
A VPS with root access |
A KVM VPS running Ubuntu 22.04 or Debian 12. HostSailor’s KVM VPS NVMe plans include full root access and your choice of OS. |
|
An SSH client |
Terminal (built into macOS and Linux) or PuTTY (free download for Windows). This is how you will connect to your server. |
|
Your server’s IP address |
Provided in your welcome email from HostSailor after purchase. |
|
A domain name (optional) |
Not required for the initial setup, but you will need one if you plan to host a website or set up SSL. |
|
A text editor on your local machine |
Notepad, VS Code, or any text editor — useful for editing configuration files or saving SSH keys. |
Step-by-Step Process to Set Up a VPS
Step 1: Connect to Your VPS via SSH
The first step of the VPS configuration that you will be performing is logging into your server, and to be able to do this, you are going to use SSH or Secure Shell. SSH enables you to log in remotely to another computer somewhere in the world; basically, it is like having a secure connection to your server, where every single thing you write is being encrypted.
</> Bash
ssh root@your_server_ip
Your terminal will require you to confirm that you wish to continue the very first time you connect. Type in yes and then press enter when requested. You will need to type in the root password.
You will notice that the cursor will not appear on the screen when typing this, and that's fine. When you see "root@hostname" at the bottom of the terminal, you will know that you are connected and may proceed.
Step 2: Update Your Server Packages
Now that you have entered the server, the next important thing is to update the system package. The OS in the VPS can not be the latest one, so update the system packages. The server will be secure and stable.
</> Bash
sudo apt update
sudo apt upgrade -y
If the kernel is upgraded during an update, it is advisable to reboot.
</> Bash
sudo reboot
Reconnect via SSH after the reboot. Following this step, your server will be updated and ready for further configuration.
Step 3: Create a Non-Root User with Sudo Privileges
Now that you have a server updated, we will be considering security. For now, you have been running as Root; this is a position of great power but also very risky. It's better to make a new user with sudo access, who will only run as an administrator when required.
</> Bash
adduser yourusername
usermod -aG sudo yourusername
Now switch to this new user:
</> Bash
su - yourusername
This makes your server more secure against accidental mistakes and unauthorized access.
Step 4: Set Up SSH Key Authentication
You now have a user created that is safe. The way the user logs in also needs to be secure. Replacing password authentication with SSH key authentication would be an even better idea. The concept of an SSH key relies on a private key being kept on the user's machine and a public key on the server.
</> Bash
ssh-keygen -t ed25519
ssh-copy-id yourusername@your_server_ip
Once this has been done, you will then be able to log in without a password. This is very effective when stopping brute-force attacks and increasing the security of your VPS.
Step 5: Disable Root SSH Login
Now that you have your new user and your SSH keys created, you can proceed by disabling root login. This means that there are no attacker routes through the root account, which is very commonly used.
</> Bash
sudo nano /etc/ssh/sshd_config
Change this line:
</> Bash
PermitRootLogin no
Then restart SSH:
</> Bash
sudo systemctl restart ssh
After this step, your server access becomes significantly more secure.
Step 6: Set Up a Basic Firewall with UFW
By now, you have strengthened your login security; however, protection at the network level is also essential. A firewall blocks unwanted traffic and keeps only the necessary ports open. UFW (Uncomplicated Firewall) is a simple tool used in Ubuntu.
</> Bash
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
To check the status:
</> Bash
sudo ufw status
This step helps protect your VPS from external threats.
|
Action |
Command |
|
Allow SSH |
sudo ufw allow 22/tcp |
|
Allow HTTP |
sudo ufw allow 80/tcp |
|
Allow HTTPS |
sudo ufw allow 443/tcp |
|
Enable firewall |
sudo ufw enable |
|
Check status |
sudo ufw status verbose |
|
Disable firewall |
sudo ufw disable |
|
Delete a rule |
sudo ufw delete allow 80/tcp |
Step 7: Install Fail2Ban for Brute-Force Protection
After setting up a firewall, it is essential to take security one step further. Fail2Ban is a tool that detects repeated failed login attempts and blocks the attacker's IP address.
</> Bash
sudo apt install fail2ban -y
Check the status:
</> Bash
sudo systemctl status fail2ban
This provides a strong additional layer to protect your server against automated attacks.
Step 8: Install a Web Server (Nginx)
With your server hardened against attack, you're now actually ready to put it to use. The only thing standing between the server and being put to work is installing a web server (like Nginx) that actually shows your website to the outside world.
</> Bash
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Verify this by entering your IP address into a browser:
http://your_server_ip
If the default page appears, your web server is functioning correctly.
Step 9: Point Your Domain to the VPS
Once the web server is up and running, the next step is to connect your domain to the VPS. To do this, you need to access your domain's DNS settings and add an A record.
Type: A
Host: @
Value: Your VPS IP
It may take some time for the DNS changes to propagate, but once they do, your website will become accessible via your domain.
Step 10: Secure Your Site with a Free SSL Certificate
Finally, it is essential to secure your website using an SSL certificate. This transitions your site from HTTP to HTTPS, ensuring that user data remains encrypted.
</> Bash
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx
Once the SSL setup is complete, your website becomes fully secure and goes live. Your VPS is now ready—you can confidently use it for any project.
VPS Setup Checklist
Thus far, you have provisioned the entire VPS, but it is advised that you re-examine it to make sure you didn't omit anything significant. The table below should give you a great indication of whether you have covered all aspects necessary for your server:
|
Step |
Checklist Item |
Status (✔/✖) |
|
1 |
SSH login is working (server is accessible) |
☐ |
|
2 |
Server packages are updated |
☐ |
|
3 |
Non-root user is created |
☐ |
|
4 |
Sudo privileges are assigned |
☐ |
|
5 |
SSH key authentication is enabled |
☐ |
|
6 |
Root SSH login is disabled |
☐ |
|
7 |
Firewall (UFW) is enabled |
☐ |
|
8 |
Required ports (22, 80, 443) are open |
☐ |
|
9 |
Fail2Ban is installed and running |
☐ |
|
10 |
Web server (Nginx) is installed |
☐ |
|
11 |
Domain is connected to VPS (optional) |
☐ |
|
12 |
SSL certificate (HTTPS) is enabled |
☐ |
What to Do Next with Your VPS?
Host a Website or App
The most popular application will be the hosting of your website or web application on a VPS. You have successfully installed Nginx on your server, and it is ready to host a website that you have built using WordPress, PHP, Node.js, or any framework.
Hosting a website on a VPS provides a higher level of control and higher performance than shared hosting. The performance advantage of VPS hosting is evident when it comes to the sharing of resources between users, unlike shared hosting. A faster and more responsive website can be served when it is hosted on a VPS.
Run Your Own Email Server
Another benefit is that you can create and manage your own email server on your VPS; you'll get to have custom email addresses such as "[email protected]," which would reinforce your branding. You wouldn't be dependent on other third-party email providers.
Although setting up an email server can be somewhat advanced, once properly configured, it proves to be extremely useful. A VPS grants you complete control, enabling you to manage emails securely and implement spam protection measures.
Run AI Models Locally
If you’re interested in AI or machine learning, running AI models on your VPS is an excellent idea. You can run your own AI tools, chatbots, or LLM models locally on your VPS. You won’t need to rely on external APIs.
This is especially good for developers and researchers who need to test their projects privately. The beauty of VPS is its flexibility and customization. You can tailor your setup to your needs.
Install a Control Panel
If you find it a little difficult managing your server by command line, then perhaps you might be interested in getting a control panel for your server. This should give you a graphical interface allowing you to have easy management over your server.
With a control panel, you will be able to manage the files of your server and also add domains and install applications, using the benefit of knowing not too many commands. This comes in handy, especially for a beginner learning how to manage a VPS server who prefers a simple interface to work with.
The Bottom Line
Setting up a VPS might seem a bit technical at first, but if you follow the correct steps one by one, the process becomes quite straightforward. In this guide, you have learned how to take a blank server from the initial connection stage. Once your VPS is properly set up, it grants you complete freedom.
It can also be customized to meet your specific requirements, enhance performance, and accommodate multiple diverse projects. You are either a starter or a growing business that requires a VPS because it offers you flexibility and control that is usually not achievable when using a shared hosting service.
For a dependable and highly performing VPS service, you should consider using HostSailor’s KVM VPS NVMe plans. KVM virtualization ensures that you have dedicated resources that guarantee you top performance for your site or application.
Frequently Asked Questions About VPS Hosting Setup
How do I connect to my VPS for the first time?
The method to get in touch with the VPS is through the SSH command (ssh root@yourserverip), and after typing your IP address and the password, you can use your server from the command line immediately.
What is SSH, and how does it work?
SSH is the security protocol that makes an encrypted connection between you and your VPS to make the safe transfer of files. This is the very same connection by which you will give orders to the remote server and control it.
What is the first thing to do after getting a VPS?
Once you receive a VPS, the very first step is to log in to the server and update it so that all the latest security patches are installed. Subsequently, the security setup and other configurations are gradually initiated.
How do I secure a VPS server?
For VPS security, disable root login, enable SSH keys, and have a firewall running. Tools like Fail2Ban can also assist in your server security.
Do I need technical knowledge to use a VPS?
It might seem a bit technical at first, but with a basic understanding, a VPS can be managed quite easily. If you follow the step-by-step guides, everything will gradually become clear.
What do I need to set up a VPS server?
You need a VPS with root access, an SSH client (Terminal on Mac/Linux or PuTTY on Windows), your server's IP address, and the root password provided by your hosting provider. A stable internet connection is also essential since you will be working on a remote server.