create multiple domains and subdomains with apache2

Posted on 2011-10-31
Last Modified: 2012-05-12

I'm wondering how I can create multiple domains and subdomains. I'm using Spry. They have a DomainControl Panel but doesn't seem to really work. I read that I need to create a config file in etc/apache2/sites-available and then symlink it to /etc/apache2/sites-enabled.

1) Do I create a config file for each domain and sub-domain? What do I call the config file?
2) How do I symlink the config file in sites-available to sites-enabled?
3) What are the folders sites-available and sites-enabled for? Why have 2 different folders?

Question by:Victor Kimura
    LVL 19

    Accepted Solution

    It doesn't sound very logical, but it is likely just an Apache include.  And having two folders is a good idea, because you can simply remove the symlink to disable one, but you don't have to delete the site config if you want to reenable it later.

    Try doing a generic vhost like this, but creating a text file in /etc/apache2/sites-available called "" (which is the name of the domain that you want to set up.  Replace in this config with the IP address of your server.

    DocumentRoot /path/to/your/server/root
    CustomLog /path/to/your/logdir/access_log combined
    ErrorLog /path/to/your/logdir/error_log

    Then do:

    cd /etc/apache/sites-enabled && ln -s ../sites-available/

    Be sure that and resolve to the IP address of your machine before you restart Apache, or they obviously won't work.

    Author Closing Comment

    by:Victor Kimura

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now