How to Host a Website on a VPS
By Harborvm7 min read
Key takeaways
- Pick Nginx for most sites and Apache when you need.htaccess rules; both serve static and dynamic content well.
- A LEMP stack (Nginx) or LAMP stack (Apache) with MariaDB and PHP covers most websites, including WordPress.
- DNS changes are simple: point an A record at your server IP and allow time for the record to spread.
- Let's Encrypt gives free certificates and Certbot renews them automatically before they expire.
- Harborvm ships automatic HTTPS and up to 10 forwarded ports, so a single Linux VPS can serve your site end to end.
To host a website on a VPS you rent a Linux server, install a web server such as Nginx or Apache, point your domain at the server with a DNS A record, and add a free SSL certificate. This guide walks through each step with the exact commands, using Ubuntu as the example. The same pattern works on Debian, AlmaLinux, Rocky Linux, and Fedora.
A VPS gives you a full operating system and root access, so you decide what runs and how. That is more work than shared hosting, but you get real control and resources that are yours. If you are weighing the two, read VPS vs Shared Hosting: Which Should You Choose? first.
Choosing a web server: Nginx vs Apache
Your web server is the program that listens on ports 80 and 443 and sends pages to visitors. Two options cover almost every case.
Nginx handles many connections with little memory and serves static files fast. It is the common choice for new sites and high-traffic sites. On the busiest sites in particular, Nginx leads: according to the W3Techs web server survey, Nginx is used by around 30% of all websites and remains the top pick among the largest sites.
Apache is older and uses .htaccess files, which let you change rules per directory without touching the main config. Some applications and tutorials assume Apache, so it is the safer choice when software expects .htaccess.
A short way to decide:
- Pick Nginx for a new site, a static site, or anything where speed under load matters.
- Pick Apache if your application documents
.htaccessrules or you want per-directory overrides.
Both run well on a small VPS. The Harborvm Small plan (1 vCPU, 2 GB RAM, 40 GB SSD) is enough for a personal site or a low-traffic business site. Because each vCPU is one real CPU thread and memory is reserved, your site keeps the resources you pay for even when the host machine is busy. For why that matters, see What Is a Dedicated vCPU and Why It Matters.

