Reputation: 464
I have created a fresh Laravel application by using composer create-project
command. Then I put all the folders and files in /usr/share/nginx/html/
, which is the default document root for my nginx server. However everytime I runs the http://localhost
, it keeps displaying 403 Forbiden
. I tried creating a testing index.php (<? php_info();)
and it worked fine.
I've read somewhere that I need to set the containing folder (/html), as well as the app/storage
folder permission to 777 but still no luck.
Please help me. Thank you in advance.
Here is the nginx default.conf
Upvotes: 1
Views: 12606
Reputation: 3680
The accepted answer is correct - Laravel services from the public
folder and you need to tell nginx to look there - but also a little vague if you're bumping up against this problem. When you create new sites on a Homestead installation by adding them to your .yaml file and using vagrant provision
or vagrant up --provision
, the created nginx conf file will need editing before Laravel will serve files correctly.
Go to your CLI, and enter Homestead using vagrant ssh
or homestead ssh
. It will ask for your password, which by default is "vagrant".
Once you're in the virtual machine, type the following commands:
sudo nano /etc/nginx/sites-enabled/your-site-name-here
Then add /public
to the end of the existing root near the top of the file (it'll be something like /home/vagrant/projects/your-site
to begin with and save in Nano (ctrl+s), then exit nano (ctrl+x).
Once you've exited Nano, restart nginx using sudo nginx -s reload
. Your routing will now work!
Upvotes: 0
Reputation: 1442
Laravel projects serve from the <projectName>/public
directory. Make sure your nginx config is set up to look there for your index file and NOT in your <projectName>
folder only.
Upvotes: 8
Reputation: 169
Would you edit your question and paste your server config there?
I think it may because index.php is not in the index file list. check these lines:
index index.html index.php;
or
try_files $uri $uri/ =404;
Upvotes: 6