How to install a web server on your Linux VPS
Instructions for installing the web servers Apache2 and Nginx on a Linux VPS.
Apache2 and Nginx in comparison
Apache2:
- Classic web server, very widely used
- Supports
.htaccessfiles - Simple configuration, ideal for beginners and WordPress hosting
- Works process-based, which can lead to performance losses under high load
Nginx:
- Modern, resource-saving web server
- Works event-based → very performant under high load
- No
.htaccesssupport - Often used as a reverse proxy in front of Apache or other services
Apache2
Update system
First update the system of your server. Open the console and enter the following command:bashapt update && apt upgrade -yapt update && apt upgrade -yInstall Apache2
Install Apache2 by entering the following command in the console:bashsudo apt install apache2sudo apt install apache2Default web directory
After installation, you can upload your website files there:/var/www/html/var/www/htmlTest website
Open a web browser and navigate to:http://<server-ip>Important commands
Use the following commands to manage Apache2:bashsudo systemctl status apache2 # Displays the status of Apache2 sudo systemctl restart apache2 # Restarts Apache2 sudo systemctl enable apache2 # Enables Apache2 at system startupsudo systemctl status apache2 # Displays the status of Apache2 sudo systemctl restart apache2 # Restarts Apache2 sudo systemctl enable apache2 # Enables Apache2 at system startup
Nginx
Update system
First update the system of your server. Open the console and enter the following command:bashapt update && apt upgrade -yapt update && apt upgrade -yInstall Nginx
Install Nginx by entering the following command in the console:bashsudo apt install nginxsudo apt install nginxDefault web directory
After installation, you can upload your website files there:/var/www/html/var/www/htmlTest website
Open a web browser and navigate to:http://<server-ip>Important commands
Use the following commands to manage Nginx:bashsudo systemctl status nginx # Displays the status of Nginx sudo systemctl restart nginx # Restarts Nginx sudo systemctl enable nginx # Activates Nginx at system startupsudo systemctl status nginx # Displays the status of Nginx sudo systemctl restart nginx # Restarts Nginx sudo systemctl enable nginx # Activates Nginx at system startup
INFO
Here you can find instructions on how to install an SSL certificate: Instructions