Create and Deploy a Website in Under 10 Minutes
Piotr
Sep 23, 2024
Deploying a website in just under 10 minutes is totally achievable. This guide will walk you through the process, step by step, using Hetzner as your cloud provider and Let’s Encrypt to set up a free SSL certificate.
Before we start, you’ll need to ensure a few prerequisites are in place.
Prerequisites
A Domain Name
Ensure you already own a domain or have an account with a domain provider (such as EuroDNS, GoDaddy, or Namecheap) where you can quickly purchase one.
An Account on Hetzner
Hetzner is our cloud provider for this tutorial. You'll need to sign up if you don’t have an account yet. Remember that creating an account might require a prepaid balance of €20, which can be paid via PayPal or credit card.
Once you’ve handled these prerequisites, you’re ready to move on.
🕛 The timer is running.
Step 1: Acquire a Domain Name
🕐 If you already own a domain, feel free to skip this step. If not, here’s what you need to do:
Sign in to your domain provider’s platform. Search for an available domain and complete the purchase. Once purchased, keep the DNS management tools handy—you’ll need them shortly.
Step 2: Generate an SSH Key (OpenSSH Certificate) (optional but recommended)
🕑 To securely connect to your server, you must generate an SSH key.
If you don't have any yet, here’s how:
Open a terminal on your local machine (Linux/macOS) or use an SSH tool (like PuTTY on Windows).
Run this command to generate an SSH key:
ssh-keygen -t rsa -b 4096
Save the key and copy your public key using:
cat ~/.ssh/id_rsa.pub
In the Hetzner Cloud control panel, add the public key to the SSH Keys section (within the Security menu). This will enable you to connect to your VM securely.
Step 3: Set Up Your Web Server on Hetzner
🕒 With a Hetzner Cloud account ready, it’s time to deploy a virtual machine (VM) where your website will be hosted:
Log in to your Hetzner Cloud account.
- Go to the Cloud Console, create a "New Project," then select "Create Server."
- Choose the Location closest to your target audience (Hetzner has multiple data centers worldwide).
- Select the Image (I chose Debian 12)
- Select the Type of your Server: Shared vCPU, x86 (Intel/AMD) and then CX22 (2vCPUs, 4 GB RAM, SSD 40 GB and the price at €0.006/h is an excellent choice to start with)
- In the Networking section, ensure you enable IPv4 (alongside IPv6) because some domain providers require IPv4 to link domains. That will add an extra €0.00086/h to the bill but is rather necessary.
- SSH keys: To increase the security of your server, you are recommended to use SSH keys. You can use a previously added SSH key or copy and paste a new public one into this field.
- Deploy the server by clicking "Create & Buy now".
After your server is created, Hetzner will provide your server's public IP address.
Step 4: Connect to Your Server
🕓 Now that the SSH key is in place, connect to your Hetzner server using the following command:
ssh root@your-server-ip
Make sure to replace your-server-ip with the IP address Hetzner provided.
Step 5: Install Nginx
🕔 Once logged into your server, the next step is to install a web server. We’ll use Nginx, a widely used and reliable web server.
Update the package lists:
bash
sudo apt update
sudo apt upgrade
Install Nginx:
sudo apt install nginx
Start the Nginx service:
sudo systemctl start nginx
You can now navigate to your server’s IP address in a browser. You should see the default Nginx welcome page.
Step 6: Configure DNS to Point to Your Server
🕕 It’s time to connect your domain to your server by setting up DNS records:
Log in to your domain provider’s DNS management tool.
Add an A record pointing your domain to the IPv4 address of your Hetzner server:
A record: * points to your-server-ip
A record: www points to your-server-ip
The wildcard * record is for any subdomain (including a non-prefixed domain name without any subdomain).
Optionally, using @ instead of * will allow you to use your domain without any subdomain only.
A record: @ points to your-server-ip
Wait for the DNS propagation, which can take anywhere from a few minutes to an hour.
Step 7: Secure Your Website with SSL (Using Let’s Encrypt)
🕖 Your site is now online, but it’s not yet secure. Let’s use Let’s Encrypt to set up a free SSL certificate:
Install Certbot, the tool used for obtaining SSL certificates:
Install Python:
sudo apt install python3 python3-venv libaugeas0
Install Certbot Nginx Package:
sudo apt install python3-certbot-nginx
Set up a Python virtual environment:
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
Install Certbot:
sudo /opt/certbot/bin/pip install certbot
Prepare the Certbot command:
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
Run Certbot to generate and install the SSL certificate:
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
Certbot will prompt you to enter an email address and agree to the terms of service. Once Certbot finishes, it will configure Nginx to redirect HTTP traffic to HTTPS automatically.
Or, just get a certificate:
If you want to change your Nginx configuration by hand, run this command.
sudo certbot certonly --nginx
Set up automatic renewal:
Let’s Encrypt SSL certificates are valid for 90 days and it is recommended to set up a cron job to automatically renew it for free before its expiration to avoid service interruption.
Run the following line, to add a cron job to the default crontab.
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
Step 8: Verify HTTPS
🕗 You should now be able to visit your website using HTTPS. To verify everything is working, open your browser and navigate to https://your-domain.com.
To double-check your SSL configuration, you can use tools like SSL Labs to confirm that your SSL certificate is correctly installed and trusted.
Step 9: Deploy your website
🕘 The content you see visiting your website is the default Nginx welcome page. It lives in /var/www/html. To change it to your desired content, do the following:
cd your-website-directory
scp * root@your-server-ip:/var/www/html
Was it 10 minutes?
🕙 I don't know, but now that you know the steps, you can set the web server in less than that!
—
🕚 This clock does not show 10 minutes, true.
🕛 But it is still cool to see so many nice native Unicode characters available today.