PDA

View Full Version : NameVirtualHost www.mysite.it has no VirtualHosts


gabrix
1st February 2007, 11:29
I have 3 virtualhosts on an apache2 running on a debian 2.6.8 stable . I don't understand why the site still being reachable , when i restart apache2 , it shows this error:
root@www:~# /etc/init.d/apache2 restart
Forcing reload of web server: Apache2[Thu Feb 01 10:13:45 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
[Thu Feb 01 10:13:45 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
It happens only for the site above , and all sites have same virtualhost in pache2.conf and dir /etc/apache2/sites-enabled here the apache2.conf:
<VirtualHost tor.gabrix.ath.cx>
ServerName tor.gabrix.ath.cx
ServerAlias tor.gabrix.cx
ServerAdmin gabrix@gabrix.ath.cx
DocumentRoot /var/www/torgab
ErrorLog /var/log/apache2/tor_error.log
TransferLog /var/log/apache2/tor_access.log
<IfModule mod_security.c>
CustomLog /var/log/apache2/tor_modsec_custom_log \
"%h %l %u %t \"%r\" %>s %b %{mod_security-message}i" \
env=mod_security-relevant
</IfModule>
</VirtualHost>

<VirtualHost www.gabrix.ath.cx>
ServerName www.gabrix.ath.cx
ServerAlias www.gabrix.cx
ServerAdmin gabrix@gabrix.ath.cx
DocumentRoot /var/www/gabrix
ErrorLog /var/log/apache2/gabrix_error.log
TransferLog /var/log/apache2/gabrix_access.log
<IfModule mod_security.c>
CustomLog /var/log/apache2/gabrix_modsec_custom_log \
"%h %l %u %t \"%r\" %>s %b %{mod_security-message}i" \
env=mod_security-relevant
</IfModule>
</VirtualHost>

<VirtualHost x.gabrix.ath.cx>
ServerName x.gabrix.ath.cx
ServerAlias x.gabrix.cx
ServerAdmin gabrix@gabrix.ath.cx
DocumentRoot /var/www/ics
ErrorLog /var/log/apache2/x_error.log
TransferLog /var/log/apache2/x_access.log
<IfModule mod_security.c>
CustomLog /var/log/apache2/x_modsec_custom_log \
"%h %l %u %t \"%r\" %>s %b %{mod_security-message}i" \
env=mod_security-relevant
</IfModule>
</VirtualHost>
And this is the /etc/apache2/sites-enabled/ics file:
NameVirtualHost x.gabrix.ath.cx
<VirtualHost x.gabrix.ath.cx>
ServerAdmin webmaster@gabrix.ath.cx

DocumentRoot /var/www/ics
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from 127.0.0.1/8
allow from 192.168.1.0/29
deny from all
</Directory>
<Directory /var/www/ics/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
</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/x_error.log

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

CustomLog /var/log/apache2/x_access.log combined
ServerSignature Off

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>
This morning i added the first page of content and i had back a "page not found" but maybe it's an another issue .
ciao.

falko
2nd February 2007, 14:34
NameVirtualHost x.gabrix.ath.cx
NameVirtualHost must be followed by an IP address, not an FQDN.

gabrix
2nd February 2007, 19:58
Why x.gabrix.ath.cx is the only between them 3 to have an ip ? Anyway didn't work like this either ...
root@www:~# apache2ctl restart
[Fri Feb 02 18:56:16 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
root@www:~# apache2ctl restart
[Fri Feb 02 18:56:19 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts

falko
3rd February 2007, 15:36
You must change all NameVirtualHost directives. Each of them must take an IP address.

gabrix
4th February 2007, 06:50
Forgive me i changed configuration in all possible maners, but i don't manaage to get it to work.Where should the ip go in the apache2.conf file or sites-enabled dir ?
root@www:~# /etc/init.d/apache2 restart
Forcing reload of web server: Apache2[Sun Feb 04 05:44:03 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
[Sun Feb 04 05:44:04 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts
Ho i sould i configure the default virtualhost ? with a * or ip ?And where does the NameVirualHost directive go ?

martinfst
4th February 2007, 13:19
You should update both NameVirtualHost and VirtualHost. You can use a *, and as such it will be active for every IP on your system, of you can use a single IP, in which case the block is only valid for that IP address NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options None
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options None
#Options Indexes FollowSymLinks MultiViews
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<snipped rest of file>

gabrix
4th February 2007, 16:10
That's how i have set the 3 virtualhost on my apache2
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@gabrix.ath.cx

DocumentRoot /var/www/torgab
NameVirtualHost 192.168.1.4
<VirtualHost 192.168.1.4>

NameVirtualHost 192.168.1.4
<VirtualHost 192.168.1.4>
And i keep on getting this error:
root@www:~# apache2ctl restart
[Sun Feb 04 15:02:00 2007] [warn] NameVirtualHost 192.168.1.4:0 has no VirtualHosts
Do i have to name also the port it listen to ?Is it because the default virtualhost has to be mensioned explicitly ?
Still with yhe default virtualhost on *.
NameVirtualHost x.gabrix.ath.cx
<VirtualHost x.gabrix.ath.cx>
NameVirtualHost www.gabrix.ath.cx
<VirtualHost www.gabrix.ath.cx>
I get the error:
root@www:~# apache2ctl restart
[Sun Feb 04 15:13:41 2007] [warn] NameVirtualHost x.gabrix.ath.cx:0 has no VirtualHosts

martinfst
4th February 2007, 16:51
Maybe you're making the modifications to the config file apache2 is not using? See httpd -Vfor the initial config file and work from there.

gabrix
5th February 2007, 02:59
What's that httpd -V it is apache2 in charge ....

martinfst
5th February 2007, 09:37
Yes, and httpd is the name of the Apache(2) program actually running. You will see when you execute the command.

falko
5th February 2007, 13:42
And i keep on getting this error:

root@www:~# apache2ctl restart
[Sun Feb 04 15:02:00 2007] [warn] NameVirtualHost 192.168.1.4:0 has no VirtualHosts
That warning is ok, it just means that there is no virtual host on the IP address 192.168.1.4.

gabrix
5th February 2007, 21:16
My virtual hosts are configured just like as you see in my first post and instead of fqdn there are ips as you sayd so it's not ok !!!
root@www:~# httpd -V
bash: httpd: command not found

martinfst
5th February 2007, 22:35
So what's the output of apache2ctl -V then?

gabrix
6th February 2007, 11:29
This has worked :
root@www:~# apache2ctl -V
Server version: Apache/2.0.54
Server built: Jul 28 2006 09:04:55
Server's Module Magic Number: 20020903:9
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT=""
-D SUEXEC_BIN="/usr/lib/apache2/suexec2"
-D DEFAULT_PIDLOG="/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

martinfst
6th February 2007, 12:12
So you use -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"for you config file. Good. In your 1st post you showed us (part of?) this file. Can you check if you have a line reading
Include /etc/apache2/sites-enabled/[^.#]*in this apache2.conf file?

gabrix
6th February 2007, 15:32
Here it is:
Include /etc/apache2/sites-enabled/[^.#]*
And this is the virtualhost file:
NameVirtualHost 192.168.1.4
<VirtualHost 192.168.1.4>
ServerAdmin webmaster@gabrix.ath.cx

DocumentRoot /var/www/ics
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from 127.0.0.1/8
allow from 192.168.1.0/29
deny from all
</Directory>
<Directory /var/www/ics/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
</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/x_error.log

falko
7th February 2007, 19:32
What exactly is the problem right now? Don't your sites work now?

frgomes
21st February 2007, 16:37
If you are behind a NAT/firewall, probably your webserver has a local IP address (probably 192.168.xxx.xxx) and your router/firewall is responsible for forwarding incoming requests to your webserver.

In this situation, you have a public IP address for your www.yourdomain.com but, in fact, Apache has to accept requests in your local interface instead of your public IP address (assigned to your router/firewall in fact).

Try something like this in your /etc/hosts:



127.0.0.1 localhost

# these lines MUST be kept otherwise Apache2 fail serving these addresses
192.168.1.2 subdomain11.yourdomain1.com
192.168.1.2 subdomain12.yourdomain1.com
192.168.1.2 subdomain13.yourdomain1.com
192.168.1.2 subdomain21.yourdomain2.com
192.168.1.2 subdomain22.yourdomain2.com
192.168.1.2 subdomain23.yourdomain2.com


# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


Enjoy :-)

gabrix
8th March 2007, 20:49
I have done this the problem remains !!!!

tftd
23rd March 2007, 01:11
Hello there ..
I have the same problem. I'm reading almost everything in the network about it and still under apache 1.3.37 it doesn't work.

My NameVirtualHost is the IP of the machine. For example

NameVirtualHost 123.123.123.123:80

<VirtualHost 123.123.123.123:80>
Documen Root /somewhere/subdomain
ServerName www.subdomain.mydomain.com
ErrorLog logs/bla.error_log
</VirtualHost>


And I get the error:

[Fri Mar 23 02:25:42 2007] [warn] NameVirtualHost 123.123.123.123:80 has no VirtualHosts
/usr/local/apache/bin/apachectl start: httpd started

falko
23rd March 2007, 19:27
My NameVirtualHost is the IP of the machine. For example

NameVirtualHost 123.123.123.123:80

<VirtualHost 123.123.123.123:80>
Documen Root /somewhere/subdomain
ServerName www.subdomain.mydomain.com
ErrorLog logs/bla.error_log
</VirtualHost>

For Apache 1.3, it must be like this:

NameVirtualHost 123.123.123.123

<VirtualHost 123.123.123.123>
Documen Root /somewhere/subdomain
ServerName www.subdomain.mydomain.com
ErrorLog logs/bla.error_log
</VirtualHost>