NGINX + VPS-奇怪的404错误,直到重新启动

时间:2019-06-03 08:59:28

标签: nginx http-status-code-404 vps

我正在尝试为我的VPS Web服务器设置nginx,并在单独的文件夹中安装2种不同的wordpress。我没有使用nginx的经验,因为我一直使用apache和htaccess,所以可以得到任何帮助:)

我遇到一个奇怪的问题:浏览一个文件夹(/ markuz)时出现404错误,但它似乎不是由nginx生成的(如果我尝试其他未配置的文件夹,则使用nginx会得到404错误写在页脚上,但不在此特定文件夹上...)

我还遇到了第二个问题,例如漂亮的永久链接,例如/ wordpressfolder / product / name被重写为/ wordpressfolder / name等。

这是我的Nginx配置

# HTTP Server
server {
    listen 80;
    listen [::]:80;
    server_name _;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    root /var/www/nightwindworld.org/html;

    server_name nightwindworld.org www.nightwindworld.org;
    index index.php;

    ssl_certificate /etc/letsencrypt/live/nightwindworld.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nightwindworld.org/privkey.pem;
    ssl_protocols SSLv3 TLSv1.1 TLSv1.2;

    location /phpmyadmin {
    try_files $uri $uri/ /phpmyadmin/index.php$is_args$args;
            location ~ \.php$ {
                # default fastcgi_params
                include fastcgi_params;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # fastcgi settings
                fastcgi_pass                    unix:/var/run/php/php7.3-fpm.sock;
                fastcgi_index                   index.php;
                fastcgi_buffers                 8 16k;
                fastcgi_buffer_size             32k;

                # fastcgi params
                fastcgi_param SCRIPT_FILENAME   $request_filename;
            }
    }

    location /markuz {
    #root /var/www/nightwindworld.org/html/markuz;
        try_files $uri $uri/ /markuz/index.php$is_args$args;
        location ~ \.php$ {
        #root /var/www/nightwindworld.org/html/markuz;
            # default fastcgi_params
            include fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi settings
            fastcgi_pass                    unix:/var/run/php/php7.3-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_buffers                 8 16k;
            fastcgi_buffer_size             32k;

            # fastcgi params
            fastcgi_param SCRIPT_FILENAME   $request_filename;
        }
    }

    location /lepassionidimari {
        #root /var/www/nightwindworld.org/html/lepassionidimari;
    #alias /var/www/nightwindworld.org/html/;

    #if (!-e $request_filename) {
    #   rewrite ^ /lepassionidimari/index.php last; }

        try_files $uri $uri/ /lepassionidimari/index.php$is_args$args;
        location ~ \.php$ {
        #root /var/www/nightwindworld.org/html/lepassionidimari;
            # default fastcgi_params
            include fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi settings
            fastcgi_pass                    unix:/var/run/php/php7.3-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_buffers                 8 16k;
            fastcgi_buffer_size             32k;

            # fastcgi params
            fastcgi_param SCRIPT_FILENAME   $request_filename;
        }
    }

#    location / {
#        alias /var/www/nightwindworld.org/html/markuz/;
#    }

    location ~* .(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
    expires 30d;
    add_header Pragma "public";
    add_header Cache-Control "public";
    }
}

我在每个位置块中尝试了很多带有根/别名的组合,但始终存在404错误。 有趣的是,如果我重新启动vps计算机并首先打开/ markuz,则/ lepassionidimari会显示404错误,直到下次重新启动为止,反之亦然。

那会是什么? 谢谢:)

0 个答案:

没有答案