3

I am setting up a small web hosting service for my clients. I have my dedicated server which will be the shared server to host clients websites using WHM/cPanel.

I have a separate VPS server that I want to use for hosting my own sites, so that in the event the shared server goes down my clients can still reach me to open tickets, etc..

I have setup my business domain name on my shared server, i created glue records within name cheap to setup ns1/ns2 so that my shared server can be reached using mydomain.com and can forward domains using ns1.mydomain.com and ns2.mydomain.com.

What I want to do now is forward www.mydomain.com and mydomain.com to my VPS so that i can use it to host my main website.

I have edited the DNS zone within WHM/cPanel to point the @ and www 'A Record' to my VPS IP address.

Now when I try to visit www./mydomain.com it shows the Apache 2 test page as if vhosts aren't working.. I have setup VPS before and never had this issue so i'm thinking either a problem with the DNS A/www records or I have missed something when configuring the VPS.

Here is my vhosts within httpd.conf: (CentOS 6.5)

      #
      # Use name-based virtual hosting.
      #
      NameVirtualHost *:80
      ...
      <VirtualHost *:80>
           ServerAdmin my@email.com
           DocumentRoot /var/www/html
           ServerName vps.mydomain.com
           ServerAlias 91.227.220.159
      </VirtualHost>

      <VirtualHost *:80>
           ServerAdmin my@email.com
           DocumentRoot /var/www/username/public_html
           ServerName www.mydomain.com
           ServerAlias mydomain.com
      </VirtualHost>

If this was working then vps.mydomain.com and server IP should show the default apache page and mydomain.com should show the site located at /var/www/username/public_html.

I appreciate this could be a hard question to answer but I am pulling my hair out, is there anything blatant obvious i could have missed?

Is the way I'm setting up the domain the best route to take? The idea is that if my clients visit me at mydomain.com they'll be taken to my website on the VPA, but they can also use ns1.mydomain.com ns2.mydomain.com to point domain to the shared server and hostname.mydomain.com for things like SSL when using IMAP, would there be a better way to achieve this? Maybe pushing domain back to Namecheap and managing DNS from there?

0

If this was working then vps.mydomain.com and server IP should show the default apache page and mydomain.com should show the site located at /var/www/username/public_html.

Correct as long as you reloaded Apache to re-read its config files.

This sounds like a DNS propagation issue to me. Check the DNS records for mydomain.com and www.mydomain.com from your local machine and from a remote machine to see if you get the same results. Then check again because checking a few times in a row can return different results if your registrar delegates to more than one NS.
See also whatsmydns.net to check DNS records from various NS around the globe.

If you're able to rule out DNS, make sure Apache read your VirtualHost block using

httpd -S

or

apache2ctl -S

You should see every value for listed with the default vhost on top:

*:80                   is a NameVirtualHost
     default server vps.mydomain.com (/etc/httpd/conf/httpd.conf:10)
     port 80 namevhost vps.mydomain.com (/etc/httpd/conf/httpd.conf:10)
     port 80 namevhost www.mydomain.com (/etc/httpd/conf/httpd.conf:20)
             alias mydomain.com

Is the way I'm setting up the domain the best route to take?

I think it's a good idea to host your client sites separate from your support/corporate. Just make sure your support site "can't" go down (e.g. geo-redundant or provider-redundant environment).

I would also steer clear of hosting your own DNS. Keeping DNS up and highly available is usually more hassle than it's worth, especially if you consider the consequences if it breaks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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