π DNS & VPS Setup Guide (Example: plabonasad.xyz
)
When you purchase a domain and a VPS hosting, you need to connect them.
This is done using DNS records and configuring your VPS (like Nginx/Apache).
This guide is brief, step-by-step, and developer-friendly.
π Quick Overview: DNS Records
DNS is like the phonebook of the internet.
It tells the browser or mail server where to go when someone uses your domain.
Common DNS Records
Record | Purpose | Example |
---|---|---|
A | Points domain β IPv4 address | plabonasad.xyz β 123.45.67.89 |
AAAA | Points domain β IPv6 address | plabonasad.xyz β 2606:4700:4700::1111 |
MX | Directs emails β mail server | @ MX 10 mail.google.com |
CNAME | Points domain β another domain | www β plabonasad.xyz |
TXT | Stores text (for verification & security) | "v=spf1 include:_spf.google.com ~all" |
π For website setup, the A record is the most important (connects your domain β VPS IP).
π Step 1: Get Your VPS Public IP
Login to your VPS provider dashboard and copy your IPv4 address.
Example: 123.45.67.89
π Step 2: Set DNS Records
Go to your domain registrar DNS settings (where you bought plabonasad.xyz
).
Add the following records:
Type | Name | Value | Purpose |
---|---|---|---|
A | @ | 123.45.67.89 | Root domain β VPS |
A | www | 123.45.67.89 | www β VPS |
π This means:
-
plabonasad.xyz
β goes to your VPS -
www.plabonasad.xyz
β goes to your VPS
π Overview Flow (Diagram)
User Browser (plabonasad.xyz)
|
v
DNS Lookup (A Record β 123.45.67.89)
|
v
VPS Server
|
v
Nginx/Apache
|
v
Your Website
π Step 3: Configure Nginx on VPS
SSH into your VPS:
ssh username@123.45.67.89
Create a config for your domain:
sudo nano /etc/nginx/sites-available/plabonasad.xyz
Copy nginx config code:
# Redirect everything to https://plabonasad.xyz
server {
listen 80;
server_name www.plabonasad.xyz;
return 301 https://plabonasad.xyz$request_uri;
}
# Main site (canonical domain)
server {
listen 80;
server_name plabonasad.xyz;
root /var/www/app1/public;
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/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Enable the site by symlink:
sudo ln -s /etc/nginx/sites-available/plabonasad.xyz /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Step 4: Test DNS
Check if your domain points to the VPS:
dig plabonasad.xyz
Or use dnschecker.org
Step 5: Secure with SSL (Optional but Recommended)
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Run:
sudo certbot --nginx -d plabonasad.xyz -d www.plabonasad.xyz
Now your site will load with HTTPS π.
Final Notes
- A record connects domain β server IP
- Nginx/Apache serves the website from VPS
- SSL (Certbot) secures with HTTPS
- Other records (MX, CNAME, TXT) are useful for email & verification
Now when someone types plabonasad.xyz, theyβll reach your VPS-hosted site π.
Top comments (0)