Apache Webserver Tipps: Unterschied zwischen den Versionen
Aus revampedia
Zeile 19: | Zeile 19: | ||
=== Umschalten der PHP Versionen (installiert sind von 7.0 -7.4) === | === Umschalten der PHP Versionen (installiert sind von 7.0 -7.4) === | ||
Beispiedatei apache http.conf : | Beispiedatei apache http.conf : | ||
− | + | <VirtualHost *:80> | |
− | <VirtualHost *:80> | + | ServerAdmin admin@site.your_domain |
− | + | ServerName site.your_domain | |
− | + | DocumentRoot /var/www/site.your_domain | |
− | + | DirectoryIndex info.php | |
− | ServerName site.your_domain | + | <Directory /var/www/site.your_domain> |
− | + | Options Indexes FollowSymLinks MultiViews | |
− | DocumentRoot /var/www/site.your_domain | + | AllowOverride All |
− | + | Order allow,deny | |
− | DirectoryIndex info.php | + | allow from all |
− | + | </Directory> | |
− | <Directory /var/www/site.your_domain> | + | <FilesMatch \.php$> |
− | + | SetHandler "proxy:unix:/run/php/'''php7.0-fpm.sock'''|fcgi://localhost" | |
− | Options Indexes FollowSymLinks MultiViews | + | </FilesMatch> |
− | + | </VirtualHost> | |
− | AllowOverride All | ||
− | |||
− | Order allow,deny | ||
− | |||
− | allow from all | ||
− | |||
− | |||
− | |||
− | <FilesMatch \.php$> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | </VirtualHost> |
Version vom 5. Januar 2021, 19:22 Uhr
Umleiten von Webadressen
Ausführliche Anleitung (Englisch):
https://wiki.apache.org/httpd/Rewrite
Apache2 Dokumentation mit den wichtigsten Infos zum Regex-Vokabular (Englisch):
https://httpd.apache.org/docs/current/rewrite/intro.html
Ehemaliges Verzeichnis mit allen Unterverzeichnissen auf neue Homepage umleiten
Folgende Zeilen in die Apache VirtualHost-Konfigurationsdatei der entsprechenden Website einfügen:
RewriteEngine on RewriteRule "^/altes-verzeichnis/.*" "http://www.neuehomepage.ch?"
Das Fragezeichen am Ende bewirkt, dass alle vorhandenen Query-Strings (also Angaben, die in der URL nach index.php? angefügt sind), gelöscht werden.
Weiterleiten aller nicht https-Aufrufe auf https
Wenn eine Website nur mit verschlüsselter Übertragung via https erreichbar sein soll, so kann mit folgendem Eintrag in der Apache VirtualHost Konfigurationsdatei der entsprechenden Website dies erreicht werden:
<VirtualHost *:80> ServerAdmin hier-e-mail-adresse-einfügen ServerName subdomain.domain.ch Redirect permanent / https://subdomain.domain.ch </VirtualHost>
Umschalten der PHP Versionen (installiert sind von 7.0 -7.4)
Beispiedatei apache http.conf :
<VirtualHost *:80> ServerAdmin admin@site.your_domain ServerName site.your_domain DocumentRoot /var/www/site.your_domain DirectoryIndex info.php <Directory /var/www/site.your_domain> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> <FilesMatch \.php$> SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost" </FilesMatch> </VirtualHost>