Some Issues with Configuration

Steve Holdoway steve at greengecko.co.nz
Thu Mar 6 05:19:31 UTC 2014


Hi!

On Wed, 2014-03-05 at 21:18 +0000, Richard Ibbotson wrote:
> On Wednesday 05 Mar 2014 21:03:22 Jonathan Matthews wrote: 
> > Nginx doesn't execute PHP. It passes each request destined for your
> > blog (i.e. the locations you decide are "your blog") to another
> > process that runs/is-running the PHP. Take a look here, and it might
> > help:
> 
> >> http://wiki.nginx.org/WordPress<<
> 
> I'll have a read through this again.  The part that might work is...
> 
>    location /blog {
>                 try_files $uri $uri/ /blog/index.php?$args;
>         }
>  
>         location ~ \.php$ {
>                 fastcgi_split_path_info ^(/blog)(/.*)$;
>         }
> 
> But... I have not just /blog but others.  Such as /journalism and 
> others.  Do I just put in another location for that ?  Such as ....
> 
>   location /journalism {
>                 try_files $uri $uri/ /journalism/index.php?$args;
>         }
>  
>         location ~ \.php$ {
>                 fastcgi_split_path_info ^(/journalism)(/.*)$;
>         }
> 
> > If you're still stuck, please have a google before asking more
> > questions here. There are many, many, *many* articles out there,
> > explaining how to get Nginx+PHP/WordPress working, and the config
> > you posted above strongly suggests you've not read any of them yet!
> > The Internet is your friend ... ;-)
> 
> I spent a month doing that.  Been going to ApacheCon since 2001.  Done 
> most international GNU/Linux and BSD conferences.  Seen a few things.  
> I'm a bit lost on NGINX configuration.  Something new to learn :)
> 

Nginx is just acting as a switch here, so in the location block for .php
files, you need to hand over to php for further processing. This is
usually done via fastcgi to php-fpm - especially for the performance
gains after using APC, etc...

You can do this in one of two ways: I use the more convoluted one...

in nginx.conf, define a php backend:

http { 
	...
    	upstream  backend  {
        	server unix:/var/run/php5-fpm.sock;
    	}
}

( ensure that the php-fpm process is listening on that socket - you can
also use ports )

in the site config pass them over:

	location ~ \.php$ {
		fastcgi_split_path_info ^(/journalism)(/.*)$;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_pass backend;
	}

That should approximately do it - depending on the contents
of /etc/nginx/fastcgi-params which I modified years ago!

hth,

Steve
-- 
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa



More information about the nginx mailing list