V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
station
V2EX  ›  NGINX

nginx 配置哪里出错了 ?

  •  
  •   station · 2020-01-25 10:01:31 +08:00 · 4542 次点击
    这是一个创建于 1524 天前的主题,其中的信息可能已经有所发展或是发生改变。
    整了台机子,搭建 NAS,其中 nextcloud 卡在 lnmp 的配置上

    centos 8 全套 dnf 安装
    输入 ip,页面就是 File not found.
    参考了搜索结果,感觉没问题啊


    #定义 Nginx 运行的用户和用户组
    user nginx nginx;

    #nginx 进程数,建议设置为等于 CPU 总核心数
    worker_processes 1;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    # 进程 Pid 文件
    #pid /var/run/nginx/nginx.pid;


    events {
    use epoll;
    worker_connections 1024;
    }


    http {
    include mime.types;
    default_type application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log logs/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;

    server {
    listen 80;
    server_name localhost;
    root /var/www/nextcloud;
    index index.html index.htm;
    charset utf-8;

    #access_log logs/host.access.log main;

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    fastcgi_pass unix:/run/php-fpm/www.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }
    }
    19 条回复    2020-01-26 16:52:49 +08:00
    eason1874
        1
    eason1874  
       2020-01-25 10:33:09 +08:00
    这两行改成这样试试,记得重启 Nginx。

    listen 80 default_server;
    server_name _;
    station
        2
    station  
    OP
       2020-01-25 10:37:01 +08:00
    @eason1874 还是不行....
    xiri
        3
    xiri  
       2020-01-25 10:39:59 +08:00 via Android
    你没有把 index.php 加进 index 里,,,,,,

    root
    iamverylovely
        4
    iamverylovely  
       2020-01-25 10:40:20 +08:00 via Android
    路径后面加个斜杠看看。☺
    xiri
        5
    xiri  
       2020-01-25 10:40:39 +08:00 via Android
    @xiri index index.html index.htm 改成
    index index.html index.htm index.php
    Buges
        6
    Buges  
       2020-01-25 11:29:55 +08:00 via Android   ❤️ 1
    没什么特殊要求的话,Web 服务器建议用 caddy,省时省力配置简单明了。
    laowudxf
        7
    laowudxf  
       2020-01-25 12:43:41 +08:00
    你监听的是 sock 文件 你的备注写的是监听 9000 端口,你 php-fpm 有没有设置对
    black11black
        8
    black11black  
       2020-01-25 13:15:36 +08:00
    你的 fpm 提交确实有问题,一般安装目录都是带版本号的,你这个应该是直接把代码贴过来的吧。另外不成功可以尝试把 Documentroot 写死。可以开 f12 看一下返回头里是否有 xphp 解析信息

    另外问一下 nextcloud 是开原的 nas 系统吗?买群晖和自建方案比起来哪个合适?
    w0nglend
        9
    w0nglend  
       2020-01-25 14:38:23 +08:00
    nextcloud 可以直接用 docker 跑起来。不用折腾
    daimaosix
        10
    daimaosix  
       2020-01-25 17:20:21 +08:00
    配置一下伪静态
    daimaosix
        11
    daimaosix  
       2020-01-25 17:21:57 +08:00
    xfspace
        12
    xfspace  
       2020-01-25 18:03:35 +08:00 via Android
    文件夹 /结尾


    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    $document_root 直接引用 root 值

    /var/www/nextcloudindex.php

    /var/www/nextcloud/index.php
    station
        13
    station  
    OP
       2020-01-25 18:48:35 +08:00
    @black11black

    fpm 的路径是默认配置 ls /var/run/php-fpm 结果: php-fpm.pid 和 www.sock

    nextcloud 是开源的,但不是 nas 系统:一个私有网盘套件
    station
        14
    station  
    OP
       2020-01-25 18:54:30 +08:00
    @w0nglend 惭愧不会 docker

    @laowudxf 不要在意注释,那个是没修改的

    @xiri 试过,一样的结果
    MrUser
        15
    MrUser  
       2020-01-25 19:45:43 +08:00
    检查下 php-fpm 的 sock 路径与你 nginx 里写的是不是一致
    millionart
        16
    millionart  
       2020-01-25 20:24:25 +08:00
    https://www.digitalocean.com/community/tools/nginx
    用这个生成吧,或者照着一行行改
    Yourshell
        17
    Yourshell  
       2020-01-25 20:32:55 +08:00   ❤️ 1
    看日志啊
    justrand
        18
    justrand  
       2020-01-26 12:09:25 +08:00 via Android
    对啊,为什么不先看下错误日志呢?
    neighbads
        19
    neighbads  
       2020-01-26 16:52:49 +08:00
    nextcloud 太大了。。。用了半年换成了 caddy
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3707 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 10:39 · PVG 18:39 · LAX 03:39 · JFK 06:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.