1

I'm trying to run nginx and php-cgi on my Windows PC, I've got up to the point where I want to move the html directory back two directory's so I can sort of create a structure.

The only problem I have now is that PHP doesn't pick up any .php file. I have tried loading a static html file (localhost/test.html) and it works fine but localhost/info.php doesn't work at all.

Can anyone give me some guidance on this? The part of the server block can be found below.

server { listen 80; server_name localhost; root ../../www; index index.html index.htm index.php; #charset koi8-r; #access_log logs/host.access.log main; location ~ \.php$ { fastcgi_pass 127.0.0.1:9123; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 

3 Answers 3

4

Don't use a relative path in the root directive. Use the absolute path.

2

php-cgi on Windows has a bug concerning relative paths apparently:

[PHP-BUG] Bug #54955 [NEW]: FastCGI doesn't recognize Windows relative paths

Your solutions are:

  1. Absolute paths like what Michael Hampton said.
  2. Junctions.
2

If you are using an NGINX stack on a local machine for development, there might be a preconfigured setting that is playing Gotcha:

open_basedir = "c:/webserver.;c:/” 

Here is where I discovered the error on Windows with WinNMP:

Today I wanted to try out Nginx server my windows machine. After setting up the basic server block details for my project, I called the site URL. In the WT-NMP stack to quickly setup the software I needed. In the server block, I needed to specify my root path in a different location other than WWW.

Then when I hit the URL, I was getting “No Input File Specified” for my PHP script.

Now I’m not much of a reader so I just goggled here and there and didn’t found much of a fix. So then I reviewed the php log files. There I got the error message as my project folder path is not within the allowed path(s): (c:/wt-nmp)

So basically I had to edit php.init open_basedir value to include the path I stored my project. However here I could see that even the driver is considered to be as a path. So I ended up placing the driver letter since if I want to store more websites in my ‘d’ drive, I would not encounter this error. This is the final line. I have bold my text to indicate the change I made.

open_basedir = “c:/wt-nmp.;d:/”

“Happy Nginx, is a good Nginx.”

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.