If you plan to host websites or web applications on your server, you will need to install a web server. Apache and Nginx are the two most popular options.
Apache
Apache is the most widely used web server in the world. It is highly configurable, supports .htaccess files for per-directory settings, and works well with PHP out of the box. To install on Ubuntu/Debian: apt install apache2 -y. On AlmaLinux/Rocky: dnf install httpd -y. After installation, start the service and enable it to run on boot.
Nginx
Nginx is known for its high performance, low memory usage, and ability to handle large numbers of concurrent connections. It is an excellent choice for serving static content, acting as a reverse proxy, and load balancing. To install on Ubuntu/Debian: apt install nginx -y. Start and enable the service after installation.
Which Should You Choose?
For most general-purpose hosting, either will work well. Apache is a better choice if you rely on .htaccess files or need maximum compatibility with hosting tools. Nginx is better if you are serving high-traffic static content or using it as a reverse proxy in front of an application. Many administrators use both together - Nginx as a front-end proxy and Apache as the back-end application server.
After Installation
Open ports 80 (HTTP) and 443 (HTTPS) in your firewall. Place your website files in the default document root (typically /var/www/html for Apache and /usr/share/nginx/html or /var/www/html for Nginx). Set up virtual hosts (Apache) or server blocks (Nginx) to host multiple websites on the same server.
Tip: After installing your web server, install Certbot to get free Let’s Encrypt SSL certificates. Run: apt install certbot python3-certbot-nginx (or python3-certbot-apache) and then certbot --nginx (or --apache) to automatically configure HTTPS.