在nginx上所有“未找到" Laravel路线 [英] All Laravel routes “not found” on nginx

查看:105
本文介绍了在nginx上所有“未找到" Laravel路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在nginx服务器上设置Laravel 4.1安装(第一次),对于每个Laravel路由都会给出未找到"信息,而不是预期的视图.主页加载正常.

Trying to setup Laravel 4.1 installation on a nginx server (first time) and I'm given "not found" for every Laravel route instead of the view expected. The main page loads fine.

请注意,只能通过IP访问站点,这就是为什么我为server_name使用填充IP 123.123.123.123.

Please note, site can only be accessed by IP which is why I have the filler IP 123.123.123.123 for server_name.

etc/nginx/nginx.conf:

etc/nginx/nginx.conf:

listen 80;

user  nginx;

worker_processes 4;

worker_rlimit_nofile 200000;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections 4000;

    use epoll;

    multi_accept on;
}

http {
    include       /etc/nginx/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"';

    include  /etc/nginx/conf.d/*.conf;
    include  /etc/nginx/sites-enabled/*;
}

etc/nginx/site-available/mysite.conf:

etc/nginx/site-available/mysite.conf:

server {
    listen 80;
    server_name  123.123.123.123 "";
    access_log  /srv/www/mysite/logs/access.log;
    error_log  /srv/www/mysite/logs/error.log;
    root  /srv/www/mysite/public_html/public;
    rewrite_log  on;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log /var/log/nginx/access.log main buffer=16k;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_proxied any;
    #gzip_proxied expired no-cache no-store private auth;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;

    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    sendfile on;

    tcp_nopush on;

    tcp_nodelay on;

    keepalive_timeout 90;

    keepalive_requests 100000;

    reset_timedout_connection on;

    client_body_timeout 30;

    send_timeout 30;

    # Remove trailing slash to please Laravel routing system.
    if (!-d $request_filename) {
        rewrite  ^/(.+)/$ /$1 permanent;
    }

    location / {
        index  index.html index.htm index.php;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
    }

    # We don't need .ht files with nginx.
    location ~ /\.ht {
        deny  all;
    }

    # Set header expirations.
    location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
        expires  365d;
    }
}

推荐答案

也许您应该给这个: http://daylerees.com/nginx-configuration-for-daylerees-dot-com .它可能会解决您的问题.

Maybe you should give this: http://daylerees.com/nginx-configuration-for-daylerees-dot-com a look. It might solve your problem.

这篇关于在nginx上所有“未找到" Laravel路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