![Sentry 与 PHP 和 nginx:Sentry 仪表板中不再出现错误](https://linux22.com/image/768109/Sentry%20%E4%B8%8E%20PHP%20%E5%92%8C%20nginx%EF%BC%9ASentry%20%E4%BB%AA%E8%A1%A8%E6%9D%BF%E4%B8%AD%E4%B8%8D%E5%86%8D%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF.png)
我的 nginx(nginx/1.14.2)配置被卡在了 php(php-7.4)应用程序上,该应用程序通常会向哨兵发送错误通知。
我将 php 应用程序从 apache 移至 nginx 服务器,现在我的 sentry 错误不再报告...我做错了什么?
这是我的 nginx 配置:
server {
root /var/www/services/some-sesrvice;
index index.php;
server_name *****.com;
access_log /var/log/nginx/some-service.access.log;
error_log /var/log/nginx/some-service.error.log;
location / {
try_files $uri $uri/ /index.php;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/*****./fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/*****./privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = *****.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name *****.com;
return 404; # managed by Certbot
}
和我的 php 调用
Sentry\init(['dsn' => 'https://*****.ingest.sentry.io/***' ]);
throw new Exception("Sentry is working on ".$_ENV['ENV']." machine!");
使用 composer.json 部分安装 Composer 时
"require": {
"sentry/sdk": "^3.1",
....
有什么想法或关于如何调试这个问题的任何想法吗?
更新
错误日志文件发现了这一点(因此捕获了错误):
2021/07/02 13:22:12 [error] 17232#17232: *193 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Exception: Sentry is working on TEST machine! in /var/www/services/some-service/Config/sentryloader.php:13
Stack trace:
#0 /var/www/services/some-service/Config/bootstrap.php(15): include()
#1 /var/www/services/some-service/index.php(6): include('/var/www/servic...')
#2 {main}
thrown in /var/www/services/some-service/Config/sentryloader.php on line 13" while reading response header from upstream, client: ****ip****, server: ****.com, request: "GET /get HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "****.com"
更新:snippets/fastcgi-php.conf
:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;