A deep dive into my efforts to set up this blog.
learning how to host a site
November 24, 2024 (Updated: November 24, 2024)
In this post, we’ll be walking through how i step up my vps to host my site and configuerd my custom email address using my domain
Prerequisites
Software Needed
- Command Prompt : for talking to my server via SSH and running simple commands
- Visual Studio Code : used to build the site
- GitHub : Used for backing up my code
- Nginx : used to host and server the site
- Rsync: for sending files from local to vps
- Windows Subsystem for Linux : provided a Linux environment for running server related commands
Technical skills
- System Administration
- Configured a VPS using SSH on Command Prompt
- Installed and confiured Nginx
- Networking and DNS Management
- Configured DNS records (A,AAAA,MX and TXT) to link domain to VPS and enable email functionality
- Tested and verified DNS propagation to ensure proper connectivity
- Software Installation and Configuration
- Deployed files to the VPS using Rsync
- Edited site files using VS Code and applied udates to the server after commiting to GitHub
- Email Set Up
- Configured a custom email address using Titan, including SPF, DKIM and Dmarc for email authencation
- Problem-Solving and Troubleshooting
- Resolved connectivity issues during server setup and verfied Nginx functionality
- Documentation and Communitcation
- Created clear and concise documentation to outline the set-up process
Accounts and Services
- Vultr : My VPS provider
- Epik : My domain registar
- Titan Email : used to set up and manage a custom email based on my domain
Step-by-Step Guide
Step 1 : Set Up Your VPS
- Sign Up and Create a VPS
- Go To Vultr and create an account
- Deploy a server instance :
- Choose a Server Type : Debian 12x64
- Server Size : Start with the basic plan
- Region : Choose the server location closest to you
- Access The Server Via SSH :
- Use command prompt to log in. Replace(your-ip-here) with your servers ip address
bash
ssh root@<your-ip-here>
- Accept the SSH key fingerprint and enter the root password provided by Vultr
- Update The Server :
bash
sudo apt udpate
sudo apt update -y
Step 2 : Configure The Web Server(Nginx)
- Install Nginx :
bash
Sudo apt install nginx -y
- Enable Nginx
- Ensure Nginx service is running :
bash
Sudo systemctl enable nginx
sudo systemctl start nginx
- Test Nginx Installation :
- Ensure correct firewall ports are open
bash
ufw allow 80
ufw allow 443
- Open browser and go to your VPS IP address http://(your-ip-here). You Should see the default Nginx Welcome page
- Deploy your website :
- Install Rsync :
bash
sudo apt install rsync
- Move dist folder from local machine to VPS using rsync :
bash
rsync -avz -e "ssh" /mnt/c/path/to/local/folder/ root@your-ip-here:/var/www/<your-site>/
- Update the Nginx configuration file to serve your site :
bash
sudo nano /etc/nginx/sites-available/<your-site>
- Example Configuation :
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/<your-site>;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
- Enable Configuration and Reload Nginx :
bash
sudo ln -s /etc/nginx/sites-available/<your-site> /etc/nginx/sites-enabled/
sudo systemctl reload nginx
Step 3 : Configure DNS for Your Domain
- Log in to Epik:
-Go to Epik and access your domain settings
-Update the DNS records:
- A Record : Points yourdomain to your VPS Ipv4 address
- AAAA Record : Points yourdomain to your VPS Ipv6 address
- Verify DNS Propagation Use a DNS lookup tool to confirm records are live
Step 4 : Setup Email with Titan
- Sign Up and Configure Titan Email
- Create an account on Titan Email
- Connect Titan to you domain by adding the required DNS records(SPF,DKIM and MX) in Epik
- Test Email Functionality
- Send and receive test emails to confirm everything is working
Step 5: Troubleshooting Common Issues
- Cannot connect via ssh
- ensure port 22 is open in the VPS
- Nginx Configuration Error
- Run sudo nginx -t to test the configuration for syntax errors.
- DNS propagation Delay
- It can take up to 24 hours for DNA changes to propagate