Setting up a Virtual Private Server (VPS) can seem like a daunting task, especially for those who are not familiar with the command-line interface. However, with the right steps, it is possible to effectively manage and optimize a VPS. This article provides a clear guide on how to set up a VPS using the Hostinger platform, accompanied by best practices and helpful tips.
Understanding VPS Configuration
Shared hosting plans are typically fully managed by the provider, which limits the user's ability to modify the server configuration. In contrast, a VPS allows the user to have more control, granting the freedom to install the desired control panel and customize the server environment. In this case, the provider only handles aspects such as virtualization and the web server, while the specific configurations depend on the user.
Developers usually interact with their VPS via the SSH (Secure Shell) protocol, using tools like PuTTY to connect and manage their server remotely. For those with less experience, it is advisable to opt for a control panel with a graphical user interface (GUI).
Steps to Set Up a VPS in 6 Stages
The process of configuring a VPS with Hostinger can be broken down into six key steps, ensuring that your server is secure and optimized.
1. Choose and Purchase a VPS Hosting Plan
When selecting a VPS plan, it is essential to consider aspects such as technical support, performance, server resources, price, and security features. Hostinger, for example, offers VPS plans starting at €5.49 per month, with different hardware configurations and features such as snapshots and root access. Users can upgrade their plan at any time through hPanel and benefit from robust security features, as well as the AI assistant Kodee to simplify management.
2. Log in to the VPS Using SSH
Accessing the VPS requires knowing the server's IP address and the root login credentials, which can be found in the SSH Access section of hPanel. For those using macOS or Linux, access is configured through the Terminal; Windows users can use PuTTY by following these steps:
- Open PuTTY.
- Copy the IP address and SSH port from hPanel.
- Paste the information into the corresponding fields and click "Open."
- Enter the login credentials.
It is advisable to change the default SSH port after the initial connection for security purposes.
3. Update the VPS
Keeping the VPS software updated is crucial for ensuring security and performance. To perform an update on a CentOS-based system, the commands used are:
apt update apt upgrade
Depending on the Linux operating system, different package managers may be used. After the update, it is recommended to restart the VPS to effectively apply the changes.
4. Create a New User and Modify Privileges
For those managing their VPS, it is advisable to create additional user accounts with limited permissions. This not only helps prevent errors but also enhances security. To add a new user, the following command should be used:
adduser username
Then, superuser privileges can be granted by using:
usermod -aG sudo username
5. Enable Public Key Authentication
Public key authentication is a secure method that uses a key pair to enhance SSH connection security. The private key remains on the user's device, while the public key is stored on the server. To enable this, PuTTYgen can be used to generate a key pair, and then the steps to configure the public key on the VPS should be followed. These steps include creating a directory for the keys and adjusting their permissions.
6. Set Up a Firewall for the VPS
The security of the VPS must be a priority, and configuring a firewall is essential. A firewall allows filtering of traffic and protects the server from threats. Hostinger offers a built-in option to set up a firewall in hPanel. The process involves selecting "Create Firewall Configuration" and adding the desired rules to manage incoming and outgoing traffic.
Hosting a Website on the VPS
Once the VPS configuration is complete, you can start the process of hosting a website. Hostinger supports various control panels such as cPanel, Plesk, and CyberPanel. For beginners, it is recommended to use available templates to simplify the installation.
Installing CyberPanel
If CyberPanel is chosen as the control panel, it can be accessed through the unique address or IP of the server after installation. Access requires entering the root credentials.
Creating Websites and Managing Domains in CyberPanel
To add a domain, it is necessary to log in to CyberPanel and follow the steps to create a website, including setting up the package and PHP version. DNS management can be done through Hostinger to point the domain to the VPS.
Installing Applications and Managing Databases
CyberPanel allows for the installation of applications, including content management systems like WordPress. To install applications, select the relevant website and follow the installation process. It is also possible to create and manage databases from the control panel.
Managing the Website and Advanced Features
In addition to providing a simplified interface, CyberPanel offers management tools such as a file manager, the creation of FTP accounts, and the ability to manage SSH keys and firewall settings. Additionally, it allows developers to enjoy advanced features, such as Git integration.
Changing the VPS Hostname
It is advisable to change the VPS hostname to avoid conflicts in network environments. Hostinger allows the hostname to be easily changed through hPanel or via command-line commands, based on the user's preference.
With these steps, users can efficiently and securely set up their VPS with Hostinger, facilitating the management and development of applications and websites. For those interested in delving deeper into this topic, we invite you to continue reading on the blog.