Hallo,
ich habe mir gestern auf meinen Server neben Apache2 nun noch lighttpd installiert und würde lighttpd nun ab sofort gerne als Hauptserver (Port 80) laufen lassen.
Soweit ist das auch alles kein Problem, wäre da nicht die Konfiguration.
Ich hab in lighttpd nun das simple-vhost Modul aktiviert und habe mir ein kleines Script gebastelt, das die vorhanden Ordner zu ihren Domains legt:
Code:
#!/bin/bash
rm /etc/lighttpd/conf-enabled/include_config
for VHOST in `find /var/vhosts/ -mindepth 1 -maxdepth 1 \( -type d -or -type l \) -exec test -e "{}/server.conf" \; -exec basename "{}" \;` ; do {
echo "Creating vHost for \"$VHOST\"..."
rm /etc/lighttpd/sites-enabled/$VHOST.conf
echo "\$HTTP[\"host\"] =~ \"$VHOST\" {" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "var.vhost_name = \"$VHOST\"" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "var.vhost_path = \"/var/vhosts/$VHOST\"" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "server.server-root = \"/var/www/vhosts/$VHOST/www/\"" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "server.document-root = \"/var/www/vhosts/$VHOST/www/\"" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "server.errorlog = \"/var/vhosts/$VHOST/logs/error.log\"" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "accesslog.filename = \"/var/vhosts/$VHOST/logs/access.log\"" >> /etc/lighttpd/sites-enabled/$VHOST.conf
cat /var/vhosts/$VHOST/server.conf >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "}" >> /etc/lighttpd/sites-enabled/$VHOST.conf
echo "include \"/etc/lighttpd/sites-enabled/$VHOST.conf\"" >> /etc/lighttpd/conf-enabled/include_config
} ; done
sudo chown www-data:www-data /etc/lighttpd/conf-enabled/include_config
sudo chmod u+x /etc/lighttpd/conf-enabled/include_config
Die HTTP Dateien liegen also unter /var/vhost/domain.com/www/
Nun möchte ich gerne das vorhandene Subdomains (bzw Ordner) funktionieren:
/var/vhost/sub1.domain.com/www/ => sub1.domain.com
und alle anderen nicht existieren Domains (z.b
www.domain.com/sub2.domain.com) auf
www.domain.com umgeleitet werden.
Hat da irgendjemand eine Idee wie ich das Problem lösen könnte?
Die Lösungen aus dem Internet mit Regex hatten bisher nicht funktioniert...