栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

【无标题】

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【无标题】

nginx+wordpress搭建博客过程中报502
  • 问题描述
  • 问题分析
  • 解决问题
  • 附录

问题描述

在/etc/nginx/sites-available/default 中配置好了后访问域名,要么报502错误,要么访问文件就会下载。

问题分析

我的nginx目录是/etc/nginx/
nginx的主配置文件是/etc/nginx/nginx.conf
查看主配置文件,找到error log的位置:

error_log /var/log/nginx/error.log;

查看error.log发现报错:

2022/05/02 12:24:33 [crit] 8526#8526: *6 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 183.209.108.63, server: 1
01.132.237.235, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "www.yuanzhe.xyz"

意思是方收到请求index.php的时候找不到php7.0-fpm.sock文件

解决问题

经仔细核对发现我的fpm版本是7.2
在配置文件/etc/nginx/sites-available/default中修改fpm版本为7.2后,重启nginx(/etc/init.d/nginx restart),就可以通过域名访问了

附录

下面附上我的配置文件 /etc/nginx/sites-available/default

# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html/yuanzhe.xyz;

        # Add index.php to the list if you are using PHP
        index index.html index.php index.htm index.nginx-debian.html;

        server_name 101.132.237.235;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ .php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #       deny all;
        #}
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/850699.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号