【问题标题】:Nginx showing 404 no matter the config无论配置如何,Nginx 都显示 404
【发布时间】:2017-10-30 04:00:57
【问题描述】:

我目前在使用 nginx 时遇到了一些问题。无论我做什么配置,我都会得到 404 页面。 我正在按照说明为 laravel 设置 nginx。

项目所在文件夹为/var/www/smuvajse,主index.php位于public文件夹(完整路径将是 /var/www/smuvajse/public)

这是我的配置文件:

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/smuvajse/public;

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

server_name ip_of_the_instac;

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

        location / {
                try_files $uri $uri/ /index.php?$query_string;
         }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
        #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #}

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

【问题讨论】:

  • nginxerror.log 中有什么内容?

标签: nginx


【解决方案1】:

try_files $uri $uri/ =404;更改为try_files $uri $uri/ /index.php?q=$uri&$args;并重新加载nginx,它应该可以解决问题。

【讨论】:

  • 进行了更改,但我仍然得到 404:/
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-22
  • 2015-01-17
  • 2017-12-24
  • 2020-03-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多