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 and ns2.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?

  • What 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.
    – slhck
    Nov 21, 2014 at 15:03

2 Answers 2


To get a website up at a domain name you need to follow these steps:

  1. Register the domain name.
  2. At the registrar, point the NameServer (NS) records to the domain name server (DNS) that will be handling the domain.
  3. On the name server, add records to resolve the host name to your server.
  4. 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:

  1. Create a directory for the files to be served /var/www/example.com and put the HTML files there.
  2. 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
  3. Enable the site: sudo a2ensite example.com
  4. Restart the webserver: sudo service apache2 restart

Look ubuntu documentation of Bind9 https://help.ubuntu.com/community/BIND9ServerHowto

  • Yes, but if I got already DNS addresses from my VPS provider should I install DNS server on my own VPS? Or just use the provided ones?
    – Rafcio Kowalsky
    Nov 21, 2014 at 14:40
  • How does this answer the question?
    – William
    Nov 21, 2014 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.