View previous topic :: View next topic |
Author |
Message |
marxin n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 28 Oct 2005 Posts: 28
|
Posted: Mon Aug 04, 2008 6:13 pm Post subject: Apache virtual hosts |
|
|
I'm trying to run 2 name-based virtual hosts on my Gentoo box, but I'm not succesfull.
/etc/conf.d/apache2
Code: |
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D PHP5 -D SSL_DEFAULT_VHOST"
|
00_marxin.eu_vhost.conf
Code: |
<IfDefine DEFAULT_VHOST>
Listen 80
NameVirtualHost *:80
<VirtualHost marxin.eu>
ServerName marxin.eu
ServerAlias www.marxin.eu
Include /etc/apache2/vhosts.d/marxin.eu_vhost.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
</IfDefine>
|
00_gameground.cz_vhost.conf
Code: |
<IfDefine DEFAULT_VHOST>
Listen 80
NameVirtualHost *
<VirtualHost gameground.cz>
ServerName gameground.cz
ServerAlias www.gameground.cz
Include /etc/apache2/vhosts.d/gameground.cz_vhost.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
</IfDefine>
|
/etc/hosts
Code: |
127.0.0.1 localhost
77.48.17.118 marxin.eu
77.48.17.118 gameground.cz
::1 localhost
|
ifconfig
Code: |
eth0 Link encap:Ethernet HWaddr 00:16:17:81:71:87
inet addr:77.48.17.118 Bcast:77.48.17.119 Mask:255.255.255.252
inet6 addr: fe80::216:17ff:fe81:7187/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17127 errors:0 dropped:0 overruns:0 frame:0
TX packets:18708 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1769390 (1.6 Mb) TX bytes:2786294 (2.6 Mb)
Interrupt:23 Base address:0xc800
|
/etc/init.d/apache2 start
Code: |
* Caching service dependencies ... [ ok ]
* Starting apache2 ...
apache2: apr_sockaddr_info_get() failed for marxin_server
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Mon Aug 04 20:12:50 2008] [warn] VirtualHost marxin.eu:0 overlaps with VirtualHost gameground.cz:0, the first has precedence, perhaps you need a NameVirtualHost directive
[Mon Aug 04 20:12:50 2008] [warn] NameVirtualHost *:0 has no VirtualHosts
[Mon Aug 04 20:12:50 2008] [warn] NameVirtualHost *:80 has no VirtualHosts
(98)Address already in use: make_sock: could not bind to address [::]:80
|
Thanks for your advices, marxin |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
FlorianSchmidt Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/9672126194892b672cc6b5.jpg)
Joined: 20 May 2008 Posts: 77 Location: Germany
|
Posted: Tue Aug 05, 2008 10:46 am Post subject: |
|
|
In 00_marxin.eu_vhost.conf change
Code: | NameVirtualHost *:80 |
into
(This is more or less just a suggestion)
and
Code: | <VirtualHost marxin.eu> |
into:
because of http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost
in 00_gameground.cz_vhost.conf delete
Code: |
Listen 80
NameVirtualHost *
|
You must not have more than one "Listen 80" in your whole apache configuration and you only need to define "NameVirtualHost" once, at least for what it looks like you are planning to do.
And change
Code: | <VirtualHost gameground.cz> |
into
So much for the apache stuff, lets have a look if that helps.
In general, if you really want to divide the configuration into seperated files, you should place the NameVirtualHost and Listen directives in your "main" configuration file, because they have a more general meaning. Sometimes there is also a listen.conf for the Listen directive exclusive, I think debian is doing it that way... Hmm, at this point I must admit that I have no idea how gentoo is doing it, anyway the suggestions made above will work. _________________ -bash: :wq: command not found |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
kashani Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/9629732313ee51df8c5935.jpg)
Joined: 02 Sep 2002 Posts: 2032 Location: San Francisco
|
Posted: Tue Aug 05, 2008 5:26 pm Post subject: |
|
|
You've got too many Listen statements. Here's how I set mine up. First off I generally leave the default installed Gentoo default_vhost and defualt.vhost.include files alone. I don't care about traffic that hits my server without specifying a domain name and rather it just hits a blank vhost.
/etc/apache2/vhosts.d/00_default_vhost.conf Code: |
<IfDefine DEFAULT_VHOST>
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
Include /etc/apache2/vhosts.d/default_vhost.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
</IfDefine> |
Now I start defining my vhosts. No Listen statements, not NameVirtualHost, etc because you've already entered all that in the default_vhost.conf.
/etc/apache2/vhosts.d/badapple.net.conf Code: |
<VirtualHost *:80>
ServerName badapple.net
ServerAlias www.badapple.net
ServerAdmin webmaster@badapple.net
DocumentRoot /var/www/badapple.net/htdocs
CustomLog /var/log/apache2/badapple.net.access.log combined
ErrorLog /var/log/apache2/badapple.net.error.log
# PHP tweaks
php_value post_max_size 104857600
php_value upload_max_filesize 104857600
<Directory "/var/www/badapple.net/htdocs">
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</VirtualHost> |
You can continue to define the DEFAULT_VHOST stuff in each vhost you create, but generally I assume I want all my vhosts all the time.
kashani _________________ Will personally fix your server in exchange for motorcycle related shop tools in good shape. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
leonardosam n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/290842468474db03be6956.jpg)
Joined: 28 Nov 2007 Posts: 10 Location: Campinas, Brazil
|
Posted: Thu Dec 11, 2008 11:29 pm Post subject: Same problem here |
|
|
Hey guys,
I'm running into the same stupid problem here and can't find where the problem is. I have tried many suggestions and none seemed to work. I have a default host in www.x.com and the one that I want to work under /home/user/public_html is www.y.com , however, whenever I try to open www.y.com , I end up at www.x.com
It is driving me crazy.
Here's my configuration:
/etc/conf.d/apache2
Code: | APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D MAILMAN -D USERDIR -D STATUS" |
/etc/apache2/httpd.conf
Code: |
Include /etc/apache2/vhosts.d/*.conf |
/etc/apache2/vhosts.d/00_default_vhost.conf
Code: | <IfDefine DEFAULT_VHOST>
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName x.com
ServerAlias www.x.com
Include /etc/apache2/vhosts.d/default_vhost.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
</IfDefine> |
/etc/apache2/vhosts.d/01_y_com.conf
Code: | <IfDefine DEFAULT_VHOST>
<VirtualHost *:80>
ServerName y.com
ServerAlias www.y.com
DocumentRoot /home/user/public_html
</VirtualHost>
</IfDefine> |
Plus, I have modules alias and virtualhost_alias loaded.
Everything seems to be okay, right? What the heck is going on in here anyway?
I would appreciate any support. Thank you. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
cach0rr0 Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
![](images/avatars/14936637654ee19d6630f96.gif)
Joined: 13 Nov 2008 Posts: 4123 Location: Houston, Republic of Texas
|
Posted: Sun Dec 14, 2008 10:52 pm Post subject: |
|
|
@leonardosam
I don't see anywhere that your y.com vhost is actually configured to use that .conf file
I only see default_vhost.include
Here is how I have mine set up, which works
00_default_vhost.conf snippet:
Code: |
<IfDefine DEFAULT_VHOST>
Listen 80
# Use name-based virtual hosting.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mydomain.com
Include /etc/apache2/vhosts.d/default_vhost.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
<VirtualHost *:80>
ServerName eu.mydomain.com
Include /etc/apache2/vhosts.d/eu_vhost.include
php_admin_value session.save_path "/var/www/eu/tmp"
php_admin_value file_uploads off
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
|
Notice the Include statement in the second block? and of course, snippet of eu_vhost.include
Code: |
DocumentRoot "/var/www/eu/htdocs"
<Directory "/var/www/eu/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
|
note that when you include all *.conf in your main httpd.conf is going to be out of whack with your file named as it is. You need apache to include that config in a very specific place, so you use the Include directive as I have above.
hope that helps |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
cach0rr0 Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
![](images/avatars/14936637654ee19d6630f96.gif)
Joined: 13 Nov 2008 Posts: 4123 Location: Houston, Republic of Texas
|
Posted: Sun Dec 14, 2008 11:02 pm Post subject: |
|
|
sorry for the double post, im watching the game and distracted
So, first and foremost, let's rename that file
Code: |
mv /etc/apache2/vhosts.d/01_y_com.conf /etc/apache2/vhosts.d/01_y_com.include
|
then change your 00_default_vhost.conf to be like so:
Code: |
<IfDefine DEFAULT_VHOST>
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName x.com
ServerAlias www.x.com
Include /etc/apache2/vhosts.d/default_vhost.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
<VirtualHost *:80>
ServerName y.com
ServerAlias www.y.com
Include /etc/apache2/vhosts.d/01_y_com.include
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
</IfDefine>
|
Then change 01_y_com.include like so:
Code: |
DocumentRoot "/home/user/public_html"
<Directory "/home/user/public_html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
|
restart apache and see how you go |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
leonardosam n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/290842468474db03be6956.jpg)
Joined: 28 Nov 2007 Posts: 10 Location: Campinas, Brazil
|
Posted: Sun Dec 14, 2008 11:24 pm Post subject: Corrected |
|
|
Everything was fine regarding the configuration. I was trying to setup the vhost without any further configuration first. The problem is that Apache does not accept to have virtual hosts under a public_html (~username) directory.
It is now running sound and smoothly. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|