I’m moving my site from fatcow.com to linode.com because I setup VPS on linode so I’ll have more control of it. The first step is to setup name-based virtual host so that I can link my sub-domains to my “www” sub-directories.
- Create DNS records for domains and sub-domains. The IP address of sub-domains can be the same as your main domain.
- Now the world know how to resolve your domain name to an IP address, next step is to create name-based virtual host on Ubuntu server so that we can host different sites on different sub-domains. I want to create 2 sites. One is my main domain which host my blog www.ycshao.com, another one is for testing purpose image.ycshao.com.
Enable name-based virtual host on Ubuntu:
$ vim /etc/apache2/ports.conf
and add following line to the end if it’s not there
There are two folders in
/etc/apache2, which are sites-available and sites-enabled. Usually sites-enabled folder will have soft link to files in sites-available folder. The folder names are pretty obvious, “available” means available sites and “enabled” means sites which can be accessed. Let’s start from scratch.
$ cd /etc/apache2/sites-available # Go to directory
$ cp default wordpress # Make a copy of default setting file
$ vim wordpress
and modify first few lines to
The most important things are your “ServerName” corresponding to url you want to set and “DocumentRoot” corresponding to which directory this url points to. Then make a soft link to enable this site:
$ ln -s /etc/apache2/sites-available/wordpress /etc/apache2/sites-enabled/wordpress
$ service apache2 restart
Now you should be able to access www.ycshao.com and it should go to my wordpress blog sitting in /var/www/wordpress.
- Now repeat step 4 for image.ycshao.com and other sites you want to configure.