Host-a-Website-on-a-VPS

A virtual private server (VPS) gives you an isolated server environment with resources you can use for your website. Compared with shared hosting, it offers more control over the operating system and server software. That control also means you are responsible for setup and routine maintenance unless your hosting plan includes managed support. Providers may offer root access, a choice of Linux distributions, optional control panels, backups, and different resource levels, so check what your plan actually includes before you begin.

This guide walks through a basic setup using an Ubuntu VPS and Nginx. The same general sequence applies elsewhere, but package commands and configuration paths can differ by distribution or control panel.

What you’ll need

Before starting, have a VPS with Ubuntu installed, its public IP address, and permission to connect over SSH. You’ll also need a domain name that you can edit through your registrar or DNS provider. Make sure you can use a user account with sudo privileges. If your host has already installed a web server or control panel, check its instructions first; avoid installing a second server that could conflict with the existing setup.

A small static site can run with modest resources, while a content management system, online store, or several websites may need more memory, storage, and processing capacity. Consider expected traffic and application requirements when choosing a plan. Look for backup and support arrangements too, and do not assume that a control panel or automatic backups are included.

1. Connect to the VPS with SSH

SSH (Secure Shell) creates an encrypted connection between your computer and the server. On macOS or Linux, open Terminal. On Windows, use Windows Terminal or another SSH client. Substitute your server’s IP address and the login name supplied by your host:

ssh username@YOUR_SERVER_IP

If your provider supplies an SSH key, use the key-based login instructions it provides. On your first connection, SSH may ask you to confirm the server’s host key. Confirm it only if the IP and server details match the information from your provider. Once connected, commands you enter run on the VPS, not on your own computer.

For safer routine administration, use a regular account with sudo rather than logging in as root when the provider supports that setup. Keep the SSH key or password private. Never paste credentials into a public support post or save them in a website directory.

2. Update the server and install Nginx

Start by applying the available system updates. On Ubuntu, run:

sudo apt update
sudo apt upgrade -y

Install Nginx, a web server that can deliver website files to visitors:

sudo apt install nginx -y

Check that the service is running:

sudo systemctl status nginx

If it is active, enter the VPS IP address in a browser. You should see Nginx’s default page. Ubuntu’s Nginx guide also uses the /var/www directory for site files and separates site-specific server configuration from the default site.

3. Allow web traffic through the firewall

A website will not load from outside the VPS if a firewall blocks web requests. Some VPS providers have a network firewall in their dashboard, while Ubuntu also provides the ufw host firewall. Check both layers if you cannot reach your site.

If you use ufw, allow SSH before enabling the firewall so that you do not accidentally lock yourself out of the server. Then allow web traffic and check the rules:

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status

The Nginx Full profile allows the standard HTTP and HTTPS ports. If that profile is not available on your system, use sudo ufw allow 80/tcp and sudo ufw allow 443/tcp instead. Keep SSH open on the port you actually use. Ubuntu documents ufw as its default firewall configuration tool and provides commands to allow ports and review firewall status.

4. Put your website files on the server

Create a directory for your site and give it a simple test page. Replace example.com with your own domain in the later configuration steps.

sudo mkdir -p /var/www/example.com/html
sudo chown -R $USER:$USER /var/www/example.com/html
nano /var/www/example.com/html/index.html

In the editor, add a small HTML page, for example:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example website</title>
</head>
<body>
<h1>It works</h1>
<p>This website is running on my VPS.</p>
</body>
</html>

Save the file and close the editor. In Nano, use Ctrl+O, press Enter, then Ctrl+X. For a real website, upload its files using a secure method such as SFTP or deploy them from your version-control workflow. Avoid making the website directory writable by every user on the server.

5. Configure Nginx for your domain

Nginx needs to know which domain should serve files from the directory you created. Make a site configuration file:

sudo nano /etc/nginx/sites-available/example.com

Add this configuration, changing the domain name if needed:

server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;

root /var/www/example.com/html;
index index.html;

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

Enable the configuration and test it before reloading Nginx:

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

If nginx -t reports an error, fix the indicated line before reloading. Ubuntu’s example shows how a server block maps a hostname to a document root and how Nginx uses that configuration to serve a site. If you already have a site configuration or use a hosting panel, follow its method instead of duplicating these files.

6. Point your domain to the VPS

Sign in to the DNS service that manages your domain. Create or update an A record for the root domain (often written as @) and set its value to the VPS’s IPv4 address. Add another A record for www if you want that hostname to work too. If your VPS has a public IPv6 address and IPv6 is configured for the site, create matching AAAA records. Do not add an IPv6 record with an address that is not actually configured on the server.

DNS changes can take time to appear everywhere. Once the records resolve to the VPS, open http://example.com and check that your page loads. Until the domain points to the server, certificate setup for that hostname may fail.

7. Enable HTTPS

HTTPS encrypts the connection between a visitor’s browser and your website. For Nginx, Certbot can obtain a certificate and configure Nginx to use it. First, confirm that the domain resolves to the server and that inbound web traffic is allowed. Then follow Certbot’s current instructions for your Ubuntu version and installation method. The Certbot Nginx workflow uses the certbot –nginx command to request and install a certificate, and recommends testing renewal with sudo certbot renew –dry-run.

After installation, visit https://example.com and check that the page loads securely. The installed Certbot package normally automates certificate renewals, but the dry run is a useful way to confirm that renewal works. If your hosting provider or control panel manages SSL certificates, use its documented method instead.

8. Check the site and keep the server maintained

Test the site using both the root domain and www address, if both are configured. Check the page from another network or device, and confirm that HTTP redirects to HTTPS if your certificate tool enabled that option. If the browser shows the wrong page, review the domain’s DNS records, Nginx server name, and document root. If the site does not respond at all, check the firewall and Nginx status.

Keep the operating system and website software updated. Back up both the site files and any databases, and store a copy away from the VPS so a server failure does not take out the only backup. Check that you know how to restore a backup before you need one. Monitor disk space and resource use as the website grows. A managed VPS provider may handle some maintenance and monitoring, but the exact responsibilities depend on the plan; confirm them with your provider.

Common questions

1. Can I host more than one website on a VPS?
Yes. Nginx can use separate server blocks to serve different domains from different directories on one server. Each site still shares the VPS’s CPU, memory, storage, and network capacity, so monitor resource use as you add sites.

2. Do I have to use a control panel?
No. You can manage a VPS through SSH and configuration files, or use a compatible control panel if your plan includes or supports one. A control panel can make common tasks easier, but it does not remove the need to understand backups, updates, and access security.

3. What if I don’t want to manage the server myself?
Ask the host whether managed support covers operating-system updates, security configuration, monitoring, backups, and troubleshooting. “Managed” can mean different things between providers. Some Linux VPS plans also offer optional panels or technical support, so verify the scope before choosing a plan.

Learn more in the knowledge base: When VPS Hosting Would Be Suitable For You? (Part I)

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

Change Default IP Address for Name-based Sites

Change Default IP Address for Name-based Sites

When you’re hosting multiple websites on the same server using name-based virtual hosting, your server…

Why Should You Select Your Virtual Server With bodHOST.com?

There are many reasons to choose a virtual server with bodhost.com. It offers you fully…

How to Unzip Files in CMD (Windows 10 & 11) – 4 Methods

Need to extract a ZIP file without touching your mouse? Windows gives you four solid…