Buying a domain is exciting. Creating a server is exciting too.
But the moment you try to connect both of them, things can feel confusing.
You bought your domain from Namecheap. You created a VPS on DigitalOcean. Now you expect your website to open when someone visits your domain.
But unlike shared hosting or cPanel hosting, DigitalOcean does not automatically connect everything for you.
You need to set up two important things:
- DNS : so your domain points to your server
- Nginx : so your server knows how to serve your website
In this guide, we will walk through the full setup in a simple and beginner-friendly way.
By the end, your domain will point to your DigitalOcean Droplet, Nginx will serve your website, and HTTPS will be enabled.
The Big Picture
Before touching any settings, let’s understand the flow.
Namecheap Domain
↓
DNS points to DigitalOcean IP
↓
DigitalOcean Droplet
↓
Nginx Web Server
↓
Your Website
Your domain is like a human-friendly address.
Your DigitalOcean Droplet is the actual server.
DNS connects the domain to the server.
Nginx receives the request and serves your website files or forwards traffic to your app.
Step 1: Create a DigitalOcean Droplet
First, create a Droplet on DigitalOcean.
For a beginner project or test website, this setup is usually enough:
Ubuntu 22.04 LTS
Basic Droplet
1 GB RAM
After the Droplet is created, DigitalOcean will give you a public IP address.
It will look something like this:
159.89.xxx.xxx
Keep this IP address safe. You will need it in the next step.
This IP is where your domain will point.
Step 2: Point Your Namecheap Domain to DigitalOcean
Now go to your Namecheap account.
Open:
Domain List
→ Manage
→ Advanced DNS
There are two common ways to connect your domain.
Option A: Use A Records
This is the easiest method for beginners.
Add these DNS records:
| Type | Host | Value |
|---|---|---|
| A Record | @ | Your DigitalOcean IP |
| A Record | www | Your DigitalOcean IP |
Example:
| Type | Host | Value |
|---|---|---|
| A Record | @ | 159.89.xxx.xxx |
| A Record | www | 159.89.xxx.xxx |
You can keep TTL as the default value.
Here is what this does:
example.com → DigitalOcean server
www.example.com → DigitalOcean server
So both the root domain and the www version will go to the same Droplet.
For most simple projects, this is the best starting point.
Option B: Use DigitalOcean Nameservers
Another option is to manage DNS from DigitalOcean instead of Namecheap.
In DigitalOcean, go to:
Networking
→ Domains
→ Add Domain
Add your domain there.
DigitalOcean will give you nameservers like:
ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
Then go back to Namecheap:
Domain
→ Manage
→ Nameservers
→ Custom DNS
Add those three DigitalOcean nameservers and save.
This method is useful when you want to manage all DNS records from DigitalOcean, especially if you have multiple subdomains or services.
Which DNS Method Should You Choose?
For beginners, use A Records.
It is simple, clear, and easy to debug.
Use DigitalOcean nameservers when your setup becomes larger, for example:
api.example.com
app.example.com
blog.example.com
admin.example.com
For now, we will continue with the beginner-friendly A Record method.
Step 3: Wait for DNS Propagation
DNS changes are not always instant.
Sometimes they work in a few minutes. Sometimes they take longer.
Usually, it can take:
5 minutes to 1 hour
In some cases, it may take up to:
24 hours
You can use tools like DNS Checker to see whether your domain is pointing to the correct server IP.
A common beginner mistake is changing DNS and immediately thinking something is broken. Sometimes nothing is broken. DNS just needs a little time.
Step 4: Connect to Your Server with SSH
Now connect to your DigitalOcean Droplet.
On Mac or Linux, open your terminal.
On Windows, you can use PowerShell or PuTTY.
Run:
ssh root@YOUR_SERVER_IP
Example:
ssh root@159.89.xxx.xxx
The first time you connect, your terminal may ask for confirmation. Type:
yes
Then enter your password or use your SSH key, depending on how you created the Droplet.
Step 5: Install Nginx
Once you are inside the server, update the package list:
sudo apt update
Then install Nginx:
sudo apt install nginx -y
Check if Nginx is running:
sudo systemctl status nginx
If everything is working, you should see that Nginx is active.
At this point, if you open your server IP in the browser, you may see the default Nginx welcome page.
That means your web server is working.
Step 6: Configure the Firewall
Ubuntu servers often use ufw for firewall management.
Allow Nginx traffic:
sudo ufw allow 'Nginx Full'
Also allow SSH so you do not lock yourself out:
sudo ufw allow OpenSSH
Then enable the firewall:
sudo ufw enable
You can check the firewall status with:
sudo ufw status
You should see that HTTP, HTTPS, and SSH traffic are allowed.
Step 7: Create a Website Folder
Now create a folder for your website.
sudo mkdir -p /var/www/myproject
Create a test HTML file:
sudo nano /var/www/myproject/index.html
Paste this:
<h1>Hello from DigitalOcean</h1>
Save the file:
CTRL + X
Y
Enter
This simple file will help us confirm that the domain and Nginx setup are working.
Step 8: Create an Nginx Server Block
An Nginx server block tells Nginx how to handle traffic for a specific domain.
Create a new config file:
sudo nano /etc/nginx/sites-available/myproject
Paste this configuration:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/myproject;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
Replace this:
example.com www.example.com
With your real domain.
For example:
server_name mycoolsite.com www.mycoolsite.com;
This config says:
“When someone visits this domain, serve files from /var/www/myproject.”
Step 9: Enable the Site
Nginx keeps available site configs in:
/etc/nginx/sites-available/
But it only uses configs that are linked in:
/etc/nginx/sites-enabled/
So we need to enable the site:
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled/
Step 10: Test and Reload Nginx
Before restarting Nginx, always test the config:
sudo nginx -t
If everything is fine, you should see something like:
syntax is ok
test is successful
Now reload Nginx:
sudo systemctl reload nginx
Open your domain in the browser:
http://yourdomain.com
You should see:
Hello from DigitalOcean
Great. Your domain is now connected to your Droplet.
Step 11: Add HTTPS with Certbot
A production website should use HTTPS.
For that, we can use Certbot with Let’s Encrypt.
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Then run:
sudo certbot --nginx
Certbot will ask you to choose the domain.
Select your domain and allow redirect to HTTPS.
After that, your site should work with:
https://yourdomain.com
Certbot also sets up automatic renewal, so your SSL certificate can renew before it expires.
Final Architecture
Your setup now looks like this:
Namecheap
↓
DNS A Record
↓
DigitalOcean Droplet IP
↓
Nginx
↓
Website Files
This is a common real-world setup used by many developers.
Why This Feels Different from cPanel Hosting
If you are coming from cPanel hosting, DigitalOcean may feel harder at first.
That is normal.
With cPanel hosting, the hosting company usually handles many things for you:
DNS
Apache or Nginx
SSL
PHP
File manager
Email tools
You often just change nameservers and upload your files.
But with a DigitalOcean VPS, you manage the server yourself.
That means you are responsible for:
Nginx
Firewall
SSL
App runtime
Deployment
Security
Logs
The benefit is flexibility.
You can run Node.js, Laravel, Docker, PostgreSQL, Redis, background workers, multiple apps, and more.
The tradeoff is that you need to understand the server setup.
A Real-Life Example
Imagine you built a small portfolio website.
You bought:
myportfolio.com
from Namecheap.
Then you created a DigitalOcean Droplet with this IP:
159.89.100.50
In Namecheap, you add:
| Type | Host | Value |
|---|---|---|
| A Record | @ | 159.89.100.50 |
| A Record | www | 159.89.100.50 |
Then on your server, your Nginx config looks like this:
server {
listen 80;
server_name myportfolio.com www.myportfolio.com;
root /var/www/myportfolio;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
After reloading Nginx and setting up SSL, visitors can open:
https://myportfolio.com
And see your website.
That is the full journey from domain to live website.

Top comments (0)