Laravel Homestead: 403 forbidden on nginx

后端 未结 16 2225
醉话见心
醉话见心 2020-12-30 19:17

I just installed Laravel Homestead according to their instructions. When I open http://homestead.app:8000 I get the nginx 403 forbidden HTTP Response.

I have tried s

相关标签:
16条回答
  • 2020-12-30 19:36

    Change the config of Nginx

    Put that line in 'location /' section:

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

    If its not working then replace your 'public' with the folder name that content 'index.php',

    That worked great with me using ServerPilot,

    Good luck!.

    0 讨论(0)
  • 2020-12-30 19:37

    Check nginx error in you vagrant box

    vagrant ssh

    sudo cat var/log/nginx/yoursite.tld-error.log

    "*1 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/code/public/index.php (No such file or directory)" "

    Change in Homestead.yaml

    nano Homestead.yaml

    to map: homestead.app to: /home/vagrant/code/Laravel/public

    then..

    vagrant reload --provision

    0 讨论(0)
  • 2020-12-30 19:38

    Another reason for this response can be duplicating your routing with folders in public directory. For example you might have homestead.app/lists GET route and lists folder in your /public directory. This will cause the same 403 error (server will assume you are trying to access /public/lists directory instead of your /lists route).

    0 讨论(0)
  • 2020-12-30 19:40

    I have been banging my head against the wall dealing with this very same problem, and I just solved it for my case.

    I was sure I'd set up the yaml file correctly, but I kept getting the 403 error, and when experimenting with some routes I was getting "input file not specified".

    My solution came from http://laravel.com/docs/4.2/homestead and it involved using the serve command. I wasn't adding any additional sites, just trying to anything to get the first site running.

    SSH'ing into my vagrant box and using the command "serve my_app_name.app /home/vagrant/Code/path/to/public" did the job. Note that I had already put an entry into my hosts file for this app.

    Hope this helps someone.

    0 讨论(0)
  • 2020-12-30 19:43

    Access in your browser

    homestead.app/public
    

    Before installation of laravel/laravel with composer within /home/vagrant/Code/Laravel/public

    0 讨论(0)
  • 2020-12-30 19:44

    I had the same problem and for me the cause was that in the Homestead.yaml file, I have incorrectly put this:

    sites:
    - map: homestead.app
      to: /home/vagrant/Code
    

    Instead of the correct syntax:

    sites:
    - map: homestead.app
      to: /home/vagrant/Code/path/to/public
    
    0 讨论(0)
提交回复
热议问题