ubuntu:apache_webserver
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Ubuntu 18.04: Apache Webserver
Ich verwende in dieser Anleitung das MPM ITK - http://mpm-itk.sesse.net/ .
Installation der Pakete
# aptitude install apache2 libapache2-mpm-itk
Konfigurationsanpassungen
Ist Apache installiert, ist er sofort einsatzbereit. Ich mache noch folgende Anpassungen:
- /etc/apache2/conf-available/security.conf
[...] # # ServerTokens # This directive configures what you return as the Server HTTP response # Header. The default is 'Full' which sends information about the OS-Type # and compiled in modules. # Set to one of: Full | OS | Minimal | Minor | Major | Prod # where Full conveys the most information, and Prod the least. #ServerTokens Minimal ServerTokens Prod [...]
Webserver-User für virtuellen Host
Ich lege mittels eines Bash-Skripts die Benutzer und Verzeichnisse für die benötigten virtuellen Hosts an:
#!/bin/bash
# Sicherheitsstopp, vorher auskommentieren!
exit 0
arr=(user1 user2 user3)
for item in ${arr[*]}
do
mkdir -p /srv/www/$item
mkdir -p /srv/www/$item/htdocs
mkdir -p /srv/www/$item/log
useradd -d "/srv/www/$item" -s /bin/false $item
chown -R $item.$item /srv/www/$item
done
exit 0
Virtuellen Host konfigurieren
Folgend eine Beispielkonfiguration, wie sie im Pfad /etc/apache2/sites-available abgelegt werden muss und mit einem Dateinamen, der mit .conf endet, benannt werden muss.
<VirtualHost *:80>
ServerAdmin webmaster@meine-domain.de
ServerName meine-domain.de
ServerAlias www.meine-domain.de
DocumentRoot /srv/www/meine-domain/htdocs
# Mod ITK configuration
<IfModule mpm_itk_module>
AssignUserId meine-domain meine-domain
</IfModule>
<Directory "/srv/www/meine-domain/htdocs/">
Options +Includes +MultiViews -Indexes +FollowSymLinks
AllowOverride AuthConfig FileInfo Options
Require all granted
</Directory>
ErrorLog /srv/www/meine-domain/log/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /srv/www/meine-domain/log/access.log combined
</VirtualHost>
Der virtuelle Host muss noch aktiviert werden. Hinter dem Befehl a2ensite gehört der Dateiname des virtuellen Hosts ohne .conf.
# a2ensite meine-domain # apache2ctl configtest # service apache2 reload
HTTPS mit Let's Encrypt
Certbot installieren
Als root ausführen:
apt-get update apt-get install software-properties-common add-apt-repository universe add-apt-repository ppa:certbot/certbot apt-get update apt-get install python-certbot-apache
Cerbot: Zertifikate anfordern und Webserver anpassen
Ein Beispiel:
# certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email certadmin@meine-domain.de --domain www.meine-domain.de --domain meine-domain.de
ubuntu/apache_webserver.1561105726.txt.gz · Zuletzt geändert: von Sebastian Hetzel
