userguy
userguy

Reputation: 107

nginx+php-fpm issue not able to call other php files in folder

I have a nginx and php-fpm config but when i access it from browser, only index.php is getting executed but rest of the files i am not able to call .

nginx config

{
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    use epoll;
    multi_accept on;
}

http {
keepalive_timeout 15;
    keepalive_requests 2048;
    server_tokens off;

   upstream php
{
    server unix:/tmp/php-cgi.socket;
   server serverip:9000;
}

 access_log  /var/log/nginx/access.log  main;
include /etc/nginx/conf.d/*.conf;

}

config in /etc/nginx/conf.d/

    server {

        root /var/www/Cachet/public/;
       location / {
     try_files $uri $uri/ /index.php index.php;
    }
        server_name  serverip ; # Or whatever you want to use
        listen 80 default;
        location ~* \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_keep_conn on;
                    include fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }




}

These are few lines from error.log and access.log

2015/11/06 12:40:53 [error] 19346#0: *1 FastCGI sent in stderr: "Unable to open primary script: /var/www/Cachet/public/dashboard.php (No such file or directory)" while reading response header from upstream, client: Client IP, server: Server IP, request: "GET /dashboard.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "Server IP"

2015/11/06 12:41:05 [error] 19346#0: *1 FastCGI sent in stderr: "Unable to open primary script: /var/www/Cachet/public/autoload.php (No such file or directory)" while reading response header from upstream, client: Client IP, server: Server IP, request: "GET /autoload.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "Server IP"

Upvotes: 0

Views: 1240

Answers (2)

Rohit G
Rohit G

Reputation: 1

Check if your installed PHP version and PHP version inside config.d do not match each other. If that is the case, change PHP version inside conf.d file to your installed PHP version. Reload nginx.

fastcgi_pass unix:/var/run/php5-fpm.sock;

Upvotes: 0

userguy
userguy

Reputation: 107

since there was no response here then with help from my colleague i was able to find two problem here in config file because of which i was not able to call multiple php files in separate folder ..

try_files $uri $uri/ /index.php index.php; 
instead it needed 
try_files $uri $uri/ /index.php$is_args$args;

Alos since it was not loading the images the line which was missing was include /etc/nginx/mime.types; in location block of conf.d/default.conf.

Upvotes: 0

Related Questions