Ask About Framework-Nginx

Dear All,

Im a System Admin from Indonesia.
I have a little trouble with Engine-X (nginx).
My server can recognize PHP & FCGI well, but a trouble appear when I use
a FuseBox frame work in my server.
I assume that the troubles are here:
~ when server access a page like this:

Engine-X will parse that as folder (identified by slash (/)), but that
doesn’t really a folder. Those are a fuseBox parsing methode.
I run this application in Apache, and everything going well.

What should I do ?

This is my nginx.conf and config:

user detik users;
worker_processes 10;
pid /var/run/;
events {
worker_connections 1024;
http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] ’
'“$request” $status $body_bytes_sent “$http_referer” ’
‘“$http_user_agent” “$http_x_forwarded_for”’;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript
text/xml application/xml application/xml+rss text/javascript;
server {
client_max_body_size 50M;
# doc root
root /data/labdetiksport/site/sport;
#access_log /var/log/nginx.vhost.access.log main;
access_log /var/log/httpd/jkt6.detiksport-access.log main;
error_log /var/log/httpd/jkt6.detiksport-error.log debug;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;

location / {
  proxy_set_header  X-Real-IP  $remote_addr;
  # If the file exists as a static file serve it directly without
  # running all the other rewite tests on it
  if (-f $request_filename) {

  # check for index.html for directory index
  # if its there on the filesystem then rewite
  # the url to add /index.html to the end of it
  # and then break to send it to the next config rules.
  if (-f $request_filename/index.html) {
    rewrite (.*) $1/index.html break;

  # Look for existence of PHP index file.
  # Don't break here...just rewrite it.
  if (-f $request_filename/index.php) {
    rewrite (.*) $1/index.php;

  # this is the meat of the rails page caching config
  # it adds .html to the end of the url and then checks
  # the filesystem for that file. If it exists, then we
  # rewite the url to have explicit .html on the end
  # and then send it on its way to the next config rule.
  # if there is no file on the fs then it sets all the
  # necessary headers and proxies to our upstream mongrels
  if (-f $request_filename.html) {
    rewrite (.*) $1.html break;
location /content_images/ {
    alias /data/images/;

error_page   500 502 503 504  /500.html;
location = /500.html {
  root   /data/labdetiksport/site/sport;

# Pass the PHP scripts to FastCGI server listening on ip:port.
# Requires you to start one instance of
location ~ .php$ {
fastcgi_index index.php;

    fastcgi_param  SCRIPT_FILENAME 

include /usr/local/nginx/conf/fastcgi.conf;
#fastcgi_param QUERY_STRING $query_string;
#fastcgi_param REQUEST_METHOD $request_method;
#fastcgi_param CONTENT_TYPE $content_type;
#fastcgi_param CONTENT_LENGTH $content_length;


----------------------------------------------------------end of

Description: PHP-FastCgi start script from

Author: Alexey Kovyrin

Comments by: Geoffrey Grosenbach

This script is started once and receives PHP requests from Nginx for

all apps. The Nginx config passes the full path to the script being

requested, so

only one fastcgi runner is needed for all apps, virtual hosts, etc.

See also the init.d script for starting this on boot.

To install PHP, I had to also compile the following:

* GNU M4 - GNU Project - Free Software Foundation


* with './configure --prefix=/usr/local


ABSOLUTE path to the PHP binary


tcp-port to bind on


IP to bind on


number of PHP children to spawn


number of request before php-process will be restarted


allowed environment variables sperated by spaces


if this script is run as root switch to the following user


################## no config below this line

if test x$PHP_FCGI_CHILDREN = x; then


if test x$UID = x0; then

EX=“/bin/su -m -c "$PHPFCGI -q -b $FCGIADDR:$FCGIPORT" $USERID”

EX=“/usr/local/bin/php -q -b detik”

echo $EX

copy the allowed environment variables


for i in $ALLOWED_ENV; do
E=“$E $i=${!i}”

clean environment and set up a new one

nohup env - $E sh -c “$EX” &> /dev/null &

----------------------------------------------------------end of

Thank you very much for your kind attentions.

best regards,

On Thu, Dec 27, 2007 at 01:33:46PM +0700, dika wrote:

I run this application in Apache, and everything going well.

What should I do ?

location ~ \.php($|/) {

     set   $script     $uri;
     set   $path_info  "";

     if ($uri ~ "^(.+\.php)(/.+)") {
         set   $script     $1;
         set   $path_info  $2;


     fastcgi_param  SCRIPT_FILENAME 

fastcgi_param PATH_INFO $path_info;


Thank you very much Mr. Sysoev, it’s nicely work!

----- Original Message -----
From: “Igor S.” [email protected]
To: [email protected]
Sent: Thursday, December 27, 2007 2:25 PM
Subject: Re: Ask About Framework-Nginx

Hi Igor,

On 27 Dec 2007, at 07:25, Igor S. wrote:


    fastcgi_param  SCRIPT_FILENAME  /data/labdetiksport/site/ 

fastcgi_param PATH_INFO $path_info;

We find that PATH_INFO becomes ORIG_PATH_INFO when read from the
environment by PHP.
Is there any way to keep it as PATH_INFO, so as to keep the PHP
software compatible with Apache?

Thanks very much,

On Wed, Jan 09, 2008 at 11:27:06AM +0000, Igor C. wrote:


Is there any way to keep it as PATH_INFO, so as to keep the PHP
software compatible with Apache?

This PHP issue. Looking in PHP sources, it seems that
cgi.fix_pathinfo=0 in php.ini should fix it.

That’s great Igor, that means we should be able to use it on earlier
versions of PHP.

Many thanks.

Hi - it seems this is a PHP issue, fixed in v5.2.4. Sorry for the noise!

Best wishes