所有的Laravel路由在nginx上都没有find

试图在nginx服务器(第一次)上安装Laravel 4.1安装程序,并且我为每个Laravel路由而不是预期的视图提供“未find”。 主页面加载正常。

请注意,网站只能通过IP访问,这就是为什么我的填充IP为123.123.123.123 server_name

等/ 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/*; } 

等/ nginx的/现场可用/ 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; } } 

我遇到了像你这样的问题。

我在我的configuration文件中添加了这个,现在终于有效了!

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

如果server_name没有正确的IP地址,则请求将转到nginx默认的vhost。

如果您希望您的Laravel应用程序成为默认的ghost,请将default_server添加到mysite.conflisten指令中,并删除/etc/nginx/sites-enabled/default