Tag Archives: virtualhost

Hosting multiple websites with Apache2

http://www.debian-administration.org/articles/412
http://fob.po8.org/node/289

If you are running multiple websites with Apache2 with mixed ports (usually http port 80, https port 443) change following configuration files. Variable NameVirtualHost should be only in file virtual.conf, find and comment it in other configuration files!

FOB: I recently reported being stuck trying to set up multiple SSL name-based virtual hosts on the same IP address with non-SSL name-based virtual hosts. Soon after, I figured it out. Shortly after that, one of my students suggested the same solution to me.

/etc/apache2/conf.d/virtual.conf

#
# We're running multiple virtual hosts.
#
NameVirtualHost *:80
NameVirtualHost *:443

/etc/apache2/sites-enabled

<VirtualHost *:80>
ServerAdmin webmaster@zviretnik.eu
ServerName zviretnik.eu
ServerAlias www.zvietnik.eu
...

<VirtualHost *:443>
ServerAdmin webmaster@zviretnik.eu
ServerName www.zviretnik.eu
ServerAlias zviretnik.eu
...

The ports 80 and 443 should be also defined in following configuration file.

/etc/apache2/ports.conf

Listen 80
<IfModule mod_ssl.c>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>

Also check your /etc/hosts file, if DNS name and IP address is correct.

127.0.0.1 localhost zviretnik.eu
94.143.171.113 zviretnik.eu zvire