I originally set my web root in /etc/apache2/sites-available/000-default.conf
to point to /home/me/www
. Due to the requirements of a new project, I need to be able to set /home/me/www/vendor/www
as its own virtual host as any local directory cruft in the request stemming from localhost/blah/blah/blah
will currently cause it to fail (the site is pretty horrible, codewise, which is why I've been contracted to work on it).
I have the following config file in my /etc/apache2/sites-available
-
project2.com.conf
:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName project2
ServerAlias localcopy
ServerRoot /home/me/www/vendor/www/
DocumentRoot /home/me/www/vendor/www/
<Directory /home/me/www/vendor/www>
Header set Access-Control-Allow-Origin "*"
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I also have the following entry in my /etc/hosts
file:
127.0.0.1 localhost
127.0.1.1 Shevat
127.0.1.2 project2.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
However, when I attempt to access project2.com
through my browser, it displays the contents of the /home/me/www
directory instead because, like I said above, I set that as my global web root in /etc/apache2/sites-available/000-default.conf
.
Is there a way to override the global web root/virtual host settings in this instance so project2.com is accessed properly?
You have to specify the full hostname when setting the ServerName parameter:
Since you left off the '.com' apache doesn't know to send you there.