Jump to content

[SOLVED] Virtual Hosting


aurir_

Recommended Posts

I have a couple of domain names registered to me, and I use one of the features, namely URL Forwarding, to point them to my server. I also have a couple of virtual hosts defined. However, when I type in my domain names in the browser, apache always loads the default website. I did a little experiment, and I added those domains to a host file, and apache loads the correct pages. What do I have to do, so that virtual hosting works with URL forwarding? Is it even possible? Will I have to create my own DNS server, and set it as the primary DNS server for my domains(I saw that there is such an option)?

Link to comment
Share on other sites

NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName mywebsite.com
        ServerAlias *.mywebsite.com

        DocumentRoot /var/www/mywebsite
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

Link to comment
Share on other sites

There's your problem.  You need more than 1 virtual host....

 

 

 

NameVirtualHost *

<VirtualHost *>

    ServerName site1.com

    DocumentRoot /some/where/

</VirtualHost>

 

<VirtualHost *>

    ServerName site2.com

    DocumentRoot /some/where_else/

</VirtualHost>

Link to comment
Share on other sites

I do have more than one virtual host. I just posted one of my virtual hosts config since all of them look the same except the names and directories change. You see, it's an Ubuntu server, and what they did is that instead of having all of the virtual hosts defined in one file, you have one file per virtual host. You can read about it at https://help.ubuntu.com/6.10/ubuntu/serverguide/C/httpd.html

 

Besides, when I add my sites to a host file on one of the local computers, that configuration works.

Link to comment
Share on other sites

I resolved the problem.

 

The apache virtual host configuration was fine. I believe, that the URL forwarding that I had, was simply going by the IP address and not domain name.

 

So, I created my own Name Server, and registered it with my domain registrar, and it all works now.

 

Thanks for your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.