Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vhost

Status
Not open for further replies.

dzvonyo

Technical User
Aug 4, 2008
6
NZ
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 xxx.xx.4.10/firstsite
OR
xxx.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//etc/apache2/sites-available/
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/ ServerName ServerAlias firstsite.com
#Second site
</Virtualhost>
<VirtualHost *:80>
DocumentRoot /var/ ServerName ServerAlias secondsite.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/ Options Indexes FollowSymLinks MultiViews
AllowOverride None


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

DocumentRoot /var/ ServerName ServerAlias firstsite.com

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


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

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

DocumentRoot /var/ ServerName ServerAlias secondsite.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/ 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 -rw-r--r-- 1 root root 1080 2008-08-05 09:34

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 xxx.xxxx.xxx.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
 
It doesn't look right to me. But then again, perhaps I'm being a little to picky. I don't see any directory containers defined for either DocumentRoot. Usually, it's best to have your vhosts in a file apart from httpd.conf. For example vhosts.conf then "Include" it in httpd.conf so that it gets read any time httpd.conf does. It makes it a lot easier to read if you have a few vhosts. I just copy and paste a vhost container to the end any time I want to add a new vhost and just edit the paths and server name. I don't know if it's been pointed out to you but once you start using vhosts, the server difined in the main section of httpd.conf gets ignored and the first vhost defined becomes the default. Anyway, just create a directory container for your DocumentRoots and you should be ok. If not, let us have a peek at your error log.


 
***PostRhythmAce***

With Apache2 it doesnt anything in httpd.conf, it empty but default. Checking on the net does point to configure either
-default.conf
or
-apache2.conf

Thats where I am pulling my hair now. Tried what I could think of but no luck. Any working configuration will be much appriciated.

THE error message I am getting are as follows:
[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



***elgrandeperro****

where should I be checking "missing </VirtualHost>
 
Oh, I didn't mean that the http.conf was %100 okay, just in terms of getting vhost past the "no VirtualHosts problem".

I don't know if you are missing code, but
each <Virtualhost *:80> must have a correspoding </Virtualhost > and I don't see that, I see the first one is right and the rest are undefined. (If I am reading your editing right).
 
Here is a code sample I cut & pasted from a post I did about 2 pages down. This is based on Mandrake/Mandriva, so the files are in a little different spot, but the code is the same regardless. I never went with ubuntu on my last build because I was too lazy to learn the new file layouts, but I would guess this code would go into your apache.conf (mine is httpd.conf) or your vhosts.conf file. In Mandrake/Mandriva there is an 'include' statement in the httpd.conf file telling it to include the vhosts.conf in the configuration. It keeps the configuration files much cleaner that way because all the site configuration is in one place, and all the server configuration that rarely gets touched is in another.

Irregardless... try this <snip>....

Here is a code sample. Depending on your configuration this will either go in httpd.conf or vhosts.conf. There may be some glaring security holes in here, but I'm not running anything mission critical and just wanted it to work.


<VirtualHost _default_:*>
DocumentRoot /var/</VirtualHost>

NameVirtualHost w.x.y.z

###
### Configuration for somesite.org
###

<VirtualHost w.x.y.z>
ServerName ServerAlias somesite.org
ServerPath /var/DocumentRoot /var/
DirectoryIndex index.html index.cgi index.shtml index.htm index.php index.pl
ErrorLog logs/somesiteerror.log
CustomLog logs/somesite.log combined

AddHandler cgi-script .cgi .pl

<Files *.pl>
AllowOverride None
Options +ExecCGI
Order allow,deny
allow from all
</Files>

ScriptAlias /cgi-bin/ /var/
</VirtualHost>



The 'NameVirtualHost' entry comes only once. You can repeat everything between the <VirtualHost w.x.y.z> and </VirtualHost> for as many domains as you need. w.x.y.z is always the same and is the IP of your server. If you had more than one network card and more than one IP you could set up named virtual hosts differently for each IP - just copy the whole configuration (including the NameVirtualHost) for each IP your server responds to.

Hope that helps. Sorry I made it generic - if I do have any mistakes in there I didn't want to advertise my IP or domains to the world!
 
Happy a lot for your input, much appreciated.

Resolved.....

on virtual hosts

comment
NameVirtualHost *:80

so it will look like

#NameVirtualHost *:80
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top