Forum Moderators: phranque

Message Too Old, No Replies

Vhost Howto on Ubuntu

         

dzvonyo1

2:09 am on Aug 5, 2008 (gmt 0)

10+ Year Member



Trying to configure Vhost on Ubuntu Server but not going well.
I can configure one site and everything work well,
as soon as I configure second site not able to access any site

using #*$!.xx.4.10/firstsite
OR
#*$!.xx.4.10/secondsite

So when configuring Vhost what should be done?
i.e
what changes should be done
/etc/apache2/sites-available/default
/etc/apache2/sites-available/www.firstsite.com
/etc/apache2/sites-available/www.second.com

OR SHOULD I be changing

etc/apache2/apache.conf

Here are my configuration where should I change
(I have just change the first part and the rest left it as default)

sudo nano /etc/apache2/sites-available/default
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/firstsite
ServerName www.firstsite.com
ServerAlias firstsite.com
#Second site
</Virtualhost>
<VirtualHost *:80>
DocumentRoot /var/www/secondsite
ServerName www.secondsite.com
ServerAlias secondsite.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None

***********
sudo nano /etc/apache2/sites-available/www.firstsite.com
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/firstsite
ServerName www.firstsite.com
ServerAlias firstsite.com

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>

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

**********
sudo nano /etc/apache2/sites-available/www.second.com
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/secondsite
ServerName www.secondsite.com
ServerAlias secondsite.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
****
/etc/apache2/sites-available# ls -l
total 12
-rw-r--r-- 1 root root 1236 2008-08-05 09:32 default
-rw-r--r-- 1 root root 1091 2008-08-05 09:28 www.firstsite.com
-rw-r--r-- 1 root root 1080 2008-08-05 09:34 www.secondsite.com

Reloading apache I got the following error

# sudo /etc/init.d/apache2 reload
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain nam
using #*$!.#*$!x.#*$!.10 for ServerName
[Tue Aug 05 09:57:01 2008] [warn] NameVirtualHost *:80 has no VirtualHosts
[Tue Aug 05 09:57:01 2008] [warn] NameVirtualHost *:80 has no VirtualHosts
[Tue Aug 05 09:57:01 2008] [warn] NameVirtualHost *:80 has no VirtualHosts

jdMorgan

1:33 pm on Aug 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As stated, you must provide a domain name for the VirtualHosts. Otherwise, a server configured as a name-based virtual server has no way of determining which 'site' it should serve content from.

See the Apache Virtual Hosts documentation [httpd.apache.org].

Jim

dzvonyo1

12:16 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



Have read the documentation suggested above, but Apache2 doesnt have httpd.conf its empty by default. Checking the net does point to changing
default.conf or apache2.conf. Thats where I am pulling my hair now. Tried what I could think of but no luck. Looking at my logs above where should I be "providing the domain name for the VirtualHosts"

Thanks

jdMorgan

3:33 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In simple terms, you cannot have all of these lines identical:

NameVirtualHost *:80
<VirtualHost *:80>

They should indicate a named domain (such as "example.com"), as described in the Apache vHosts documentation.

Jim

encyclo

3:45 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In Ubuntu, you don't need to touch the main configuration files to set up virtual hosts.

From the example above, you seem to have added the virtual hosts in the "default" file - they shouldn't be there. The default is for the main site which is served when accessing via the IP address without entering a domain name. It is not a virtual host as such. Only the "default" virtual host includes the

NameVirtualHost *
directive.

Then you create a new file for each virtual host in

/etc/apache2/sites-available/
- a very basic example would be:

<VirtualHost *>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /home/example/public_html
</VirtualHost>

Once that has been done, you must create a symlink from

/etc/apache2/sites-available/sitename
in
sites-enabled
:

cd ../sites-enabled/
ln -s /etc/apache2/sites-available/sitename sitename

Or you can use the command

a2ensite sitename
instead or manually symlinking. You will need to restart Apache.

dzvonyo1

10:51 pm on Aug 13, 2008 (gmt 0)

10+ Year Member



Resolved.....

on virtual hosts

comment
NameVirtualHost *:80

so it will look like

#NameVirtualHost *:80