India English
Kenya English
United Kingdom English
South Africa English
Nigeria English
United States English
United States Español
Indonesia English
Bangladesh English
Egypt العربية
Tanzania English
Ethiopia English
Uganda English
Congo - Kinshasa English
Ghana English
Côte d’Ivoire English
Zambia English
Cameroon English
Rwanda English
Germany Deutsch
France Français
Spain Català
Spain Español
Italy Italiano
Russia Русский
Japan English
Brazil Português
Brazil Português
Mexico Español
Philippines English
Pakistan English
Türkiye Türkçe
Vietnam English
Thailand English
South Korea English
Australia English
China 中文
Canada English
Canada Français
Somalia English
Netherlands Nederlands

Ubuntu Web Hosting: How to Host a Website on Ubuntu Server

Build Something Beautiful

With a .pk Domain

Just Rs 1,999

Ubuntu web hosting means running your own web server on Ubuntu to serve your website to visitors.

You install the software, configure it, point your domain to it, and manage everything yourself. It’s not as hard as it sounds, and you get full control over your environment.

Ubuntu Server is free and works on almost any hardware or cloud platform. It has a massive community, which means when something breaks, someone has already solved it.

In addition, the package manager makes installing software straightforward, and the long-term support releases give you security updates for years without forcing major upgrades.

This guide walks through the whole process of getting a live website with HTTPS.

Prerequisites

  • VPS with Ubuntu Server installed: Any recent LTS version works. The specs you need depend on what you’re hosting, but 1 GB RAM is enough for a static site.
  • Public IP address: Your server needs a public IP so visitors and you can reach it. Most VPS providers assign one automatically.
  • Internet connection: You’ll manage the server remotely over SSH, so you need a stable connection.
  • Registered domain name with DNS access: You need a domain and the ability to edit its DNS records so visitors can find your server.
  • SSH client and sudo access: You need an SSH client on your local machine and a user account on the server with sudo privileges.
  • Basic command line skills: You should be comfortable navigating directories, editing files, and running commands with sudo.
  • Database credentials: If your website uses a database, you’ll need the database name, username, and password.

8 Steps to Host a Website on Ubuntu Server

Step 1: Update the Server

SSH into your Ubuntu server. The first thing you do on any fresh server is update the package lists and upgrade installed packages:

text
sudo apt update && sudo apt upgrade -y

This ensures everything is up to date before you install anything new. Skipping this step can cause dependency conflicts later.

Step 2: Install a Web Server

Ubuntu Web Hosting- nginx

Nginx is a solid choice for most websites. It’s efficient, handles concurrent connections well, and uses fewer resources than Apache for static files. Install it with:

text
sudo apt install nginx -y

Once installed, Nginx starts automatically. Open a browser and go to your server’s IP address. You should see the default Nginx welcome page.

If you do, the web server is running and serving content on port 80.

If you plan to use Apache instead, the installation command is sudo apt install apache2 -y, but the configuration paths and syntax differ. This guide uses Nginx.

Step 3: Open the Firewall

Ubuntu ships with UFW (Uncomplicated Firewall). If it’s enabled, you need to allow web traffic. Nginx registers a few profiles with UFW.

To allow HTTP and HTTPS:

text
sudo ufw allow "Nginx Full"

This opens ports 80 and 443. Port 80 handles unencrypted traffic. Port 443 handles encrypted traffic once you set up SSL.

If UFW isn’t enabled yet, you can enable it with sudo ufw enable, but make sure you’ve allowed SSH first or you’ll lock yourself out.

Step 4: Point Your Domain to the Server

Log into your domain registrar or DNS provider. Create an A record for the root domain (yourdomain.com) pointing to your server’s IPv4 address.

For the www subdomain, add either another A record pointing to the same IP or a CNAME record pointing to the root domain.

The choice depends on what your DNS provider supports and what you prefer.

After saving the records, wait. DNS propagation takes anywhere from a few minutes to a few hours.

You can’t proceed with the SSL step until the domain resolves to your server. You can check propagation using dig yourdomain.com from your local machine or an online DNS lookup tool.

Step 5: Upload Your Website Files

Create the directory that will hold your site files:

text
sudo mkdir -p /var/www/yourdomain

Then copy your files there. You can use scp from your local machine, rsync for syncing, or git clone if your site is in a repository.

Ownership is critical here. A common mistake is giving the web server user (www-data) ownership of everything. That’s not necessary and creates security risks.

The web server only needs to read most files. If your application writes to specific directories (uploads, cache, logs), those need write access.

A safer setup is to own the files with a deploy user and set the group to www-data:

text
sudo chown -R deployuser:www-data /var/www/yourdomain

Then set permissions so the owner can write but the group and others can only read:

text
sudo chmod -R 755 /var/www/yourdomain

