Forum Moderators: phranque
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
See the Apache Virtual Hosts documentation [httpd.apache.org].
Jim
Thanks
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.