web page shows me timeout gateway error FastCGI

Solution 1:

The errors tells you its PHP (Version 7.2, EoL now, fix that!) that is trying to exceed its allocated memory limit.

If the script was terminated while talking to the database (the mysql logs makes me think so), then maybe one of your database queries (not necessarily the last one!) is returning an unexpectedly large result set that does not fit the memory allowed for the php script?

Check query log, execute the queries manually and see

  • if are appropriate: then you want to allocate more resources OR:
  • if one of them is unnecessarily large: then you want to improve the application querying them or cleanup unnecessary rows to reduce resource usage.

If it is the former, then keep in mind most systems are setup to have separate php configurations for separate deployment options. This may include different memory limits or available extensions. As you have multiple different deployments, the used php.ini file may be different for each of cgi, cli, fpm, apache2-mod, .. - if in doubt, let your script print phpinfo() to confirm the effective configuration.