1

I have a codeigniter application that has the following directory structure

<HOME>
  |_ <web>
  |    |_<API>
  |         |_index.php
  |_<admin>

The developers have an index.html in the , and directories. The codeigniter files and the services rolled out by the developers are in the directories. The developers access the services by appending the service name to the domain as follows http://mydomain/web/API/index.php/v1/GetRoles The host name is configured as a BASE PATH variable in a javascript file.

This app is served by NGINX running fast-cgi.

Though the HTML pages get loaded no data is being fetched. So we tried accessing the functions by typing the URL in the browser (http://mydomain/web/API/index.php/v1/GetRoles). We get a 404 Not Found error. The error logs contain the following entries

2016/05/20 16:14:57 [error] 2127#0: *232 FastCGI sent in stderr: "Unable to open primary script: /home/myname/public_html/domainname/public/projectname/index.php (No such file or directory)" while reading response header from upstream, client: 14.141.163.46, server: mydomain.com, request: "GET /web/API/v1/get/Common/GetActivities HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com"

The server should be looking for index.php in /home/myname/public_html/domainname/public/projectname/web/API/index.php instead its looking for it in the WEB ROOT.

My NGINX configuration is as follows

server {
    listen mydomain.com;
    server_name mydomain.com;
    root /home/myname/public_html/domainname/public/projectname; 

    keepalive_timeout 70;
    access_log /home/myname/public_html/domainname/log/access.log;
    error_log /home/myname/public_html/domainname/log/error.log;

    gzip_static on;

    index index.html index.php;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /usr/share/nginx/www;
    }

# pass the PHP scripts to FastCGI server listening on the php-fpm socket
    location ~ \.php$ {
            #try_files $uri =404;
            #fastcgi_pass unix:/tmp/php5-fpm.sock;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_intercept_errors on;
    }
}

I am unable to figure out why NGINX is looking for index.php in the WEB ROOT instead of loading whatever we type in the URL. Look forward to hear from anyone who have faced a similar problem.

1 Answer 1

0

As far as I can see from your request, you try to get /web/API/v1/get/Common/GetActivities, which is not a real folder. You might do location /web/API/v1/get/Common/GetActivities with root /home/myname/public_html/domainname/public/projectname/web/API or change your request path on /web/API/index.php

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .