php路由显示404,Laravel配置路由出现404解决办法

环境:Lnmp(nginx+php+mysql)

今天在搭建Laravel框架的时候访问显示空白页:

解决如下:

cd laravel

chmod -R 777 storage

在配置Laravel路由的时候报了404错误

首先分析下问题:一般出现这种情况的都是apache或者nginx配置出现问题

nginx解决办法

在location里面加上 try_files $uri $uri/ /index.php?$query_string;

如果配置文件中存在 try_files $uri $uri/ =404;需要将它注释掉或者删掉,否则会报错

鄙人的nginx配置如下:

worker_processes 1;

events {

worker_connections 1024;

}

http {

include mime.types;

# include /app/soft/nginx/conf/vhost/*.conf;

default_type application/octet-stream;

client_max_body_size 50m;

client_header_buffer_size 50M;

large_client_header_buffers 4 50M;

log_format main '$server_name $remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for" '

'$ssl_protocol $ssl_cipher $upstream_addr $request_time $upstream_response_time';

sendfile on;

keepalive_timeout 65;

server {

listen 80;

server_name localhost;

send_timeout 60;

location / {

root /app/www/laravel/public;

access_log /app/log/access.log;

error_log /app/log/error.log debug;

try_files $uri $uri/ /index.php?$query_string;

index index.php index.html index.htm;

}

location ~ \.php$ {

root /app/www/laravel/public;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffers 8 128k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

include fastcgi_params;

}

}

这样就ok了,现在可以开启你的laravel模式了~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值