Description: Learn how to point your domain to a VPS and configure it using Apache. This guide walks you through DNS settings, A records, and Apache virtual host configuration—perfect for beginners hosting sites on Ubuntu!
How to Point a Domain to Your VPS with Apache: A Step-by-Step Guide with Examples
So, you’ve bought a domain (e.g., exampledomain.com
) and launched a VPS server running Apache. Now it's time to connect them. This guide will help you point your domain to your VPS and configure an Apache virtual host.
🔹 Step 1: Find Your VPS IP Address
After launching your VPS (e.g., on DigitalOcean, AWS, or Linode), go to your provider’s dashboard.
Example VPS IP Address: 203.0.113.42
Copy this—you’ll need it for DNS setup.
🔹 Step 2: Log Into Your Domain Registrar
Let’s assume you're using Namecheap.
- Go to https://namecheap.com and log in.
- Navigate to Domain List > Select your domain > Click Manage.
- Go to the Advanced DNS tab.
🔹 Step 3: Add A Records to Point to VPS
Under Host Records, create the following entries:
HostTypeValue (IP)TTL@A203.0.113.42AutomaticwwwA203.0.113.42Automatic
@
maps the root domain (exampledomain.com
).
www
maps the www.
subdomain.
💡 For GoDaddy or Google Domains, this section might be called “DNS Management” or “DNS Settings.”
🔹 Step 4: Wait for DNS Propagation
It may take time for changes to reflect globally.
- Typical wait time: 15 minutes to 4 hours
- Max delay: Up to 48 hours
Check propagation at:
🔹 Step 5: Configure Apache Virtual Host
Now, let’s set up Apache on Ubuntu to serve your domain.
Step 5.1: Create the Directory
bash
sudo mkdir -p /var/www/exampledomain.com
sudo chown -R $USER:$USER /var/www/exampledomain.com
Add a sample index page:
bash
echo "<h1>Hello from Apache VPS!</h1>" | sudo tee /var/www/exampledomain.com/index.html
Step 5.2: Create the Virtual Host Config
bash
sudo nano /etc/apache2/sites-available/exampledomain.com.conf
Paste the following:
apache
<VirtualHost *:80>
ServerAdmin webmaster@exampledomain.com
ServerName exampledomain.com
ServerAlias www.exampledomain.com
DocumentRoot /var/www/exampledomain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Step 5.3: Enable the Site and Reload Apache
bash
sudo a2ensite exampledomain.com.conf
sudo systemctl reload apache2
Make sure the default site doesn’t conflict:
bash
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
🔹 Bonus: Enable HTTPS with Let’s Encrypt
Install Certbot:
bash
sudo apt update
sudo apt install certbot python3-certbot-apache
Get your SSL certificate:
bash
sudo certbot --apache -d exampledomain.com -d www.exampledomain.com
Certbot will auto-configure SSL and set up auto-renewal.
Common Issues & Fixes
ProblemLikely CauseDomain not loadingDNS not propagated yet“Site can’t be reached”Apache not configured or runningNo www versionMissing A record or ServerAlias403/404 errorsIncorrect DocumentRoot
✅ Conclusion
You’ve now pointed your domain to a VPS and configured Apache to serve it. Whether you’re launching a blog, portfolio, or web app, this setup gives you full control.
Need reverse proxy setup or multiple domains? Let me know—happy to help expand this guide!
Want this as a Markdown, PDF, or HTML file? Just say the word!