M
M
Misha Behersky2015-04-15 10:43:09
PHP
Misha Behersky, 2015-04-15 10:43:09

How to properly configure nginx with php?

There is something like this nginx configuration.

server {
        listen       80;
        server_name  localhost;
        ...
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

I want to make two-three-who-more routes, each of which corresponds to a separate folder with its own scripts. I do it like this:
location /first {
        root c:/one/folder;
        index index.php;
    }
        
    location /second {
        root d:/different/location;
        index index.php;
    }
        
    location /third {
        root relative/path;
        index index.php;
    }

But it looks like the root directives are being ignored (or I'm using them incorrectly). It works only if you write root c: / one / folder; in the server block. Then everything will be fine for localhost/first , but for the rest it says No input file specified. .
What do you need / how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2015-04-15
@OnYourLips

You are using the webserver configuration for routing within the application, this is not correct.
If you have different applications, then use different server {} blocks with different hosts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question