Hi,
I just installed my first droplet (LEMP) thanks to some information on DO tutorials. But I’m having a problem and I dont know what is the cause (or fix :) ) for the issue.
I created a new file in ‘sites-available’ with the following server block;
server {
server_name ~^(.+)\.dev\.mydomain\.nl$;
set $file_path $1;
root /home/dev-mydomain-nl/$file_path/public/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
As you can see, I created a wildcard subdomain which also has a variable root directory. I also installed the Laravel framework. When I visit a domain, I see Laravels default page. But as soon as I browser to an page (for example …nl/test/) I get the 403 - Forbidden page.
The error in the log file also states:
directory index of "/home/dev-mydomain-nl/mike/public/test/" is forbidden
What should happen, is that all trafic is routed to the index file (unless the file itself exists). But what should I change in the Nginx config?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The test directory does not exists. All traffic should be routed via the index.php file in the public directory (unless the requested file exists, like an image, CSS or js file of course :)).
But what should I change in the try_files?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.