Require and Includes not Functioning Nginx Fpm/FastCGI
Posted
by
Vince Kronlein
on Server Fault
See other posts from Server Fault
or by Vince Kronlein
Published on 2013-11-02T03:38:57Z
Indexed on
2013/11/02
3:56 UTC
Read the original article
Hit count: 291
I've split up my FPM pools so that php will run under each individual user and set the routing correctly in my vhost.conf files to pass the proper port number.
But I must have something incorrect in my environment because on this new domain I set up, require, require_once, include, include_once
do not function, or rather, they may not be getting passed up to the interpreter to be rendered as php.
Since I already have a Wordpress install on this server that runs perfectly, I'm pretty sure the error is in my server block for nginx.
server {
server_name www.domain.com;
rewrite ^(.*) http://domain.com$1 permanent;
}
server {
listen 80;
server_name domain.com;
client_max_body_size 500M;
index index.php index.html index.htm;
root /home/username/public_html;
location / {
try_files $uri $uri/ index.php;
}
location ~ \.php$ {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?name=$1 break;
}
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
The problem I'm finding I think is that there are dynamic calls to the doc root index file, while all calls to anything within a sub-folder should be routed as normal ie: NOT passed to index.php.
I can't seem to find the right mix here.
It should run like so:
domain.com/cindy (file doesn't exist) --> index.php?name=$1
domain.com/admin/anyfile.php (files DO exist) --> admin/anyfile.php?$args
© Server Fault or respective owner