A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

How to create a sub-domain in Linode

Open the DNS Manager in Linode

  1. Login to Linode Members Area
  2. Go to the DNS Manager tab.
  3. Click the domain name you want to put the sub-domain to.
  4. Scroll to the middle of the page and look for the A/AAAA Records.
  5. Click on Add a new A/AAAA Record
  6. 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.
  7. For the IP Address, input the IP address of your server.
  8. Click Save.

SSH to your server

  1. SSH to your server.
  2. Once you are logged in as root, create a user called “shop” (same as your sub-domain name).
  3. Go to: /etc/apache2/sites-available OR enter this command:
    cd /etc/apache2/sites-available
  4. 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
    
  5. Copy the default file into your new sub-domain file. You can issue this command:
    cp default shop.mydomain.com
    
  6. Open up shop.mydomain.com in VI.
  7. 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
    
    
  8. 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/
    
  9. Enable the site by issuing this command:
    a2ensite shop.mydomain.com
  10. Then refresh Apache by using this command:
    /etc/init.d/apache2 reload

That’s about it.

FYI: My Linode is using Ubuntu 9.10.

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to How to create a sub-domain in Linode

  1. Daniel says:

    Thanks for the guidance. With the help of these points it became easy to make to create sub-domain.

  2. Jasmine says:

    Linode offers root access in a virtual machine, meaning lots of freedom, but also lots of tweaks. I’ve been able to do everything I’ve wanted with Linode, except for one: email.To be fair, I haven’t put much time into setting up email on Linode.przeprowadzki warszawa I followed directions posted in the Linode Library, but never got things to work. After talking with a trustworthy developer, I decided to skip hosting email at Linode and let Google deal with the mail.

  3. Wenbert says:

    Jasmine, I did the exact thing(setup email using Google Apps). Using Google apps is much more convenient than anything. I do not have to worry about disk space usage or spam.

    The only thing that scares me is when Google will try to do something “evil” with its apps.

  4. Hola, me gusta mucho su web

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>