I've created two virtual hosts. tester.ly and tucnak.me
/sites-available/Lab:
<VirtualHost tucnak.me:80>
ServerAdmin kovalevskiy11#gmail.com
ServerName tucnak.me
DocumentRoot /home/tucnak/Web/Lab/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/tucnak/Web/Lab/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
#... here smth skipped.
</VirtualHost>
And /sites-available/Tester:
<VirtualHost tester.ly:80>
ServerAdmin kovalevskiy11#gmail.com
ServerName tester.ly
DocumentRoot /home/tucnak/Web/Tester/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/tucnak/Web/Tester/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# skipped too.
</VirtualHost>
And my apache2 output:
[Mon Feb 13 20:17:07 2012] [warn] VirtualHost tucnak.me:80 overlaps with VirtualHost tester.ly:80, the first has precedence, perhaps you need a NameVirtualHost directive
I think that smthing wrong directive cause this problem. So, I need help.
You may have a NameVirtualHost *:80 or NameVirtualHost * directive in your configuration.
This mean your starting VirtualHost directives should be:
<VirtualHost *:80>
(...)
<VirtualHost *:80>
(...)
And not :
<VirtualHost tester.ly:80>
(...)
<VirtualHost tucnak.me:80>
(...)
The name of the VirtualHost is given by the ServerName directive inside the VirtualHost, not by the name used in the <VirtualHost xxx>. And this xxx should match one of the NameVirtualHost declarations in main configuration.
Related
My configuration :
Wampserver 3.0.0 32bits
Apache 2.4.17
php 5.6.15
mysql 5.7.9
My problem :
WampServer start properly, but when I try to access a project in the log i have:
[Sat May 21 10:55:39.393866 2016] [authz_core:error] [pid 6984:tid 1140] [client 127.0.0.1:50070] AH01630: client denied by server configuration: C:/wamp/www/project/api/app/
[Sat May 21 10:55:39.395878 2016] [authz_core:error] [pid 6984:tid 1140] [client 127.0.0.1:50070] AH01630: client denied by server configuration: C:/wamp/www/project/api/src/
Yet I check my configuration files and all seems OK.
There are my configs files :
httpd.conf :
<Directory "C:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org]
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
#onlineoffline tag - don't remove
#Require local
Require all granted
</Directory>
httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin admin#test.fr
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
ServerName localhost.project.com
#ServerAlias localhost.project.com
DocumentRoot "C:/wamp/www/project/website/web/"
<Directory "C:/wamp/www/project/website/web/">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/project/api"
ServerName api.project.com
#ServerAlias api.project.com
<Directory "C:/wamp/www/project/api">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/Demo_websocket/web"
ServerName demo.websocket
#ServerAlias demo.websocket
<Directory "C:/wamp/www/Demo_websocket/web">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
My hosts file :
I think I do not understand very well what you mean. The content of my
hosts file is :
127.0.0.1 localhost
127.0.0.1 api.project.com
127.0.0.1 localhost.project.com
I already tried to set Require all granted in VirtualHost but no success :s
If someone has already faced this problem and found a solution , I'm interested. Thank you
you are using localhost with virtual hosting,
if this is your hosts file, it is correct
127.0.0.1 localhost
127.0.0.1 api.project.com
127.0.0.1 localhost.project.com
and in your local browser you'll write one of these urls.
But your virtual host configuration must respond to a specific host and not to *, for example fo api you must have <VirtualHost api.project.com:80> and not <VirtualHost *:80>
also the generic * virtual host MUST be at the end of the list, then the result is:
<VirtualHost localhost.project.com:80>
ServerAdmin admin#test.fr
ServerName localhost.project.com
#ServerAlias localhost.project.com
DocumentRoot "C:/wamp/www/project/website/web/"
<Directory "C:/wamp/www/project/website/web/">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost api.project.com:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/project/api"
ServerName api.project.com
#ServerAlias api.project.com
<Directory "C:/wamp/www/project/api">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost demo.websocket:80>
ServerAdmin admin#test.fr
DocumentRoot "C:/wamp/www/Demo_websocket/web"
ServerName demo.websocket
#ServerAlias demo.websocket
<Directory "C:/wamp/www/Demo_websocket/web">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.fr
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
<Directory "C:/xampp/htdocs/">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/gl"
ServerName gl.dev
<Directory "C:/xampp/htdocs/gl">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
The above is what I currently have in my vhosts file. When I hit localhost I want my root to open, but when I load gl.dev I want the individual site to open. Any ideas?
hosts file:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 gl.dev
I think in windows you have to use backslash when specifying document root. please try the following
<VirtualHost *:80>
ServerName localhost
ServerAlias *.localhost
DocumentRoot "C:\xampp\htdocs\"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gl.dev
ServerAlias *.gl.dev
DocumentRoot "C:\xampp\htdocs\gl"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Restart WAMP server
OK, so, I think the title is rather self-explanatory.
I've set up my own Apache server (on Debian) and hosting 2 different sites (let's say mysite1.com at /home/www/mysite1, and mysite2.com at /home/www/mysite2).
In my domain name registrar setup page (Dynadot actually), I created A records (still not sure what this is exactly...) for both of them, pointing to my server's ip...
Now, on the server's side, here'e what my .conf file looks like (/etc/apache2/sites-enabled/mysite actually)
<VirtualHost *:80>
DocumentRoot /home/www/mysite1.com
ServerName www.mysite1.com
ServerAdmin drkameleon#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/www/mysite1.com>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin
<Directory "/home/www/mysite1.com/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /home/www/phpmyadmin
ServerName www.mysite1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/www/mysite2.com
ServerName www.mysite2.com
ServerAdmin drkameleon#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/www/mysite2.com>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Now, the thing is. Now matter which site I visit (1 or 2), I always get mysite1's contents.
What am I doing wrong? Any ideas?
There are multiple possibilities of what could go wrong.
Do you have
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
somewhere in the config? (http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost)
Without that config entry Apache is not sensitive to domain names in dispatching requests to virtual hosts.
It's just a guess.
Make sure Apache has been reloaded after any changes to the config!
hello i have 2 domains domain1.com,domain2.com
both are in the same server under domain1.com
i want to set the VirtualHost to handle them both
like this:
<VirtualHost domain1.com:80>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost domain2.com:80>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>.
but for some reason the server send me only to the first one
i also tryed it like this
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>.
anyone have any idea how to fix this problem ?
I think you are missing the NameVirtualHost directive.
NameVirtualHost *:80
<VirtualHost *>
DocumentRoot /var/www/html
ServerName domain1.com
<Directory /var/www/html>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/domain2
ServerName domain2.com
<Directory /var/www/domain2>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
Without it your first VirtualHost will be used for all access when using name-based virtual hosting.
I am trying to set up a dynamic vHost, but have run into some trouble. It will not allow me to set multiple ServerAlias.
<VirtualHost *:80>
ServerAlias *.com
ServerAdmin michael.ian.curry#gmail.com
VirtualDocumentRoot /var/www/%1/production/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
The above vHost only works for '.com' i need it to work for 'www..com' and '*.com'
I assumed that setting the ServerAlias to would fix it, but it is not working.
ServerAlias *.com www.*.com
If you have any insight, please respond
--MichaelCurry
==EDIT 1==
Example redcrusher.com and www.redcrusher.com
==EDIT 2==
The code below does not work either
ServerAlias www.*.com *.com
Figured it out!
'www.*.com' must execute before '*.com' This is because ServerAlias is setting a dynamic domain and must exist before a "smaller" alias exists.
Example: 'www.*.com', 'dev.*.com', 'asdf.*.com' THEN '*.com'
vHost File [production.conf]:
<VirtualHost *:80>
ServerAlias www.*.com
VirtualDocumentRoot /var/www/%2/production/html
ServerAdmin michael.ian.curry#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
<VirtualHost *:80>
ServerAlias *.com
VirtualDocumentRoot /var/www/%1/production/html
ServerAdmin michael.ian.curry#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
I hope this helps anyone else that is having this problem!
--MichaelCurry
you must use like this
ServerAlias www.domain.com domain.com
ServerAlias *.domain.com
if You want use That Way You Must Follow Order
ServerAlias www.*.com *.com
the problem is of
VirtualDocumentRoot /var/www/%1/production/html
you Use a Dynamic VirtualDocumentRoot that mean
for redcrusher.com VirtualDocumentRoot is
/var/www/redcrusher/production/html
and for www.redcrusher.com VirtualDocumentRoot is
/var/www/www.redcrusher/production/html
I think with split ServerAlias in Three part it solve
ServerAlias www.*.com
VirtualDocumentRoot /var/www/%1/production/html/
ServerAlias *.*.com
VirtualDocumentRoot /var/www/%2/production/html/%1
ServerAlias *.com
VirtualDocumentRoot /var/www/%1/production/html
i think should Work
VirtualDocumentRoot :
redcrusher.com
/var/www/redcrusher/production/html
www.redcrusher.com
/var/www/redcrusher/production/html/
sub.redcrusher.com
/var/www/redcrusher/production/html/sub