Also wie es scheint sind einfach alle Anleitungen im Internet nicht sehr aktuell.
Laut denen hier gehts mit einer neueren Apache Version:
http://www.zdnet.de/webentwicklung_so_unterstuetzt_apache_ssl_sites_mit_einer_ip_adresse_story-20000203-41527996-1.htm
Also wollen wir das mal zusammen erarbeiten.
Ich nehme einen frisch installieren Ubuntu Server 10.04 und als test die Domains sample1.com und sample2.com
apt-get install apache2 (apache installieren)
mkdir /var/www/sample1.com (verzeichnis für dateien machen)
mkdir /var/www/sample2.com (verzeichnis für dateien machen)
vi /var/www/sample1.com/index.html (index file das auch was auf der seite erscheint)
<html>
<head>
</head>
<body>
<h1>sample1.coma</h1>
</body>
</html>
für den zweiten host natürlich das selbe mit den ensprechenden anpassungen. ich beschreibe nun nicht alles, ich gehe davon aus jeder der das hier lesen tut kennt sich einigermassen aus.
cp /etc/apache2/sites-enabled/000-default sample1.com
vi /etc/apache2/sites-enabled/sample1.com (anpassen für beide seiten)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
'''ServerAlias sample1.com www.sample1.com'''
DocumentRoot /var/www/'''sample1.com'''
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/'''sample1.com'''>
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 warn
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>
</VirtualHost>
Nun möchte ich, das die sample2 sowohl auf http als auch auf https hört.
Zertifikate generieren
Generating a 1024 bit RSA private key
.....++++++
..........................++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
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) [AU]:CZ
State or Province Name (full name) [Some-State]:Stadt
Locality Name (eg, city) []:City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Company
Organizational Unit Name (eg, section) []:Section
Common Name (eg, YOUR name) []:sample2.com
Email Address []:sample2@sample.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:Origon46
An optional company name []:Company Name
root@ubuntu-server:/etc/apache2/ssl#
openssl rsa -in privkey.pem -out server.cert.key
openssl x509 -in server.cert.csr -out server.cert.crt -req -signkey server.cert.key -days 365
vi vi /etc/apache2/sites-enabled/sample2.com (um folgendes erweitern)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerAlias sample2.com www.sample2.com
DocumentRoot /var/www/sample2.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sample2.com>
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 warn
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>
</VirtualHost>
'''<VirtualHost *:443>
SSLEngine On
SSLCertificateKeyFile /etc/apache2/ssl/server.cert.key
SSLCertificateFile /etc/apache2/ssl/server.cert.crt
DocumentRoot /var/www/sample2.com
</VirtualHost>'''
Enabling module ssl.
See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
Run '/etc/init.d/apache2 restart' to activate new configuration!
/etc/init.d/apache2 restart (Apache restarten)
funktioniert ☺ https://sample2.com zertifikat ist zwar nicht vertrauenswürdig, da selber generitert aber es läuft...
Wenn ich nun also einfach folgenden Teil
<VirtualHost *:443>
SSLEngine On
SSLCertificateKeyFile /etc/apache2/ssl/server.cert.key
SSLCertificateFile /etc/apache2/ssl/server.cert.crt
DocumentRoot /var/www/sample1.com
</VirtualHost>
in das VirtualHost File von sample1.com kopiere kommt beim apache reboot folgender fehler:
{{{
warn] _default_ VirtualHost overlap on port 443, the first has precedence
... waiting
[warn] _default_ VirtualHost overlap on port 443, the first has precedence
Klar, weil beide VirtualHosts möchten auf den Port, aber bei Port 80 funktionierts ja auch.
Was muss also nun getan werden?
und
Wofür sind die default und default-ssl in /etc/apache2/sites-available gedacht? Solle man lieber die als vorlagen nehmen der VirualHosts?