DNS (Domain Name System) converts human-friendly domain names (like www.google.com) into IP addresses.
Step 1: Configure DNS in Namecheap
- Log in to Namecheap.
- Go to Domain List:
Click on the "Domain List" on the left sidebar.
Find the domain you want to configure and click "Manage."
- Set Up DNS Records
Navigate to the Advanced DNS tab.
You will need to configure A Records and possibly CNAME record:
A Record → Points your domain to your server’s IP.
Type: A Record
Host: @
Value: your IP address
TTL: Automatic
CNAME Record → Makes www.yourdomain.com point to yourdomain.com.
Type: CNAME Record
Host: www
Value: yourdomain.com
TTL: Automatic
- Changes can take a few minutes to 24 hours to propagate.
Step 2: Configure Nginx on Your Server
If you haven't configured Nginx yet, follow these steps:
- install nginx:
sudo apt update && sudo apt install nginx -y
- create a new nginx config:
sudo nano /etc/nginx/sites-available/myproject
- add this content:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
# Write the rest of your Nginx configuration here
}
- enable the config:
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled/
- check for errors:
sudo nginx -t
- restart nginx:
sudo systemctl restart nginx
If you have Nginx configured, you only have to adjust the server_name
directive to include your domain:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
# Keep the rest of the configuration unchanged.
Then you have to restart nginx:
sudo systemctl restart nginx