During setting up a virtual host with Ubutnu 20.04.5 LTS for a customer for Nextcloud, Only Office and Zammad I came across the following problem:
After installing nginx-extras (nginx-extras is required by only office) with PHP-8.1. on Ubtuntu 20.04.5 LTS the nginx server always crashed after a certain time, without any comprehensible reason. After a more detailed analysis I found out that the main process exited more or less exactly after 24 hours (sometimes 48 hours) after systemd reloaded nginx:
systemd: Reloading A high performance web server and a reverse proxy server. systemd: Reloaded A high performance web server and a reverse proxy server. systemd: nginx.service: Main process exited, code=killed, status=11/SEGV systemd: nginx.service: Killing process 462641 (nginx) with signal SIGKILL. systemd: nginx.service: Killing process 462641 (nginx) with signal SIGKILL. systemd: nginx.service: Failed with result 'signal'. nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: signal) since Mon 2022-09-12 02:24:57 CEST; 6h ago Docs: man:nginx(8) Process: 700608 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 700609 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 815231 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS) Main PID: 700610 (code=killed, signal=SEGV) Tasks: 0 (limit: 1843) Memory: 8.2M CGroup: /system.slice/nginx.service
After some research I found out that when installing nginx-extras the perl module who allows to execute perl scripts directly in nginx is also installed. However there is a bug in perl shipped with Ubuntu 20.04.x LTS which results in a nginx crash after nginx is reloaded after three or four times.
To solve this bug I decided to unlink the mod-http-perl module and restart nginx using the following command:
unlink /etc/nginx/modules-enabled/50-mod-http-perl.conf sudo systemctl restart nginx
Since that nginx is running completely fine. I do not need to execute perl directly in nginx, therefore there are no side effects I have to consider.