在 Ubuntu 20.04 上使用 Nginx 运行的 Magento 2 返回“错误网关”错误代码 502

在 Ubuntu 20.04 上使用 Nginx 运行的 Magento 2 返回“错误网关”错误代码 502

我在 Ubuntu 20.04 上全新安装了 Magento 2.4.4-p2。PHP 版本为 8.1.13,nginx 版本为 1.18.0 (Ubuntu)。我可以看到并访问主页和以下页面,没有出现 502 bad gateway 错误:

https://example.com/sales/guest/form/
https://example.com/catalogsearch/advanced/

其余所有内容,包括管理页面和上述页面上的任何活动(例如搜索查询)都会返回错误网关 502。里面/etc/nginx/sites-available有具有example.com以下配置的虚拟主机:

upstream fastcgi_backend {
   server  unix:/run/php/php8.1-fpm.sock;
}
server {
  listen 80;
  server_name example.com;
  set $MAGE_ROOT /var/www/example.com/html;
  include /var/www/example.com/html/nginx.conf.sample;
  client_max_body_size 2M;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate         /etc/ssl/cert.pem;
  ssl_certificate_key     /etc/ssl/key.pem;
  access_log /var/log/nginx/magento.access;
  error_log /var/log/nginx/magento.error;
}

我关注了文档并调整了以下内容/etc/php/8.1/fpm/php.ini

memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On

通常,此问题是由不正确的 Nginx 配置文件引起的。但 Magento 2 文档中是这样说的。我该如何修复此问题?- 错误日志很干净。

的内容include /var/www/example.com/html/nginx.conf.sample;这里

相关内容