1

I'm having an issue where when I go to the /public directory it shows the Laravel app as normal, but navigating away to any other page results in it saying

No input file specified.

I am using an Nginx server with PHP 5.5.9 FPM.

I've scoured google for the last 4 hours or so, looking at every tutorial and stackoverflow page for rewriting issues in Laravel however they all yield the same result.

I've even set all the files and folders to 777 so I could see if it was some sort of permissions issue. I've checked the Laravel config and it's all set, I've no idea what is wrong.

Can anyone point me in the right direction?

The last config I tried is below:

server {
    listen 80 default_server;

    root /usr/share/sites/base;
    index index.php
    server_name localhost;
    location / {
            try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            include fastcgi_params;
    }
}

I have also tried many others such as:

server {

            listen          80;
            server_name     domain.com;

            root            /usr/share/sites/base;
            index           index.php;


            location / {

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

            }

    if (!-d $request_filename) {

            rewrite ^/(.+)/$ /$1 permanent;

    }


    location ~* \.php$ {

            # Server PHP config.
            fastcgi_pass                    unix:/var/run/php5-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_split_path_info         ^(.+\.php)(.*)$;

            include                         /etc/nginx/fastcgi_params;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

    location ~ /\.ht {
            deny all;

    }

    }

1 Answer 1

1

The error "No input files specified" will nearly always be related to the fact that the wrong path was sent to php.

Looking at your 'last config tried' I can see that fastcgi_param SCRIPT_FILENAMEis not defined in your php location. You should first begin by defining it in the location :

location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
}

Furthermore you say that you can reach the app so this means that index.php is working but not when you change page. So the problem should also come from /index.php?$args. Indeed, using this line if I try to reach yourserver.com/test and if 'test' is not a file in your root path nginx will then try request /index.php? (I had this probem). You should try only with /index.php.

EDIT : The solution was that root directive should point to the Laravel public folder, in that case /usr/share/sites/base/public.

Sign up to request clarification or add additional context in comments.

4 Comments

Ah, Your answer made me realise that I needed to specify /public on the root in order to make it work. Thanks for your help!
Oh I thought 'base' was your Laravel public folder, didn't even think about it ! Did you change anything else ?
I decided to use the longer config out of the two, not sure if the first one works or not.
'/index.php?$query_string' is, according to Laravel doc, needed for pretty urls. (Despite the fact I do use a Laravel app that doesn't require this line to work properly). We can see that SCRIPT_FILENAME is defined in the php location. Depending on the app, 'fastcgi_index index.php' could be needed but it's absolutely possible that it could work without it if you define /index.php in try_files directive. The \.ht location is needed if Apache doc root concurs with Nginx one. It will prevent .htaccess file. It appears to me that the if statement acts like a "warranty"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.