Installing a LEMP or LAMP stack step by step
A full website usually needs four things: the operating system, a web server, a database, and a language runtime. The common bundles are:
- LEMP: Linux, Nginx (the E is for its pronunciation), MariaDB or MySQL, and PHP-FPM.
- LAMP: Linux, Apache, MariaDB or MySQL, and PHP.
Here is a LEMP install on Ubuntu. Start as a non-root user with sudo rights. If you have not hardened the server yet, work through How to Secure Your VPS: A Practical Checklist alongside this.
- Update the package list and installed packages:
sudo apt update && sudo apt upgrade -y
- Install Nginx:
sudo apt install nginx -y
- Install the database server:
sudo apt install mariadb-server -y
sudo mysql_secure_installation
Answer the prompts to set a root password and remove the test database.
- Install PHP-FPM and the MySQL extension:
sudo apt install php-fpm php-mysql -y
- Create a server block for your site. Make a web root and a config file:
sudo mkdir -p /var/www/example.com
sudo nano /etc/nginx/sites-available/example.com
A minimal config that serves PHP:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
}
- Enable the site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
For a LAMP stack, replace steps 2 and 5: install apache2 instead of Nginx, install php libapache2-mod-php, and put your site files under /var/www/example.com with a virtual host in /etc/apache2/sites-available/.
On a fresh Harborvm VPS, Ubuntu is ready in about a minute, so you can run these commands right after the server boots. Other distributions use a different package manager: AlmaLinux, Rocky Linux, and Fedora use dnf in place of apt. See Best Linux Distro for VPS: How to Choose if you have not picked one.
Pointing your domain and configuring DNS
Right now your site answers only on the server IP address. To use your domain, you add DNS records that map the name to that address.
- Find your server IP. On Harborvm, your VM sits behind the server's public IP with forwarded ports, so use the IP and ports shown in your control panel.
- Log in to your domain registrar or DNS host.
- Add an A record for the apex domain, pointing
example.comat your IPv4 address. - Add a second A record (or a CNAME) for
www, pointingwww.example.comat the same place. - Set a modest TTL, such as 3600 seconds, while you are still making changes.
DNS changes are not instant. Resolvers cache records, so an update can take minutes to a few hours, and up to 48 hours in rare cases. You can watch progress with a simple lookup:
dig example.com +short
When that returns your server IP, the record has spread to your resolver. Visitors on other networks may see it sooner or later depending on their own caches.
Adding free SSL with Let's Encrypt
Every public site should serve over HTTPS. Let's Encrypt is a nonprofit certificate authority that issues certificates for free, and the Certbot client installs and renews them for you. Certificates are short lived by design, so automatic renewal matters: Let's Encrypt has announced it is moving default certificate lifetimes down toward 45 days, which only works smoothly if renewal is automated.
On Ubuntu with Nginx:
- Install Certbot:
sudo snap install core && sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
- Request and install the certificate. Certbot edits your Nginx config and reloads it:
sudo certbot --nginx -d example.com -d www.example.com
Choose to redirect HTTP to HTTPS when prompted.
- Confirm automatic renewal is scheduled:
sudo certbot renew --dry-run
For Apache, swap --nginx for --apache. Certbot installs a systemd timer that renews certificates before they expire, so once the dry run passes you can leave it alone.
Harborvm also offers automatic HTTPS on your own domain as a built-in feature, which handles certificate issuance and renewal for you. If you prefer to manage certificates yourself, the Certbot route above works the same on any Harborvm Linux VPS.
Testing performance and going live
Before you announce the site, check that it works and holds up.
- Confirm HTTPS: open
https://example.comand check the padlock. A redirect fromhttp://should land on the secure version. - Check the config: run
sudo nginx -t(orsudo apachectl configtest) after any change. - Watch resources: during a traffic spike, keep an eye on CPU and memory. Harborvm shows live CPU, memory, disk, and network graphs in the browser, so you can see when a page is slow because the server is working hard rather than guessing.
- Measure load time: use your browser developer tools, or a command such as
curl -w "%{time_total}\n" -o /dev/null -s https://example.comto see how long a request takes. - Plan backups yourself: Harborvm does not provide backups or snapshots, so keep your own copies. Export your database with
mysqldumpand copy your site files off the server on a schedule you control.
One more honest limit to plan around: if your site sends email, note that outbound port 25 is blocked on Harborvm. Use a mail relay on port 587 or 465 instead, which is the standard approach for sending from a server anyway.
When the site is live, point remaining services at the domain, lower your DNS TTL back to a normal value, and set a reminder to test certificate renewal once. If you are still choosing where to run it, the Harborvm Small plan at $10 a month gives you a dedicated vCPU, reserved memory, and SSD storage that is enough to host a real website today. Spin one up, run the steps above, and you will have a site on your own domain within the hour.
Frequently asked questions
Do I need a Windows VPS to host a website?
No. Most websites run on Linux. A Linux VPS with Nginx or Apache handles static sites, WordPress, and custom apps. Windows hosting only makes sense for ASP.NET or other Windows-specific stacks.
How long does DNS take to update after I point my domain?
Usually minutes to a few hours, and up to 48 hours in rare cases. The delay depends on the TTL set on the record and on caching by resolvers between you and the visitor.
Is Let's Encrypt really free, and does it renew by itself?
Yes. Let's Encrypt issues certificates at no cost. Certbot installs a timer that renews each certificate automatically, so you set it once and leave it.
Can I host more than one website on a single VPS?
Yes. Both Nginx and Apache support virtual hosts, so you can serve several domains from one server. Each gets its own config file and its own certificate.