0

I want to transfer my website (let's say www.mydomain.com), which is currently running on a shared hosting, to my VPS server, which I recently bought.

I created a domain in the DirectAdmin of my VPS server, with the same name as the domain name which is currently running on the shared hosting (www.mydomain.com). Now I uploaded the website and database to this domain on my VPS, and it is working correctly.

Now, I only need to change de DNS from my current shared hosting to this VPS. But here's where it gets a bit confusing for me.

Let's say the VPS server has the IP address 12.12.12.12. Then the domain which I created via the DirectAdmin is running on 12.12.12.12/~admin/. I already created a DNS A record (server.mydomain.com) on my sharedhosting, which is pointing to the IP address of the server. But when I try to reach this record, it doesn't show me the website but only 'Apache is functionating normally'.

Now, what do I have to change in my DNS settings to have the domain pointing to the website which is running on my VPS server (12.12.12.12/~admin/)?

Tomzie
  • 121
  • 3

1 Answers1

1

By making an A record for www.mydomain.com to point to 12.12.12.12 you've only achieved the goal of making web requests reach the server. The server needs to be configured to take requests to the Host: www.mydomain.com and serve them up from your ~/admin folder.

There are (at least) two ways you can accomplish this, really.

  1. If this is the only webapp you'll host from the server, you can change your doc root on the VPS's webserver (you haven't told us which it is so I can't give more detail) to point to where "/~admin/" resides.

EDIT: Here's how you can change the docroot - it was already asked in stackoverflow: https://stackoverflow.com/q/5891802/708198

  1. If you have multiple web apps, or don't wish to change the default docroot for whatever reason, you need to create a virtual host for the domain. You can easily find information on the internet for virtualhost setup for whatever webserver you're using on the VPS.

Typically, on apache you can do it like this. Please don't copy/paste this blindly, I quickly drew this from my own webserver:

Set the default vhost:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
    DocumentRoot "/path/to/docroot"
    ServerName hostname.mydomain.com
        <Directory "/path/to/docroot">
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
    </Directory>
    ErrorLog "/var/log/apache/httpd-default-error.log"
    CustomLog "/var/log/apache/httpd-default-access.log" combined
</VirtualHost>

followed by

<Virtualhost *:80>
    ServerAdmin webmaster@mydomain.com
    DocumentRoot "/path/to/webapp/admin/"
    ServerName www.mydomain.com
    ServerAlias mydomain.com
<Directory "/path/to/webapp/admin/">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymlinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
    ErrorLog /var/log/www.mydomain.com/httpd-error.log
    CustomLog /var/log/www.mydomain.com/httpd-access.log combined
</Virtualhost>
sandroid
  • 1,724
  • 12
  • 16
  • Thanks a lot! I guess I will change the doc root on my VPS then, since it is the only webapp which will be running on the VPS. Where can I change this exactly? – Tomzie Nov 23 '13 at 14:28
  • @tomzie I edited my response , take a look – sandroid Nov 24 '13 at 16:06