Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

we're using php-fpm and have trouble getting the scripts to work if we change the 'root' value in nginx.conf.

location ~ \.php$ {
root /usr/share/nginx/html ;

If we change that root to point to other directory, even if it's /usr/share/nginx/html/crap, it wouldn't work. The directory exists of course. It's like it can read the file in that directory, but not execute it. I've checked all file permissions. Anyone has any idea?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Config which you provided in question will serve php files as a static file with root "root". "root" directive affects only static data.

php-fpm is a fastcgi process manager for php. For fastcgi in nginx there is a bundle of paramters starts with "fastcgi_" prefix.

If you use php-fpm, you probably want php scripts be executed by php-fpm worker. So, nginx should fastcgi_pass requests that addressed to php, to apropriate php-fpm pool.

Something like

location ~* \.php {
   fastcgi_pass 127.0.0.1:9000;
}
share|improve this answer

can you give more info on your nginx setup ie do you have vhosts or just one site. if vhosts are you using sited-enabled, sites-available setup or similar. it might be easier to so this and just include the locations for sited-enabled like so "include /usr/local/nginx/sites-enabled/*;" in nginx config then create the two folders with a vhost file in one with specific rewrite rules etc and then ln -s it into the sited-enabled folder. the vhost files can point to a folder in your home directory for example and you shouldnt have any permissions problems etc. this wont help with the npm setup but should point you in the right direction re initial setup and config of nginx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.