Add domain to VPS (DNS?)
To get a website up at a domain name you need to follow these steps:
- Register the domain name.
- At the registrar, point the NameServer (NS) records to the domain name server (DNS) that will be handling the domain.
- On the name server, add records to resolve the host name to your server.
- Configure your web server to handle requests that come in for that domain name.
I never run my own name server. Third party name server service is dirt cheap and much more reliable. I wouldn't pay more than $10 per year for it. You really should have three or four name servers running in different locations for redundancy and reliability. It sounds like your web host has name servers for you to use and I would take advantage of that.
The DNS records on the name server can be either A records that list the IP address of your web server, or CNAME records pointing to another host name that you have already set up to point to your server. Your web host has a way for you to add these records. It is usually a web interface they give you in a control panel where you can create these records.
On Ubuntu, the recommend way to add Apache configuration for a website (substitute example.com
for your actual domain name) is:
- Create a directory for the files to be served /var/www/example.com and put the HTML files there.
Create /etc/apache2/sites-available/example.com.conf:
<VirtualHost *:80> Servername example.com DocumentRoot /var/www/example.com <Directory /var/www/example.com/> AllowOverride All Require all granted </Directory> </VirtualHost>
- Enable the site:
sudo a2ensite example.com
- Restart the webserver:
sudo service apache2 restart
Related videos on Youtube
Rafcio Kowalsky
Updated on September 18, 2022Comments
-
Rafcio Kowalsky over 1 year
I have a VPS and some domains. I want to add one of my domains to the VPS.
My VPS provider has send me his Nameservers like
ns1.example.com
andns2.example.com
and I changed these DNS records in my domain panel.Should I now install a DNS server on my VPS, add a record to Apache configuration file, or edit
hosts
file?The OS is Ubuntu with Apache btw.
What exactly should I do?
-
Cristian Bica over 9 yearsWhat do you mean by "add domains to the VPS"? Do you just want to point the domains to the IP of the VPS, or..? You don't need to install a DNS server.
-
-
cnayak over 9 yearsHow does this answer the question?