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
- 1SSH in as root or sudo user
- 2Run:
apt update
apt install nginx -y- 1Start and enable it:
systemctl start nginx
systemctl enable nginx- 1Open the firewall:
ufw allow 'Nginx Full'- 1Visit
http://YOUR_VPS_IP, you should see "Welcome to nginx"
Web server is live.
Install Apache (if you really need it)
- 1
apt install apache2 -y - 2
systemctl start apache2 && systemctl enable apache2 - 3
ufw allow 'Apache Full' - 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.htmlin there and refresh
Adding HTTPS
- 1Install Certbot:
apt install certbot python3-certbot-nginx -y- 1Point your domain's A record at the VPS IP
- 2Run:
certbot --nginx -d yourdomain.com- 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.
Getting Started with Your Endercloud VPS
First-login checklist for a fresh Linux VPS, secure it before you build.
How to Connect via SSH (Windows & Mac)
Open a terminal session to your VPS, with password or, better, an SSH key.
How to Set Up a Firewall (UFW)
Open only the ports you actually need with Ubuntu's UFW firewall.
Still need help?
Our team is on Discord around the clock. Real humans, real answers.