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

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

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.

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?
The operating system and most of the software are free. You still pay for the hardware or VPS. You can host on old hardware at home if you have a stable internet connection and a public IP, but most people use a VPS for reliability and speed.
Is Ubuntu Server good for web hosting?
Yes. Ubuntu Server is one of the most widely used operating systems for web hosting. It’s stable, well-documented, and has a massive community. The LTS releases receive security updates for years.
Can I host multiple websites on one Ubuntu VPS?
Yes. Nginx server blocks let you host as many sites as your server resources can handle. Each site gets its own config file, root directory, and optionally its own database. The limit is CPU, RAM, and bandwidth, not the software.
Can I host WordPress on Ubuntu Server?
Yes. WordPress runs on a LEMP stack (Linux, Nginx, MySQL/MariaDB, PHP). You install the database server and PHP, create a database for WordPress, download WordPress into your site directory, and configure Nginx to handle PHP requests through PHP-FPM. It’s a common setup.
How much RAM do I need to host a website on Ubuntu?
For a static site, 1 GB is enough. For WordPress or a small dynamic application, 2 GB is a realistic minimum. If you’re running an ecommerce store or a busy application, 4 GB or more is safer.
Is Nginx or Apache better for Ubuntu web hosting?
Nginx uses fewer resources and handles high traffic better, especially for static files. Apache offers more flexible per-directory configuration through .htaccess and a larger module ecosystem. For a new site, Nginx is the more common choice. If your application depends on .htaccess or specific Apache modules, go with Apache.
Do I need a domain name to host a website on Ubuntu?
No, but you need one for anyone to find your site by name. Without a domain, visitors would have to use your server’s IP address. You can test your site using the IP before pointing a domain, but a domain is necessary for a real website.
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.
Domain SearchInstantly check and register your perfect .pk or international domain
Web HostingGet a .pk domain for as low as PKR 467
cPanel HostingUser-friendly hosting powered by cPanel
Reseller HostingLaunch your own hosting business with minimal technical requirements
Windows HostingOptimized for Windows-based applications and websites
Affiliate ProgramEarn referral commissions by promoting our services
WordPress HostingFast & Reliable WordPress Hosting
Domain TransferMigrate your existing domain seamlessly with zero downtime.
All DomainsAccess 324+ top-level domains (TLDs) worldwide from a single platform
Whois LookupIdentify the owner of any domain using our whois and rdap lookup tool
Managed VPS Hosting
SSL CertificatesEncrypt data, build trust, and boost SEO.






