Einzelheiten zur Apache-Konfiguration
Ziel bei der Konfiguration ist es nur mit virtuellen Servern zu arbeiten. Die Konfiguration funktioniert wie beschrieben, müsst an manchen Stellen aber noch etwas konsistenter überarbeitet werden.
für Typo3
Da ich viel mit Typo3 arbeite habe ich noch die Module
- opcache
- soap
installiert und etwas an den PHP-Einstellungen gedreht in der /etc/php5/apache2/php.ini:
post_max_size=10M upload_max_filesize=10M max_execution_time=240
/etc/apache2/listen.conf
# Listen: Allows you to bind Apache to specific IP addresses and/or # ports. See also the <VirtualHost> directive. # # http:///httpd.apache.org/docs/2.4/mod/mpm_common.html#listen # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) # # When we also provide SSL we have to listen to the # standard HTTP port (see above) and to the HTTPS port # # Note: Configurations that use IPv6 but not IPv4-mapped addresses need two # Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443" # #Listen 12.34.56.78:80 #Listen 80 #Listen 443 Listen 80 <IfDefine SSL> <IfDefine !NOSSL> <IfModule mod_ssl.c> Listen 443 </IfModule> </IfDefine> </IfDefine> # Use name-based virtual hosting # # - on a specified address / port: # #NameVirtualHost 12.34.56.78:80 # # - name-based virtual hosting: # #NameVirtualHost *:80 # # - on all addresses and ports. This is your best bet when you are on # dynamically assigned IP addresses: # #NameVirtualHost *
Bei OpenSuSE ist diese Standard-Datei schon vorhanden.
/etc/apache2/vhosts.d/00_default.conf
Im ersten Schritt deaktiviere ich einen Teil der Standardvorgaben. Der Name resultiert aus der Tatsache, dass der Apache die Dateien in alphabetischer Reihenfolge einliest. Diese Datei muss als erste eingelesen werden. Seit Apache 2.4 wird statt Order allow,deny und Allow from all neu Require all granted erwartet. Sonst bekommt man die Fehlermeldung client denied by server configuration im Browser zu sehen.
Will man unbedingt die alte Konfiguration behalten, dann kann man das Modul mod_access_compat aktivieren.
ServerName default
ServerAdmin webmaster@<dummy>.de
ServerTokens Major
DocumentRoot /srv/www/htdocs
Alias /groupoffice /srv/www/htdocs/groupoffice
Alias /squirrelmail /srv/www/htdocs/squirrelmail
Alias /webmail /srv/www/roundcubemail
<Directory "/srv/www/vhosts">
AllowOverride All
Options +FollowSymLinks
Require all granted
<IfModule mod_php5.c>
</IfModule>
</Directory>
<IfModule mod_userdir.c>
UserDir disabled
</IfModule>
<VirtualHost *:80>
ServerName default
UseCanonicalName Off
DocumentRoot /srv/www/vhosts/default/httpdocs
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
Alias /groupoffice /srv/www/htdocs/dummy
Alias /squirrelmail /srv/www/htdocs/dummy
Alias /webmail /srv/www/htdocs/dummy
Alias /postfixadmin /srv/www/htdocs/dummy
Alias /phpMyAdmin /srv/www/htdocs/dummy
Alias /roundcube /srv/www/htdocs/dummy
<IfDefine MAILMAN>
ScriptAlias /mailman/ /srv/www/htdocs/dumma
Alias /mailmanicons/ /srv/www/htdocs/dummy
Alias /pipermail/ /srv/www/htdocs/dummy
</IfDefine>
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory "/srv/www/cgi-bin/">
AllowOverride None
Options None
Require all denied
</Directory>
<Directory /srv/www/vhosts/default/httpdocs>
AllowOverride All
Options None
Require all granted
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
</IfModule>
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443 >
ServerName default
UseCanonicalName Off
DocumentRoot /srv/www/vhosts/default/httpsdocs
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
Alias /groupoffice /srv/www/htdocs/dummy
Alias /squirrelmail /srv/www/htdocs/dummy
Alias /webmail /srv/www/htdocs/dummy
Alias /postfixadmin /srv/www/htdocs/dummy
Alias /phpMyAdmin /srv/www/htdocs/dummy
Alias /roundcube /srv/www/htdocs/dummy
<IfDefine MAILMAN>
ScriptAlias /mailman/ /srv/www/htdocs/dummy
Alias /mailmanicons/ /srv/www/htdocs/dummy
Alias /pipermail/ /srv/www/htdocs/dummy
</IfDefine>
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNUL
SSLCertificateFile /srv/www/vhosts/default/ssl/server.crt
SSLCertificateKeyFile /srv/www/vhosts/default/ssl/server.key
<Directory "/srv/www/cgi-bin/">
AllowOverride None
Options None
Require all denied
</Directory>
<Directory /srv/www/vhosts/default/httpsdocs>
SSLRequireSSL
AllowOverride None
Options None
Require all granted
</Directory>
</VirtualHost>
</IfModule>
Der Ordner /srv/www/htdocs/dummy ist hier ein leerer Dummy-Ordner, damit Zugriffe auf die entsprechenden Anwendungen ins Leere laufen. Natürlich müssen die in der Konfiguration genannten Pfade eingerichtet sein, also z.B. /srv/www/vhosts/default/httpdocs und /srv/www/vhosts/default/httpsdocs. Idealerweise sollte in den Ordnern auch eine Datei index.html liegen, um Fehlermeldungen zu vermeiden.
Damit die Konfiguration funktionieren kann muss, sofern das Modul SSL aktiviert wurde, an der angegebenen Stelle ein Zertifikat vorliegen. Es kann ruhig ein selbst erstelltes Zertifikat sein.
In das Verzeichnis /srv/www/vhosts/default/ssl/ wechseln und dann ausführen:
openssl genrsa -out server.key 1024 openssl req -new -key server.key -out server.csr openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
siehe dazu auch https://thomas-leister.de/allgemein/apache-webserver-ssl-verschlusselung-einrichten/ oder etwas umfangreicher https://mathias-kettner.de/lw_ca_zertifikat_erstellen.html
/etc/apache2/vhosts.d/stratoserver.net.conf
Hier wird ein virtueller Server angelegt, der auf den Strato-Namen lauscht. Aktuell ist die Konfiguration so, dass darüber auch das default-Verzeichnis genutzt wird. Sollen Dienste wie phpMyAdmin unter der Adresse verfügbar sein, so müssen die entsprechenden Rauten entfernt werden.
<VirtualHost *:80>
ServerName h2366xyz.stratoserver.net
UseCanonicalName Off
DocumentRoot /srv/www/vhosts/default/httpdocs
CustomLog /var/log/apache2/server_access_log combined
ErrorLog /var/log/apache2/server_error_log
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
# Alias /phpMyAdmin /srv/www/htdocs/phpMyAdmin
# Alias /postfixadmin /srv/www/htdocs/postfixadmin
# Alias /groupoffice /srv/www/htdocs/groupoffice
# Alias /squirrelmail /srv/www/htdocs/squirrelmail
# Alias /webmail /srv/www/roundcubemail
Alias /webstat /srv/www/vhosts/default/webstat
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory "/srv/www/cgi-bin/">
AllowOverride None
Options None
Require all granted
</Directory>
<Directory /srv/www/vhosts/default/httpdocs>
AllowOverride All
Options None
Require all granted
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
# php_admin_value include_path "/srv/www/htdocs/horde/pear:/srv/www/htdocs:./"
# php_admin_value open_basedir "/srv/www/htdocs:/tmp"
</IfModule>
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443 >
ServerName h2366xyz.stratoserver.net
UseCanonicalName Off
DocumentRoot /srv/www/vhosts/default/httpsdocs
CustomLog /var/log/apache2/server_access_log combined
ErrorLog /var/log/apache2/server_error_log
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
# Alias /phpMyAdmin /srv/www/htdocs/phpMyAdmin
# Alias /postfixadmin /srv/www/htdocs/postfixadmin
# Alias /groupoffice /srv/www/htdocs/groupoffice
# Alias /squirrelmail /srv/www/htdocs/squirrelmail
Alias /webmail /srv/www/roundcubemail
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNUL
SSLCertificateFile /srv/www/vhosts/default/ssl/server.crt
SSLCertificateKeyFile /srv/www/vhosts/default/ssl/server.key
<Directory "/srv/www/cgi-bin/">
AllowOverride None
Options None
Require all granted
</Directory>
<Directory /srv/www/vhosts/default/httpsdocs>
SSLRequireSSL
AllowOverride None
Options None
Require all granted
</Directory>
</VirtualHost>
</IfModule>
VServer-Konfiguration
Für jeden weiteren VServer erfolgt die Konfiguration nach folgendem System, wobei <dummy> durch z.B. den Domainnamen ersetzt wird. Das zugehörige Verzeichnis wird dann mit diesem Namen unterhalb von /srv/www/vhosts/ angelegt.
<VirtualHost *:80>
ServerName www.<dummy>:80
ServerAlias <dummy>
UseCanonicalName Off
DocumentRoot /srv/www/vhosts/<dummy>/httpdocs
CustomLog /var/log/apache2-vhosts.d/<dummy>_access_log combined
ErrorLog /var/log/apache2-vhosts.d/<dummy>_error_log
CustomLog /var/log/apache2/vhosts_access_log vhost_combined
ScriptAlias /cgi-bin/ /srv/www/vhosts/<dummy>/cgi-bin/
Alias /webstat /srv/www/vhosts/<dummy>/webstat
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory /srv/www/vhosts/<dummy>/httpdocs>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value include_path "/srv/www/vhosts/<dummy>/httpdocs:.:/tmp:./:/usr/share/php5/PEAR/:/srv/www/typo3src"
php_admin_value open_basedir "/srv/www/vhosts/<dummy>/httpdocs:/tmp:.:/usr/share/php5/PEAR/:/srv/www/typo3src"
php_value date.timezone "Europe/Berlin"
</IfModule>
<IfModule mod_python.c>
<Files ~ (\.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler
</Files>
</IfModule>
Options -Includes +ExecCGI
</Directory>
<Directory "/srv/www/vhosts/<dummy>/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Require all granted
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.<dummy>:443
ServerAlias <dummy>
UseCanonicalName Off
DocumentRoot /srv/www/vhosts/<dummy>/httpdocs
CustomLog /var/log/apache2-vhosts.d/<dummy>_access_log combined
ErrorLog /var/log/apache2-vhosts.d/<dummy>_error_log
ScriptAlias /cgi-bin/ /srv/www/vhosts/<dummy>/cgi-bin/
Alias /webstat /srv/www/vhosts/<dummy>/webstat
SSLEngine on
<Directory /srv/www/vhosts/<dummy>/httpdocs>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value include_path "/srv/www/vhosts/<dummy>/httpdocs:.:/tmp:./:/usr/share/php5/PEAR/:/srv/www/typo3src"
php_admin_value open_basedir "/srv/www/vhosts/<dummy>/httpdocs:/tmp:.:/usr/share/php5/PEAR/:/srv/www/typo3src"
php_value date.timezone "Europe/Berlin"
</IfModule>
<IfModule mod_python.c>
<Files ~ (\.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler
</Files>
</IfModule>
Options -Includes +ExecCGI
</Directory>
<Directory "/srv/www/vhosts/<dummy>/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Require all granted
</Directory>
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /srv/www/vhosts/<dummy>/ssl/ssl.crt
SSLCertificateKeyFile /srv/www/vhosts/<dummy>/ssl/ssl.key
SSLCertificateChainFile /srv/www/vhosts/<dummy>/ssl/sub.class1.server.ca.pem
SSLCACertificateFile /srv/www/vhosts/dummy>/ssl/ca.pem
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
CustomLog /var/log/apache2-vhosts.d/<dummy>_ssl_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
</IfModule>