Virtual Hosts mit vhost_alias
Die Anleitung bezieht sich auf einen Apache-Server innerhalb einer virtuellen Maschine (z.B. mit VirtualBox, VMWare etc.)
Apache Modul aktivieren
sudo a2enmod vhost_alias
vhost Konfigurations-Datei anlegen
Im Verzeichnis /etc/apache2/sites-available/ eine Datei anlegen, z.B. typo3kurs.dev.conf
<VirtualHost *:80>
ServerName typo3kurs.dev
ServerAlias *.typo3kurs.dev
ServerAdmin webmaster@localhost
<Directory /var/www/*/>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</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 warn
ErrorLog ${APACHE_LOG_DIR}/typo3kurs-error.log
CustomLog ${APACHE_LOG_DIR}/typo3kurs-access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# URL structure projektx.typo3kurs.dev
UseCanonicalName Off
VirtualDocumentRoot /var/www/%1
</VirtualHost>
Danach aktivieren per
sudo a2ensite typo3kurs.dev.conf
Danach Apache neu starten oder Konfiguration neu laden
hosts-Datei des Host-Systems editieren
In der hosts-Datei des Host-Systems die IP der virtuellen Maschine und den Domainnamen hinterlegen, z.B.
192.168.3.121 projekt1.typo3kurs.dev
192.168.3.121 projekt2.typo3kurs.dev
usw.
Die Domain-Struktur muss jetzt immer *.typo3kurs.dev sein.
Auf der virtuellen Maschine muss ein entsprechendes Verzeichnis vorhanden sein, also z.B.
/var/www/projekt1/
/var/www/projekt2/
usw.