1

I’m adding new pages in CI (CodeIgniter 3) including footer, header and other .php files (made by CodeCharge Studio), CI pages (controllers) are running throw a /ci.php file and every thing runs well on Apache2.

As I’m also migrating on NginX, when I call /ci.php it goes well and when I call the same output but from /ci.php/pages/test_pages I get the body part of my page and errors occurs to my included files:

[error] 12165#0: *698 FastCGI sent in stderr: "Unable to open primary script: /Users/fedibelkacem/Documents/workspace/eMashq/ci.php/pages/ClientI18N.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: emashq.fbe, request: "GET /ci.php/pages/ClientI18N.php?file=Functions.js&locale=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "emashq.fbe:81", referrer: "http://emashq.fbe:81/ci.php/pages/test_pages"

NginX is looking for Clientl18N.php in the wrong place. It is in the root and as I said, on Apache, it runs well.

Here is my NginX VHost config file:

server {
    listen 81;
    server_name emashq.fbe;

    root /Users/fedibelkacem/Documents/workspace/eMashq;

    index index.php index.html;

    location / {
            # if I put /index.php, it forces /ci.php/pages/test_pages to call 
            # /ci.php/pages/index.php and I get an other but the same type error 
            # with No input file specified on the screen!
            try_files $uri $uri/ /ci.php;
    }

    location ~* \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi_params;
    }
}
# $config['index_page'] = 'ci.php'; // or = ‘’ in CI\applications\config.php 
# doesn’t make difference!

Please help me find the right NginX conf to run my /ci.php/controller/etc.

1 Answers1

0

See this document for a number of suggestions to solve the Passing Uncontrolled Requests to PHP problem.

The uri includes pathinfo that must be handled separately, and transmitted to the ci.php script. A common solution is to change your location definition to something like:

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    ...
}

See also this document. Not all implementations have the same directives listed in the fastcgi_params file. You will need to ensure that the necessary information is being passed to your controller.

Richard Smith
  • 11,859
  • 2
  • 18
  • 26