Welcome! Log In Create A New Profile

Advanced

Re: How to setup nginx to make php works in site subdirectories

Francis Daly
February 12, 2012 03:12PM
On Sun, Feb 12, 2012 at 01:04:30PM -0500, dimentiy wrote:

Hi there,

> Yes, I have another 'location' but within the another 'server'

If you have no other location{} in the server{} block that is being used,
and you can see from the access log that the browser is actually making the
request and not using a cached version, then I'm afraid that I have no
idea what your system is doing.

> Exactly I have four 'servers' with different root. Like
> 'one.example.com', 'two.example.com', 'three.example.com',
> 'four.example.com'.
> Each of them are similar and looks like I posted above as I said the
> difference is only in root (location / { root xxx; }).

When I use a config like what you posted, I see no problem.

(Generally, you don't put "root" inside a location{} block unless you
know why you are doing it. Leave it inside the server{} block and things
are clearer.)

Can you provide an exact config file that shows the problem, that I can
copy-paste and demonstrate the problem myself? Usually, if you begin
with a simple config file and just add a few lines at a time, it will
become clear at what point things stopped working as you expect.

> You say that verything is fine and should already work. Sounds cool.
> I'm dummy with nginx and php-fpm.

Using this config file

===
events {
worker_connections 1024;
debug_connection 127.0.0.1;
}

http {
server {
listen 8000;
server_name one.example.com;
root /usr/local/nginx/one;
index index.html index.htm index.php;

location / {
}
location ~ php {
fastcgi_pass backend;
include fastcgi.conf;
}
}
server {
listen 8000;
server_name two.example.com;
root /usr/local/nginx/two;
index index.html index.htm index.php;

location ~ php {
fastcgi_pass backend;
include fastcgi.conf;
}
}
upstream backend {
server unix:php.sock;
}
}
===

I get the expected results from each of

curl -i -H Host:\ one.example.com http://localhost:8000/
curl -i -H Host:\ one.example.com http://localhost:8000/get.php
curl -i -H Host:\ one.example.com http://localhost:8000/sub/get.php

curl -i -H Host:\ two.example.com http://localhost:8000/
curl -i -H Host:\ two.example.com http://localhost:8000/sub/
curl -i -H Host:\ two.example.com http://localhost:8000/sub/index.php
curl -i -H Host:\ two.example.com http://localhost:8000/sub/get.php

where I see (respectively) the content of /usr/local/nginx/one/index.htm,
and then the php-processed output of /usr/local/nginx/one/get.php,
/usr/local/nginx/one/sub/get.php, /usr/local/nginx/two/index.php,
/usr/local/nginx/two/sub/index.php (twice), and
/usr/local/nginx/two/sub/get.php,

The only difference between

include fastcgi.conf;

and

include fastcgi_params;

is that the former includes the line

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

so that it doesn't have to be added separately.

(Note also that the "~ php" locations are probably not exactly what you
want on a live site.)

If you still have a problem with your configuration, please include the
usual debug details:

* what did you do
* what did you see
* what did you expect to see

and someone may have a better chance of reproducing what you are seeing.

> Could you tell, please, how to enable debug log?

http://nginx.org/en/docs/debugging_log.html
http://wiki.nginx.org/Debugging

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to setup nginx to make php works in site subdirectories

dimentiy February 12, 2012 06:00AM

Re: How to setup nginx to make php works in site subdirectories

Joe February 12, 2012 06:12AM

Re: How to setup nginx to make php works in site subdirectories

dimentiy February 12, 2012 06:33AM

Re: How to setup nginx to make php works in site subdirectories

Joe February 12, 2012 07:22AM

Re: How to setup nginx to make php works in site subdirectories

dimentiy February 12, 2012 12:48PM

Re: How to setup nginx to make php works in site subdirectories

Francis Daly February 12, 2012 08:00AM

Re: How to setup nginx to make php works in site subdirectories

dimentiy February 12, 2012 01:04PM

Re: How to setup nginx to make php works in site subdirectories

dimentiy February 12, 2012 01:14PM

Re: How to setup nginx to make php works in site subdirectories

dimentiy February 12, 2012 03:28PM

Re: How to setup nginx to make php works in site subdirectories

Francis Daly February 12, 2012 03:12PM

Re: How to setup nginx to make php works in site subdirectories

Francis Daly February 12, 2012 04:54PM

Re: How to setup nginx to make php works in site subdirectories

Max February 12, 2012 07:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 121
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready