Overview
Buying a domain name and renting a server are separate things. After you have both, you need to connect them through DNS so that people who type your domain get directed to your server. This guide walks through the most common scenarios.
What You Need
- ▸Your domain name (registered with any registrar)
- ▸Your server's public IPv4 address (and optionally IPv6)
- ▸Access to your DNS provider or registrar's DNS settings
- ▸A web server running on your server (Apache, NGINX, etc.)
Step 1: Find Your Server's IP Address
Log into your VPS or cloud provider (e.g., DigitalOcean, Linode, AWS EC2) and find the public IP address. It will look something like 203.0.113.42.
# Check your server's public IP curl ifconfig.me # or curl ipinfo.io/ip
Step 2: Create an A Record in DNS
Log into your DNS provider (Cloudflare, Namecheap, GoDaddy, etc.) and create an A record:
Type: A Name: @ (for yourdomain.com) Value: 203.0.113.42 TTL: 3600 (1 hour) # Also add www if you want www.yourdomain.com to work: Type: A Name: www Value: 203.0.113.42 TTL: 3600
Step 3: Wait for DNS Propagation
DNS changes take time. With a 3600 TTL, expect changes to propagate globally within 1–4 hours. You can check progress with:
# Command line check dig yourdomain.com A +short # Or use these online tools: # https://dnschecker.org # https://whatsmydns.net
Step 4: Configure Your Web Server
Once DNS resolves to your server, make sure your web server is configured to respond to your domain:
NGINX configuration
server {
listen 80;
listen [::]:80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/yourdomain;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
}Apache configuration
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/yourdomain
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>Step 5: Set Up SSL (HTTPS)
Use Let's Encrypt for a free SSL certificate:
# Install Certbot sudo apt install certbot python3-certbot-nginx # Get a certificate (NGINX) sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com # Certificate auto-renews — test renewal with: sudo certbot renew --dry-run