I Bought a VPS Now What? 8 Steps to Follow After Purchasing a VPS
After purchasing a virtual private server (VPS), you must complete several steps before deploying an application or a website.
These measures are crucial to ensure security and compatibility since VPS is self-managed. It commonly lacks pre-configured software, and the user must prepare the hosting environment manually based on their specific needs.
To help you get started, this tutorial will explain what to do after purchasing a VPS hosting plan, from getting to know your server to integrating a monitoring tool.
What to Do After Buying a VPS
In this section, we will explain seven necessary measures after purchasing VPS hosting and several Hostinger features that help simplify the task.
1. Understand Your VPS
Each VPS comes with a specific CPU core, RAM, and storage allocations. These determine how much load your virtual server can withstand and the amount of data it can save.
For the operating system, web hosting providers commonly provide two options – Linux and Windows. Hostinger’s VPS only supports Linux distros since they are free, more flexible, and perform better than Windows.
You install a control panel like CyberPanel to simplify VPS hosting management. It provides a graphical user interface (GUI) for accessing your server files and configurations without using Linux commands.
2. Set Up Your VPS
After understanding your server’s compatibility, let’s proceed with the software installation. At Hostinger, you can configure an operating system and control panel in one click using a VPS template. If you’re using another web hosting provider, you might need to use custom commands.
Once installed, access your VPS via secure shell (SSH) – a secure connection protocol for executing commands on your remote server. You can use PuTTY to access the Linux server or Remote Desktop for Windows.
By default, you will log in as root. Since this user has the most privileges, running commands and performing server management tasks using it can be somewhat risky if not careful.
With that in mind, let’s create another superuser in your Linux VPS hosting to run administrative commands. We will use AlmaLinux for this tutorial, but the steps should be the same for all distros like Ubuntu or CentOS:
adduser your-username
Enter the new account’s password and contact details. Then, switch from the root to the new user using the following command:
su your-username
With this account, you can only run administrative commands using the sudo prefix and after entering its password.
3. Point Your Domain
While you can access your VPS using its IP address, you need a domain name to make the hosted site or application accessible to users. You also need it to enable HTTPS and set up a custom mail server in later steps.
There are different ways to point a domain name to your VPS, but the easiest one is by changing the DNS record in your registrar’s settings.
To do so in Hostinger, open hPanel and navigate to Domains → Manage → DNS/Nameservers. Under the Manage DNS section, add two new A records pointing to your VPS IP address. Name them www and @, but keep other configuration values identical.
4. Secure Your VPS
To maintain your VPS security, regularly run the update command to install the latest version of all software. Here’s how to do so in AlmaLinux:
sudo dnf update && sudo apt upgrade
For other distros, replace dnf with their corresponding package manager, like apt for Debian and Ubuntu VPS. If you use Windows, follow the guide on updating your server software.
In addition, configure firewall rules on your VPS to block malicious traffic that can compromise its safety. You can do so using Linux’s iptables or Windows Firewall.
Another essential measure is setting up Fail2Ban to block malicious login attempts. Here is the installation command:
sudo dnf install fail2ban
Additionally, change the default SSH port since the default one is often exploited. You can do so by opening the SSH configuration file with this command and changing the corresponding setting.
sudo nano /etc/ssh/sshd_config
While not mandatory, we also recommend setting up SSH keys to secure your SSH connection properly. These are additional login credentials that help protect your server if the username and password are compromised.
Lastly, install a secure sockets layer (SSL) certificate to encrypt the connection between your server and clients. You can do so using Certbot via your command line interface or your hosting management panel’s feature.
For example, set it up in Cyberpanel by going to the main dashboard → SSL → Manage SSL. Select your VPS domain and click Issue SSL. Then, go to Websites → List Websites → Manage → Rewrite Rules and select force HTTPS.
5. Install a Web Server
Now, install the web stack to host your website or application. The first component is a web server, a software that takes clients’ requests and displays the queried content.
Some popular web servers are Apache, NGINX, and OpenLiteSpeed. Unless you need a specific one, we recommend OpenLiteSpeed due to its high performance and extensive compatibility.
To help you make an informed decision, check out our WordPress on KVM tutorial to learn more about their performance. Now, let’s start installing a web server.
At Hostinger, you can use our LAMP stack template to configure Apache or LEMP for NGINX. OpenLiteSpeed templates are also available, but they are pre-configured with other software.
Use commands if you want to install the web server separately. To learn more about the steps, check out the OpenLiteSpeed setup guide.
Important! If you use Hostinger’s VPS templates, you don’t need to configure a web server and other web stack components as they are pre-installed.
6. Add Email and Database Services
Another component of a web stack is a database, which stores and retrieves user information upon request. It enables your website to show dynamic content that automatically changes based on specific queries.
There are various database management systems (DBMS), like MySQL, MariaDB, and PostgreSQL. The setup process varies depending on the databases. For example, run the following commands to install MySQL on an AlmaLinux VPS:
sudo dnf install mysql-server
While optional, we also recommend setting up phpMyAdmin. Instead of using commands, this control panel provides a graphical interface to help simplify MySQL database administration.
To learn more about how to set it up, check out our installing phpMyAdmin on CentOS tutorial, which should also work for other RHEL-based distros like AlmaLinux. Once configured, you should be able to access the panel by visiting this link:
yourvpsdomain.tld/phpmyadmin
Log in as the root user you created during the MySQL installation process. To connect the database with your application, add the PHP mysql_connect function to your index.php file.
We also recommend setting up a private mailing service with your domain to improve deliverability. The easiest way to do so is by hosting a custom mail server on CyberPanel.
7. Deploy Your First Web Application
After the web stack is configured, let’s proceed with the web application deployment. The steps slightly differ depending on whether you build it using a framework or content management system (CMS).
Hostinger VPS supports popular CMSs like WordPress and frameworks like Laravel, which you can configure using templates or commands. Several management panels also provide an installer feature.
For example, install WordPress via CyberPanel by going to the Dashboard → Websites → List Websites → Manage. Scroll down to the Application Installer section and select WP + LSCache. Enter the site information and click Create Website.
Once installed, visit yourdomain.tld/wp-admin to access the WordPress admin dashboard and configure your web page. Navigate to the Plugin menu and install plugins like WordFence to optimize security and enable caching using LiteSpeed.
For frameworks, you must use Hostinger’s VPS template or commands to install it. Once configured, push the files to the server from a Git repository via SSH or using file transfer protocol (FTP).
8. Monitor and Maintain Your Server
Regularly monitor your server performance to ensure your website or application is responsive. You can use tools like Grafana or Prometheus, but setting them up can be complicated.
For basic resource tracking, use your management panel’s built-in monitoring feature. In hPanel, you can access it by going to VPS → Settings → Backup & Monitoring → Server Usage.
Also, regularly update your server software to maintain security. To simplify this recurrent task, set up a cron job script to schedule its execution.
Moreover, enable automatic VPS backup to ensure data safety using your web host’s feature or cron job. By default, your system will create the archive file locally.
We recommend using an additional off-site backup solution to protect your files from potential physical damage. A popular provider of such a service is Google Drive.
Need Help Managing Your VPS Hosting?
Use Hostinger’s VPS AI Assistant to help with server maintenance and troubleshooting. You can generate instructions and commands for your needs using simple prompts.
Conclusion
Since VPS hosting is a self-managed service, users must complete several steps to prepare their hosting environment. After understanding the server’s hardware and software compatibility, install an operating system like Linux or Windows.
Then, access your VPS via SSH to create a new superuser and set up security software, including a firewall and SSL. Install a web stack according to your application requirements and optional software like a hosting management panel.
Configure a CMS or framework and deploy your application to the server via FTP. Lastly, a monitoring tool like Prometheus should be set up, and a cronjob script should be created to automate regular tasks like backup and updating.
I Bought a VPS Now What? FAQ
In this section, we will answer several questions users often ask after purchasing a VPS hosting plan.
What to Do on a New VPS?
The most critical steps are installing an operating system, setting up a new root password, creating a superuser, and configuring security tools. Then, install the web stack, such as the web server and database, based on your hosting needs.
Can I Host Multiple Websites on a Single VPS?
Absolutely! To host multiple websites on a VPS, create a dedicated folder within your web server’s root directory for each domain. Then, upload index.php and other page files into the location.
How Do I Install a Web Server Like Apache or NGINX on My VPS?
At Hostinger, you can install the Apache, NGINX, or OpenLiteSpeed web server using the operating system template via hPanel. Alternatively, you can do so using the apt install command via SSH.
What Is the Best Way to Monitor the Performance of My VPS?
The best way to track your VPS performance is by integrating it with a monitoring tool like Prometheus and Grafana. Alternatively, you can use Hostinger’s VPS monitoring tool directly via hPanel, but the information is not as comprehensive.