ubuntu:nginx_webserver
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| ubuntu:nginx_webserver [2019/04/13 17:01] – [PHP] angelegt Sebastian Hetzel | ubuntu:nginx_webserver [2023/10/22 09:58] (aktuell) – [Ubuntu 18.04 + 22.04: Nginx] und Sebastian Hetzel | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== Ubuntu 18.04: Nginx ====== | + | ====== Ubuntu 18.04 und 22.04: Nginx ====== |
| ===== Installation ===== | ===== Installation ===== | ||
| Zeile 51: | Zeile 51: | ||
| ===== Konfiguration ===== | ===== Konfiguration ===== | ||
| + | |||
| + | Serverweite Konfigurationen werden an folgender Datei vorgenommen: | ||
| <file | nginx.conf> | <file | nginx.conf> | ||
| Zeile 57: | Zeile 59: | ||
| [...] | [...] | ||
| </ | </ | ||
| + | |||
| + | Bei Nginx heißen die " | ||
| + | |||
| + | < | ||
| + | /etc/nginx# ll | ||
| + | total 72 | ||
| + | drwxr-xr-x | ||
| + | drwxr-xr-x 112 root root 4096 Apr 12 21:13 ../ | ||
| + | drwxr-xr-x | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | drwxr-xr-x | ||
| + | drwxr-xr-x | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | drwxr-xr-x | ||
| + | drwxr-xr-x | ||
| + | drwxr-xr-x | ||
| + | -rw-r--r-- | ||
| + | -rw-r--r-- | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | Nach Änderung der Konfiguration kann mit folgendem Befehl geprüft werden, ob die Konfiguration Fehler enthält: | ||
| + | |||
| + | < | ||
| + | # nginx -t | ||
| + | nginx: the configuration file / | ||
| + | nginx: configuration file / | ||
| + | </ | ||
| ===== HTTPS mit Let's Encrypt ===== | ===== HTTPS mit Let's Encrypt ===== | ||
| Zeile 114: | Zeile 151: | ||
| </ | </ | ||
| + | Läuft? | ||
| + | < | ||
| + | # service php7.2-fpm status | ||
| + | ● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager | ||
| + | | ||
| + | | ||
| + | Docs: man: | ||
| + | Main PID: 943 (php-fpm7.2) | ||
| + | | ||
| + | Tasks: 3 (limit: 2319) | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | Apr 13 17:24:28 xxx systemd[1]: Starting The PHP 7.2 FastCGI Process Manager... | ||
| + | Apr 13 17:24:28 xxx systemd[1]: Started The PHP 7.2 FastCGI Process Manager. | ||
| + | </ | ||
| + | |||
| + | === PHP.ini === | ||
| + | |||
| + | Folgende Zeilen dürfen nicht auskommentiert bleiben: | ||
| + | |||
| + | <file | / | ||
| + | [...] | ||
| + | env[HOSTNAME] = $HOSTNAME | ||
| + | env[PATH] = / | ||
| + | env[TMP] = /tmp | ||
| + | env[TMPDIR] = /tmp | ||
| + | env[TEMP] = /tmp | ||
| + | [...] | ||
| + | </ | ||
| + | |||
| + | |||
| + | <file | / | ||
| + | [...] | ||
| + | short_open_tag = On | ||
| + | [...] | ||
| + | open_basedir = / | ||
| + | [...] | ||
| + | expose_php = Off | ||
| + | [...] | ||
| + | </ | ||
| + | |||
| + | <file | / | ||
| + | [...] | ||
| + | short_open_tag = On | ||
| + | [...] | ||
| + | open_basedir = / | ||
| + | [...] | ||
| + | expose_php = Off | ||
| + | [...] | ||
| + | </ | ||
| + | |||
| + | ==== Tuning und Fehlerbehebung ==== | ||
| + | |||
| + | === server reached pm.max_children setting, consider raising it === | ||
| + | |||
| + | Logfile (PHP-FPM): | ||
| + | < | ||
| + | [23-Apr-2019 19:37:52] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it | ||
| + | [23-Apr-2019 21:08:16] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it | ||
| + | [23-Apr-2019 21:10:12] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it | ||
| + | </ | ||
| + | |||
| + | <file | / | ||
| + | ; The number of child processes to be created when pm is set to ' | ||
| + | ; maximum number of child processes when pm is set to ' | ||
| + | ; This value sets the limit on the number of simultaneous requests that will be | ||
| + | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. | ||
| + | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP | ||
| + | ; CGI. The below defaults are based on a server without much resources. Don't | ||
| + | ; forget to tweak pm.* to fit your needs. | ||
| + | ; Note: Used when pm is set to ' | ||
| + | ; Note: This value is mandatory. | ||
| + | pm.max_children = 8 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | |||
| + | ===== Nginx: Handling ===== | ||
| + | |||
| + | ==== Konfiguration prüfen vor Neustart des Dienstes ==== | ||
| + | |||
| + | < | ||
| + | # service nginx configtest | ||
| + | * Testing nginx configuration | ||
| + | </ | ||
| + | |||
| + | Was sagt das Errorlog? | ||
| + | > **/ | ||
| + | |||
| + | < | ||
| + | 2019/12/07 17:06:07 [emerg] 14795# | ||
| + | 2019/12/07 17:07:07 [emerg] 14859# | ||
| + | </ | ||
| + | |||
| + | ===== Reverse-Proxy ===== | ||
| + | |||
| + | ==== Virtual Host anlegen ==== | ||
| + | |||
| + | |||
| + | <file | / | ||
| + | server { | ||
| + | listen 80; | ||
| + | listen [::]:80; | ||
| + | |||
| + | server_name your_domain www.your_domain; | ||
| + | | ||
| + | location / { | ||
| + | proxy_pass app_server_address; | ||
| + | include proxy_params; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Proxyparameter festlegen ==== | ||
| + | |||
| + | <file | / | ||
| + | proxy_set_header Host $http_host; | ||
| + | proxy_set_header X-Real-IP $remote_addr; | ||
| + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| + | proxy_set_header X-Forwarded-Proto $scheme; | ||
| + | </ | ||
ubuntu/nginx_webserver.1555167700.txt.gz · Zuletzt geändert: von Sebastian Hetzel
