Special Offer: Save Upto 10% on Game Servers & Bot Hosting
VPS Hosting3 min read

How to Install a Web Server (Nginx / Apache)

Stand up Nginx or Apache on your VPS in five minutes.


Introduction

A web server takes HTTP requests and returns pages. Nginx is faster and easier to configure. Apache is older and supports .htaccess files.

For new projects, install Nginx.

Install Nginx

  1. 1SSH in as root or sudo user
  2. 2Run:
   apt update
   apt install nginx -y
  1. 1Start and enable it:
   systemctl start nginx
   systemctl enable nginx
  1. 1Open the firewall:
   ufw allow 'Nginx Full'
  1. 1Visit http://YOUR_VPS_IP, you should see "Welcome to nginx"

Web server is live.

Install Apache (if you really need it)

  1. 1apt install apache2 -y
  2. 2systemctl start apache2 && systemctl enable apache2
  3. 3ufw allow 'Apache Full'
  4. 4Visit http://YOUR_VPS_IP, Apache's welcome page loads

Serving Your Own Files

  • Nginx default folder: /var/www/html
  • Apache default folder: /var/www/html
  • Drop your index.html in there and refresh

Adding HTTPS

  1. 1Install Certbot:
   apt install certbot python3-certbot-nginx -y
  1. 1Point your domain's A record at the VPS IP
  2. 2Run:
   certbot --nginx -d yourdomain.com
  1. 1Pick "Redirect" when asked

Tip: Certbot auto-renews. Run certbot renew --dry-run to confirm.

Warning: Never run both Nginx and Apache on port 80. Pick one or have Nginx proxy to Apache on a different port.

Need More Help?

Configuration confusing? Paste your config file in Discord, we'll lint it.

Was this helpful?

Your feedback helps us write better guides.

Related Articles

More from VPS Hosting.

Still need help?

Our team is on Discord around the clock. Real humans, real answers.