call_end

    • Pl chevron_right

      Dorothy Kabarozi: Deploying a Simple HTML Project on Linode Using Nginx

      news.movim.eu / PlanetGnome • Yesterday - 16:14 • 2 minutes


    Deploying a Simple HTML Project on Linode Using Nginx: My Journey and Lessons Learned

    Deploying web projects can seem intimidating at first, especially when working with a remote server like Linode. Recently, I decided to deploy a simple HTML project ( index.html ) on a Linode server using Nginx. Here’s a detailed account of the steps I took, the challenges I faced, and the solutions I applied.


    Step 1: Accessing the Linode Server

    The first step was to connect to my Linode server via SSH:

    ssh root@<your-linode-ip>
    
    

    Initially, I encountered a timeout issue , which reminded me to check network settings and ensure SSH access was enabled for my Linode instance. Once connected, I had access to the server terminal and could manage files and services.


    Step 2: Preparing the Project

    My project was simple—it only contained an index.html file. I uploaded it to the server under:

    /var/www/hng13-stage0-devops
    
    

    I verified the project folder structure with:

    ls -l /var/www/hng13-stage0-devops
    
    

    Since there was no public folder or PHP files, I knew I needed to adjust the Nginx configuration to serve directly from this folder.


    Step 3: Setting Up Nginx

    I opened the Nginx configuration for my site:

    sudo nano /etc/nginx/sites-available/hng13
    
    

    Initially, I mistakenly pointed root to a non-existent folder ( public ), which caused a 404 Not Found error. The correct configuration looked like this:

    server {
        listen 80;
        server_name <your_linode-ip>;
    
        root /var/www/hng13-stage0-devops;  # points to folder containing index.html
        index index.html index.htm;
    
        location / {
            try_files $uri $uri/ =404;
        }
    }
    
    

    Step 4: Enabling the Site and Testing

    After creating the configuration file, I enabled the site:

    sudo ln -s /etc/nginx/sites-available/hng13 /etc/nginx/sites-enabled/
    
    

    I also removed the default site to avoid conflicts:

    sudo rm /etc/nginx/sites-enabled/default
    
    

    Then I tested the configuration:

    sudo nginx -t
    
    

    If the syntax was OK, I reloaded Nginx:

    sudo systemctl reload nginx
    
    

    Step 5: Checking Permissions

    Nginx must have access to the project files. I ensured the correct permissions:

    sudo chown -R www-data:www-data /var/www/hng13-stage0-devops
    sudo chmod -R 755 /var/www/hng13-stage0-devops
    
    

    Step 6: Viewing the Site

    Finally, I opened my browser and navigated to

    http://<your-linode-ip>
    
    

    And there it was—my index.html page served perfectly via Nginx. ✅


    Challenges and Lessons Learned

    1. Nginx server_name Error
      • Error: "server_name" directive is not allowed here
      • Lesson: Always place server_name inside a server { ... } block.
    2. 404 Not Found
      • Cause: Nginx was pointing to a public folder that didn’t exist.
      • Solution: Update root to the folder containing index.html .
    3. Permissions Issues
      • Nginx could not read files initially.
      • Solution: Ensure ownership by www-data and proper read/execute permissions.
    4. SSH Timeout / Connection Issues
      • Double-check firewall rules and Linode network settings.

    Key Takeaways

    • For static HTML projects, Nginx is simple and effective.
    • Always check the root folder matches your project structure.
    • Testing the Nginx config ( nginx -t ) before reload saves headaches.
    • Proper permissions are crucial for serving files correctly.

    Deploying my project was a learning experience. Even small mistakes like pointing to the wrong folder or placing directives in the wrong context can break the site—but step-by-step debugging and understanding the errors helped me fix everything quickly.This has kick started my devOps journey and I truly loved the challenge