Announcement

Collapse
No announcement yet.

How can I setup multiple sites

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can I setup multiple sites

    Hello,
    I have successfully setup MYSQL, Apache2, and PHP on my laptop.
    I have successfully setup www.site3.com on my computer.

    However, I cannot setup site2 or site1. They all point to the same site.
    Pinging all three sites gives the same response: 127.0.0.1

    Here is the error message I get when I reload Apache:
    Code:
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    [Tue Aug 17 17:51:50 2010] [warn] VirtualHost site1.com:0 overlaps with VirtualHost site2.com:0, the first has precedence, perhaps you need a NameVirtualHost directive
    [Tue Aug 17 17:51:50 2010] [warn] VirtualHost site3.com:0 overlaps with VirtualHost site1.com:0, the first has precedence, perhaps you need a NameVirtualHost directive
    Here is a snippet from the /etc/hosts file:
    Code:
    127.0.0.1    localhost    site3.com    site2.com    site1.com
    127.0.1.1    ryy
    Here is config file for a single site:
    Code:
    <VirtualHost site1.com>
    ServerAdmin webmaster@localhost
    #We want to be able to access the web site using [url]www.dev.example.com[/url] or dev.example.com
    ServerAlias site1.com
    DocumentRoot /home/ryy/Sites/public_html/site1.com
    #if using awstats
    ScriptAlias /awstats/ /usr/lib/cgi-bin/
    #we want specific log file for this server
    CustomLog /var/log/apache2/example.com-access.log combined
    </VirtualHost>
    Has anyone run into this problem before?

    Is NameVirtualHost directive the way to go? What changes do I need to make to implement it?
    Many thanks in advance for your help.

    #2
    Re: How can I setup multiple sites

    I recommend you have a look at the Apache2 documentation.
    I'll give you what information I have because my home server works like a charm.
    However I'm a newbie at this, so take the information with a grain of salt.

    The files are for my server which has a pile of sites on it, so I'll give you just the
    first part. The names are what I'm using, change to suit. I'm assuming your sites
    are also on the same IP.

    Your /etc/hosts file shouldn't be involved unless you want to put an alias in it
    like this:
    Code:
     192.168.1.111 CCB CCB
    You add new sites to: /etc/apache2/sites-available/sitename
    and /etc/apache2/httpd.conf

    My httpd.conf looks like this:
    Code:
    ServerName CCB.cgs
    
    NameVirtualHost 192.168.1.111
    
    <VirtualHost 192.168.1.111>
    ServerName CCB
    DocumentRoot /home/www
    </VirtualHost>
    
    <VirtualHost 192.168.1.111>
    ServerName holyrood.cgs
    DocumentRoot /var/www/sites/holyrood.cgs
    </VirtualHost>
    
    <VirtualHost 192.168.1.111>
    ServerName site.cgs
    DocumentRoot /var/www/sites/site.cgs
    </VirtualHost>
    
    etc.
    The /etc/apache2/sites-available directory should contain a file for each site
    which starts like this:
    Code:
    # NameVirtualHost *
    <VirtualHost *>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/sites/holyrood.cgs/
    
    etc.
    Note that the first line is commented out. IIRC that is where that error message comes from.

    You have to set up symlinks to sites-enabled. However there is a nice utility for
    doing that quickly. To set up a link type: a2ensite
    To remove a link type: a2dissite
    This way it is quick to take sites offline and on again as required.

    I hope this helps.

    BTW, I'm using carriage returns in this post so that it won't go off the screen. (hint)

    Comment

    Working...
    X