How to create a sub-domain in Linode
- Login to Linode Members Area
- Go to the DNS Manager tab.
- Click the domain name you want to put the sub-domain to.
- Scroll to the middle of the page and look for the A/AAAA Records.
- Click on Add a new A/AAAA Record
- In the Hostname input box, input the sub-domain you want. For example, if you want blog.mydomain.com, enter “blog” in the input box.
- For the IP Address, input the IP address of your server.
- Click Save.
SSH to your server
- SSH to your server.
- Once you are logged in as root, create a user called “shop” (same as your sub-domain name).
- Go to: /etc/apache2/sites-available OR enter this command:
cd /etc/apache2/sites-available
- If you do an
ls -la
you should see something like this:
-rw-r--r-- 1 root root 385 Apr 24 02:21 default -rw-r--r-- 1 root root 7364 Mar 9 21:19 default-ssl
- Copy the default file into your new sub-domain file. You can issue this command:
cp default shop.mydomain.com
- Open up shop.mydomain.com in VI.
- Make the new file look like this:
ServerAdmin admin@mydomain.com ServerName shop.mydomain.com ServerAlias www.mydomain.com DocumentRoot /home/shop/public_html/ ErrorLog /home/shop/logs/error.log CustomLog /home/shop/logs/access.log combined
- The next obvious thing to do is to create the directory structure found above. So just do something like this:
mkdir /home/shop/public_html/
- Enable the site by issuing this command:
a2ensite shop.mydomain.com
- Then refresh Apache by using this command:
/etc/init.d/apache2 reload