thecodejack
thecodejack

Reputation: 13379

More than one virtual host in Apache2 Ubuntu

I have tried to configure a new virtual host in apache. I have copied the default. Updated the paths. The conf looks like this

    <VirtualHost *:8081>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/ubuntu/video
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/ubuntu/video>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                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 /home/ubuntu/video/error.log

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

        CustomLog /home/ubuntu/video/access.log combined

    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>

I ran the command

sudo a2ensite video

which gave messaage that virtual host successfully added and will run upon reload. But i am not able to access the same. I have checked the path /home/ubuntu/video where error.log, access.log files are also created. I am not able to find the solution as well as problem. I searched in the internet if anyone have same problem.

The following blog post: Adding virtual hosts to Ubuntu Apache, says in its update the we cannot create more than one virtual host. I have already a virtual host installed. Does this mean 2nd virtual host cannot be configured in Ubuntu for apache?

Upvotes: 1

Views: 3994

Answers (1)

Grzegorz Grzybek
Grzegorz Grzybek

Reputation: 6237

Read these instructions.

If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.

So make sure you have these directives outside the <VirtualHost> tag:

Listen 8081
NameVirtualHost *:8081

You can also add:

ServerName www.example.com

to your VirtualHost section.

Upvotes: 2

Related Questions