For directories that need to be writable by the web server, you can grant group write access individually or use chmod 775 on those specific paths.

Step 6: Configure the Server Block

Nginx uses server blocks to define individual websites. Create a config file:

text
sudo nano /etc/nginx/sites-available/yourdomain

A basic server block looks like this:

nginx
server {
    listen 80;
    listen [::]:80;

    server_name yourdomain.com www.yourdomain.com;

    root /var/www/yourdomain;
    index index.html index.php;

    location / {
        try_files $uri $uri/ =404;
    }

    access_log /var/log/nginx/yourdomain.access.log;
    error_log /var/log/nginx/yourdomain.error.log;
}

Replace yourdomain.com with your actual domain and adjust the root path. The try_files directive tells Nginx to serve the requested file, then try it as a directory, and return a 404 if neither exists.

Enable the site by creating a symlink from sites-available to sites-enabled:

text
sudo ln -s /etc/nginx/sites-available/yourdomain /etc/nginx/sites-enabled/

Test the configuration to make sure there are no syntax errors:

text
sudo nginx -t

If the test passes, reload Nginx:

text
sudo systemctl reload nginx

Reloading applies the changes without dropping existing connections.

Step 7: Add HTTPS with a Free Certificate

Ubuntu Web Hosting- lets encrypt

Let’s Encrypt provides free SSL certificates. Certbot is the tool that automates obtaining and installing them. Install both the Certbot package and the Nginx plugin:

text
sudo apt install certbot python3-certbot-nginx -y

Run Certbot with your domain names:

text
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot will verify you control the domain, obtain the certificate, and automatically modify your Nginx configuration to use it. It also sets up a redirect from HTTP to HTTPS by default.

Certificates expire after 90 days, but Certbot installs a systemd timer that renews them automatically.

Ubuntu Web Hosting- certbot

You can test that renewal works with:

text
sudo certbot renew --dry-run

This performs a simulated renewal without actually requesting new certificates. If it passes, auto-renewal is working.

Step 8: Test the Website and Enable Updates

Visit your domain in a browser. You should see your website loading over HTTPS. The padlock icon in the address bar confirms the connection is encrypted.

If something looks wrong, check the Nginx logs at /var/log/nginx/. The access log shows incoming requests.

The error log shows problems. Both are useful for diagnosing 404s, permission issues, and other common problems.

Finally, enable automatic security updates so the server patches itself:

text
sudo apt install unattended-upgrades -y

This installs the package that handles automatic updates. On Ubuntu, it’s often already installed, but running this command ensures it’s there and configured.

Ubuntu Web Hosting FAQs

Can I host a website on Ubuntu for free?

Is Ubuntu Server good for web hosting?

Can I host multiple websites on one Ubuntu VPS?

Can I host WordPress on Ubuntu Server?

How much RAM do I need to host a website on Ubuntu?

Is Nginx or Apache better for Ubuntu web hosting?

Do I need a domain name to host a website on Ubuntu?

Deploy Your Ubuntu VPS on Truehost Today

If you’d rather skip the hardware shopping and get straight to building, our VPS hosting provides a clean Ubuntu server ready in minutes.

Every plan includes dedicated vCPUs and RAM, NVMe SSD storage that’s up to 7x faster than standard SSDs, and full root access so you can configure everything exactly how you need it.

We run automated daily backups with 30-day retention, so a mistake or a bad update doesn’t mean starting over.

Our security team monitors the servers around the clock, patches automatically, and runs malware scanning without you lifting a finger.

Plans start at ₨2,261.20/month for the entry-level Cloud VPS Elite with 1 vCPU and 1 GB RAM.

If you’re running WordPress or a small application, the Cloud VPS 1 at ₨1,817.68/month gives you 2 GB RAM and 50 GB of storage.

For busier sites or multiple applications, the Cloud VPS 2 at ₨3,315.72/month doubles the RAM to 4 GB and bumps storage to 100 GB. The Cloud VPS 3 at ₨6,650.99/month steps up to 4 vCPUs and 8 GB RAM for heavier workloads.

Read More Posts

API Hosting

API Hosting: What Developers Need to Know When Choosing a Provider

APIs are everywhere. When you log in with Google, check the weather, or pay for something through an…

How to Host a Website on a VPS

How to Host a Website on a VPS: Step by Step Guide for Beginners (2026)

If you have outgrown shared hosting or simply want more control over your website, a VPS is a…

host and share PDF files

How to Host and Share PDF Files on Your Website

You spent days on a great PDF. Maybe it is a catalog, a guide, a worksheet, or a…

cPanel to CWP Migration: How to Move Your Website

cPanel to CWP Migration: How to Move Your Website

Moving from cPanel to Control Web Panel (CWP) can lower hosting costs and give you more control over…