0

I am looking for some help configuring my nginx to allow laravel routes to work correctly, I have found numerous tutorials giving slightly different ways but to no avail.

following: nginx configuration for Laravel 4 seems quite close to what I need, however I am getting the error No input file specified.

when I look into the error log I can see that instead of my route going to eg /url/index.php/args it is instead being routed to /url/args/index.php

Cœur
  • 37,241
  • 25
  • 195
  • 267
David Craig
  • 164
  • 2
  • 13
  • It could be a number of things, and the routing that you see in the error log is fine—all Laravel requests begin at index.php, and the Laravel router takes over from there. The first thing to check would be permissions on the storage directory; have you run `sudo chmod -R 775 /var/www/laravel/app/storage`? – damiani Sep 21 '14 at 12:10
  • changing the permissions of app/storage was one of the first things I needed to do :) it works if I use the full url/index.php/test I just want it to work on url/test – David Craig Sep 21 '14 at 12:38
  • also, the routing is not fine, this would mean it's looking for a folder called args and then hit index.php from within that folder, which can't happen. – David Craig Sep 21 '14 at 12:45

2 Answers2

2

This is my nginx app configuration file, and it's all you need to make it work, and, nginx doesn't make use of .htaccess:

server {
    listen 80;
    server_name laravel.dev;
    root /var/www/laravel/public/;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log /var/log/nginx/laravel.dev-access.log combined;
    error_log  /var/log/nginx/laravel.dev-error.log error;

    error_page 404 /index.php;

    sendfile off;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

}
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
  • And once again we have this fastcgi_split_path_info matching on `\.php$`. This works because everything that doesn't exist is rewritten to the root index.php. So this config does not work for a file `/foo/bar.php`, that is requested as `/foo/bar.php/test/path/info`, unless the root index.php knows how to deligate to that file. This also relies on a fastcgi_params that is specific to some Linux distributions. Last but not least, the h5bp reference seems local to me. –  Sep 22 '14 at 17:04
  • H5bp removed, it is just a good practice: https://github.com/h5bp/server-configs-nginx – Antonio Carlos Ribeiro Sep 22 '14 at 17:08
  • Ah, thanks for the ref. Shame this config will nuke your Magento backend, as it stores thumbnails in .thumbs and references them in the media browser. Off-topic, but a nice project. –  Sep 22 '14 at 17:39
0

I managed to get my site working, I think at least one of the configs I had already tried was correct however my sites-enabled copy of the config was a copy and not a symlink so my changes weren't actually updating.

David Craig
  • 164
  • 2
  • 13