Nginx使用中的小问题 作者: Hogwarts 发布于: 2022-12-26 更新于: 2023-03-28 分类: 默认分类 #问题 **问题1**、使用 NGINX 官方源安装,启动程序发现 Systemd 中存在报错:Can't open PID file /var/run/nginx.pid (yet?) after start: No such file or directory **原因**:Nginx 启动时 PID 文件并未生成,导致文件无法读取 **解决**:在 /usr/lib/systemd/system/nginx.service 中添加如下语句即可,作用是在执行可执行文件前等待 0.1s。 ExecStartPost=/bin/sleep 0.1 **参考**:`https://www.24kplus.com/others/1770.html` **问题2**、使用反代时报错nginx: [emerg] unknown "connection_upgrade" variable **解决**:nginx配置文件出了问题,将下面map代码块补到 http {}中即可。 map $http_upgrade $connection_upgrade { default upgrade; '' close; } **参考**: `https://github.com/jupyterhub/jupyterhub/issues/781` `https://segmentfault.com/a/1190000018712908` **问题3**、connect() to unix:/run/php/php8.2-fpm.sock failed (13: Permission denied) while connecting to upstream **原因**:由于/run/php/php8.2-fpm.sock的用户是www-data而 nginx 的用户是 nginx,用户名字不匹配造成权限问题。 **解决**:把 nginx 的权限改为 www-data。将nginx.conf中的 user:nginx 改为user:www-data **问题4**、/var/cache/nginx/proxy_temp/9/17/0000000179" failed (13: Permission denied) while reading upstream **原因**:从用户nginx改为www-data后,www-data没有访问的权限。 **解决**:停止nginx进程,`rm -rf /var/cache/nginx/*` **参考**:`https://serverfault.com/questions/235154/permission-denied-while-reading-upstream` 标签: nginx