Always having difficulties with having Mautic run on our server, basically because we are trying to run Mautic with other web apps, using nginx.
This time I took some time to research carefully on php-fpm, and finally got Mautic run with other web apps.
Nginx’s mautic.conf was not properly configured (I just copied my other config hoping it work, which didn’t – but got certbot to issue SSL certificate all right), and this one helped me a lot:
Basically I copied the whole config and pasted it, and added certbot’s SSL config.
However, installation process stopped with CSRF error.
The CSRF token is invalid. Please try to resubmit the form.
Nginx error log says:
2021/05/16 12:04:11 [error] 358173#358173: *1 FastCGI sent in stderr: “PHP message: PHP Warning: SessionHandler::read(): open(/var/lib/php/session/sess_00f42598e44d48be2e05b9fbcb266cd3, O_RDWR) failed: No such file or directory (2) in /var/www/html/mautic.3.2.4/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php on line 48PHP message: PHP Warning: SessionHandler::write(): open(/var/lib/php/session/sess_00f42598e44d48be2e05b9fbcb266cd3, O_RDWR) failed: No such file or directory (2) in /var/www/html/mautic.3.2.4/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php on line 64PHP message: PHP Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: /var/lib/php/session) in /var/www/html/mautic.3.2.4/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 268” while reading response header from upstream, client: 184.108.40.206, server: mydomain.com, request: “POST /installer/step/0 HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “mydomain.com”, referrer: “https://mydomain.com/installer/step/0”
According to discussion here:
I configured php-fpm session save path to /var/lib/php/fpm-session, and changed the owner of the directory to nginx’s user, www-data:www-data.
$ ls -l /var/lib/php/
drwxr-xr-x 2 www-data www-data 4096 May 16 12:15 fpm-session
drwxr-xr-x 3 root root 4096 May 15 21:56 modules
drwx-wx-wt 2 root root 4096 Mar 27 2020 sessions
And restarted php-fpm:
sudo systemctl restart php7.4-fpm
Finally Mautic is up and running (again).