Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

后端 未结 6 919
日久生厌
日久生厌 2020-12-08 22:57

I\'ve just deploy a new laravel 7 application on AWS Elastic beanstalk. I\'ve noticed they changed the Apache server to Nginx server.

https://docs.aws

6条回答
  •  佛祖请我去吃肉
    2020-12-08 23:33

    So I just had this issue and had to figure it out. The default php implementation doesn't factor in the folder difference that laravel causes (and this isn't mentioned anywhere in the docs)

    You need to track down your nginx site config on your ec2 server. For me it was:

    /etc/nginx/conf.d/elasticbeanstalk/php.conf
    
    sudo nano php.conf
    

    root default is /var/www/html; This is incorrect, the laravel folder is added here, you need to add this in:

    root /var/www/html/your-laravel-app-name/public;
    

    You will need to be in your ec2 server for this, so you can always navigate to that folder and check it.

    I'm sure other people will be able to provide what's need to auto-configure this in the elastic beanstalk environment.

    I also added the following lines to the nginx config for a base laravel config:

    location / {
       try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ /\.ht {
       deny all;
    }
    
    location ~ /.well-known {
       allow all;
    }
    

提交回复
热议问题