I'm new to Linux world and I'm getting stuck with the Apache version 2.2 Virtual host configuration.
In my local /var/www I have 2 sites (and the default localhost) in their respective directories:
/var/www/importer
/var/www/foostore
Importer is an importer for a Opencart installed into daxstore directory, which I'm developing. I want two distinct sites working so I've copied the file
/etc/apache2/sites-available/default
into the same directory two times, renaming it into "importer" and "foostore" and then edited them to:
<VirtualHost importer:80>
ServerAdmin webmaster@localhost
ServerName importer
DocumentRoot /var/www/importer/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/importer>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
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>
switching the name for the other side. I then edited /etc/hosts as follows:
127.0.0.1 localhost
127.0.1.1 VirtualHD
127.0.0.1 foostore
127.0.0.1 importer
Then I give the commands:
sudo a2ensite importer
sudo a2ensite foostore
sudo service apache2 restart
and apache goes right. When I try to access both sites, the browser redirect me on the foostore site (which also can't find some files but this is a matter for another question).
Where am I wrong?
Thank you sirs.
Best Answer
Change the
<VirtualHost>
blocks of both site configurations from<VirtualHost importer:80>
to<VirtualHost *:80>
and make sure you have the correctServerName
directive in each file. Reload Apache.If that doesn't help, check both
access.log
anderror.log
to get information about what Apache is actually doing.