Linux Webserver Apache2:
Ausgangssituation
- Mittels VirtualHosts mehrere Subdomains versch. Webpräsenzen zuweißen.
- Via .htaccess den Zugriff auf einen Unterordner Namens „secure“ beschränken und für eine Subdomain eine sichere Verbindung via SSL einrichten.
Konfigurationsdateien:
Debian: /etc/apache2/sitesavailable/… für VirtualHosts etc.
RedHat: /etc/httpd/conf/httpd.conf
→ Bei RedHat basierden Systemen liegt leider alles in einer einzelnen Datei, was die Übersicht ziehmlich beschränkt. Das Tutorial wird sich mit RedHat basierenden Systemen befassen, eine spätere Anpassung an Debian ist möglich.
In meinem Beispiel gibt es die 4 Subdomains:
→ verkauf.take.local # Seite der Verkaufsabteilung
→ support.take.local # Seite des Supportes
→ www.take.local # Hauptseite
→ ssl.take.local # SSL Seite
(Weiterführend von dem Samba Tutorial)
Als erstes sollten wir also in unserem Windows DNS Server 4 neue ARecords für die 4 Subdomains anlegen.
Beide auf die IP Adresse 192.168.1.231.
Für diese Seiten legen wir nun 2 neue Ordner an:
[root@unix01 ~]# mkdir /var/www/support && mkdir /var/www/verkauf
| VirtualHost für non-SSL |
NameVirtualHost 192.168.1.231:80
<VirtualHost 192.168.1.231:80>
ServerName verkauf.take.local
DocumentRoot /var/www/verkauf
<Directory /var/www/verkauf>
Options None
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.231:80>
ServerName support.take.local
DocumentRoot /var/www/support
<Directory /var/www/support>
Options None
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.231:80>
ServerName www.take.local
DocumentRoot /var/www/html
<Directory /var/www/html>
Options None
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost> |
Passwortgeschützten Bereich für /var/www/html/secure erstellen
→ AllowOverride All in httpd.conf!
| .htaccess |
AuthType Basic
AuthName Secured
AuthUserFile /var/www/apachepasswords
Require user take eric |
Passwort Datei erstellen
[root@unix01 ~]# /usr/bin/htpasswd -c /var/www/apachepasswords take # Erstellt die o.g. Passwort Datei
[root@unix01 ~]# /usr/bin/htpasswd /var/www/apachepasswords eric # -c weglassen, da schon vorhanden
SSL-Verbindung
Die günstigste Variante ist ein selbsterstelltes Zertifikat und genau dieses werden wir jetzt erstellen.
[root@unix01 ~]# openssl genrsa -des3 -rand /var/log/messages:/var/log/smb:/var/log/mysql.log -out take.key 1024
→ Passwort eingeben
| [root@unix01 ~]# openssl req -new -key take.key -out take.csr |
Enter pass phrase for take.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
——
Country
Name (2 letter code) [GB]:DE
State or Province Name (full name) [Berkshire]:Sachsen
Locality Name (eg, city) [Newbury]:Kesselsdorf
Organization Name (eg, company) [My Company Ltd]:Take AG
Organizational Unit Name (eg, section) []:TAG
Common Name (eg, your name or your server’s hostname) []:ssl.take.local
Email Address []:root@take.local
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:takey
An optional company name []: |
[root@unix01 ~]# openssl x509 -req -days 30 -in take.csr \
-signkey take.key -out take.crt |
Signature ok
subject=/C=DE/ST=Sachsen/L=Kesselsdorf/O=Take
AG/OU=TAG/CN=ssl.take.local/emailAddress=root@take.local
Getting Private key
Enter pass phrase for take.key: |
Nun haben wir unser eigenes Zertifikat erzeugt. Das kopieren wir nun nach /etc/httpd/conf.d/
[root@unix01 ~]# cp take.key /etc/httpd/conf.d/
[root@unix01 ~]# cp take.crt /etc/httpd/conf.d/
Jetzt muss nur noch die Datei /etc/httpd/conf.d/ssl.conf angepasst werden:
Es müssen nur wenige Einstellungen verändert werden, aus diesem Grund schreibe ich hier nur die Veränderungen:
| /etc/httpd/conf.d/ssl.conf |
ca. Zeile 84: DocumentRoot „/var/www/ssl“
ca. Zeile 85: ServerName ssl.take.local
ca. Zeile 112: SSLCertificateFile /etc/httpd/conf.d/take.crt
ca. Zeile 120: SSLCertificateKeyFile /etc/httpd/conf.d/take.key |
Danach muss der Apache2 neugestartet werden (reload geht in diesem Fall nicht!). Die Passwortabfrage sollte nicht weiter abschreiben, Passwort eingeben und weiter gehts.
Jetzt ist eine SSL-Verbindung über http://ssl.take.local möglich.
MySQL und phpMyAdmin
Als erstes müsst ihr nach einer frischen Installation von MySQL dem root Benutzer ein Passwort geben:
[root@unix01 ~]# mysqladmin -u root password ‘takey’
→ Passwort ‘takey’ ist das neue Passwort – es wird im Klartext übergeben, es sei zu Beachten das niemand Binblick auf euren Monitor hat.
Nun laded euch die neuste Version von phpMyAdmin unter www.phpmyadmin.net herrunter und entpackt diese. Zu guter letzt muss noch ein Eintrag in der Sample-Konfigurationsdatei geändert werden und diese in config.inc.php umbenennen.
Öffnet die Datei config.sample.inc.php mit eurem favorisierten Texteditor (vi, oä.) und editiert folgende Zeile:
$cfg['blowfish_secret'] = ‘IrgendEtwasSinnfreies059689256′;
Alles andere kann so gelassen werden, jetzt noch die Config umbenennen:
[root@unix01 ~]# mv config.sample.inc.php config.inc.php
Aufrufbar ist der phpMyAdmin nun über http://www.take.local/phpMyAdmin.
Dieses Tutorial ist ein Rewrite von CodersHELL.
