简体   繁体   English

带有Laravel的Nginx HHVM返回404文件未找到

[英]Nginx HHVM with Laravel returning 404 File Not Found

I've just set HVVM on debian machine. 我刚刚在debian机器上设置了HVVM。 My issue is that when I access a laravel route it returns this strange message: 404 File Not Found , however, if I make a new .php file in the public directory of the laravel, everything works safe and sound. 我的问题是,当我访问laravel路由时,它返回以下奇怪消息:404 File Not Found,但是,如果我在laravel的公共目录中创建了一个新的.php文件,一切都会安全无事。 Here are my nginx and hhvm conf files: 这是我的nginx和hhvm conf文件:

hhvm.conf: hhvm.conf:

    location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $request_filename;
    include        fastcgi_params;
}

nginx configuration: nginx配置:

    server {
            # Make site accessible from http://localhost/
            server_name ***;

            gzip on;
            gzip_comp_level 2;
            gzip_http_version 1.0;
            gzip_proxied any;
            gzip_min_length 1100;
            gzip_buffers 16 8k;
            gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

            # Disable for IE < 6 because there are some known problems
            gzip_disable "MSIE [1-6].(?!.*SV1)";

            # Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
            gzip_vary on;

            listen 80 default_server;


            root /var/www/***/public_html/laravel/public;
            index index.php index.html index.htm;


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

            include hhvm.conf;

            location /doc/ {
                    alias /usr/share/doc/;
                    autoindex on;
                    allow 127.0.0.1;
                    allow ::1;
                    deny all;
 }
}

So what may be wrong? 那怎么可能出问题了?

Well, in my case the problem was the nginx block configuration. 好吧,在我的情况下,问题是nginx块配置。

Replacing: 更换:

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

with: 与:

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

did the trick. 做到了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM