Setting up a web server

⏱ 15 min read đŸ”ĩ Intermediate Last updated: April 2026

This guide walks you through installing Nginx, hosting a website, pointing a domain, and enabling HTTPS — everything you need to get a site live on your BareMeta server.

â„šī¸  This guide assumes you've already secured your server and have ports 80 and 443 open in your firewall.

1. Install Nginx

Nginx is a fast, lightweight web server. It's the most popular choice for hosting websites on Linux.

sudo apt update
sudo apt install nginx -y

# Start Nginx and enable it to start on boot
sudo systemctl enable nginx
sudo systemctl start nginx

# Check it's running
sudo systemctl status nginx

Visit your server's IP address in a browser — you should see the Nginx welcome page. If you need your server's IP, click the 📡 IP button in the dashboard.

2. Host your website

Create a directory for your website and add your files:

# Create the web root directory
sudo mkdir -p /var/www/mywebsite

# Set ownership to your user
sudo chown -R $USER:$USER /var/www/mywebsite

# Create a simple test page
echo "<h1>Hello from BareMeta!</h1>" > /var/www/mywebsite/index.html

Create an Nginx configuration file for your site:

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

Add this configuration (replace yourdomain.com with your domain or server IP):

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/mywebsite;
    index index.html index.htm;

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

Enable the site and reload Nginx:

# Enable the site
sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/

# Test the configuration
sudo nginx -t

# Reload Nginx
sudo systemctl reload nginx
💡  If nginx -t shows errors, check your config file for typos. Common mistakes are missing semicolons or curly braces.

3. Point a domain to your server

To use a custom domain, you need to create an A record pointing to your server's IP address at your domain registrar.

  1. Log in to your domain registrar (Namecheap, GoDaddy, IONOS, etc.)
  2. Go to DNS settings for your domain
  3. Create an A record:
    • Host: @ (for the root domain) and www
    • Value: your server's IP address
    • TTL: 300 (or default)

DNS changes can take up to 24 hours to propagate, though usually it's much faster. You can check if it's working with:

dig yourdomain.com A

4. Enable HTTPS with Let's Encrypt

Let's Encrypt provides free SSL certificates. Certbot automates the process of obtaining and renewing them.

âš ī¸  Your domain must be pointing to your server (step 3) before this will work. Let's Encrypt needs to reach your server to verify domain ownership.
# Install Certbot
sudo apt install certbot python3-certbot-nginx -y

# Obtain and install a certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts — enter your email address and agree to the terms. Certbot will automatically configure Nginx for HTTPS and set up automatic renewal.

Test that auto-renewal works:

sudo certbot renew --dry-run
✅  Your site is now available at https://yourdomain.com with a valid SSL certificate. Certbot renews it automatically before it expires.

5. Add PHP support (optional)

If your site uses PHP (WordPress, Laravel, etc.), install PHP-FPM:

# Install PHP and common extensions
sudo apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml -y

# Start PHP-FPM
sudo systemctl enable php8.1-fpm
sudo systemctl start php8.1-fpm

Update your Nginx site config to process PHP:

server {
    listen 80;
    server_name yourdomain.com;
    root /var/www/mywebsite;
    index index.php index.html;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }
}
sudo nginx -t && sudo systemctl reload nginx