How to install Nginx and host your first site
Updated 7/20/2026
Nginx is the most widely used web server for fast, modern sites. Here is how to install it and publish your first site.
1. Install
apt-get update -y
apt-get install -y nginx
systemctl enable --now nginx
Open the server IP in a browser: you should see the default Nginx page.
2. Add your site files
mkdir -p /var/www/mysite
echo "It works!" > /var/www/mysite/index.html
3. Configure a server block
Create /etc/nginx/sites-available/mysite:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/mysite;
index index.html;
}
ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
Next steps
- Point your domain: see How to point a domain to your VPS.
- Add free HTTPS: see Free SSL certificate with Let's Encrypt.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Web servers
How to install phpMyAdmin to manage MySQL from the browser
Manage your MySQL databases from a web interface with phpMyAdmin, installed and secured correctly.
Updated 7/20/2026Web serversHow to optimize Nginx performance: gzip, cache and HTTP/2
Make your site faster with gzip compression, static file caching and HTTP/2, a few lines of config.
Updated 7/20/2026Web serversHow to host a static site or a React/Vue app
Publish a static site or a React/Vue build on Nginx, with correct routing for single-page apps.
Updated 7/20/2026