Quick Nginx Setup Guide

Buy Me a Beer

A comprehensive guide to quickly set up Nginx on Ubuntu for your website. Follow these steps carefully.

1 System Update & Installation

sudo apt update
sudo apt install nginx

After installation, verify Nginx is running by accessing your server IP in a web browser.

2 Configuring Server Blocks

Replace example.com with your actual domain name.

Create Website Directory

sudo mkdir -p /var/www/example.com/html

Set Proper Ownership

sudo chown -R $USER:$USER /var/www/example.com/html

Set Correct Permissions

sudo chmod -R 755 /var/www/example.com

3 Creating a Sample Page

Create a simple HTML page to test your setup:

sudo nano /var/www/example.com/html/index.html
<html>
  <head>
    <title>Welcome to example.com</title>
  </head>
  <body>
    <h1>Hi Welcome to Example.com</h1>
  </body>
</html>

4 Nginx Configuration

sudo nano /etc/nginx/sites-available/example.com
server {
  listen 80;
  listen [::]:80;
  
  root /var/www/example.com/html;
  index index.html index.htm index.nginx-debian.html;
  
  server_name example.com www.example.com;
  
  location / {
    try_files $uri $uri/ =404;
  }
}

5 Final Steps

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Video Tutorial Guide

Watch this step-by-step video guide for visual instructions.

Need help? Contact support

© 2023 tomskbs.info - All rights reserved