jimasun
jimasun

Reputation: 644

How to correctly configure Nginx for PHP (Yii framework and Zurmo)

I am trying to setup Zurmo CRM on my local machine (Win8x64). After installing all the requirements I want to get started with the actual installation. The problem is that it seems the paths are not correctly passed from NGinx to FastCGI PHP. Here is my Nginx serve configuration:

server {

    listen       80;
    server_name  zurmo.local;
    root         html/zurmo.local;
    set $index   "index.php";

    charset utf-8;

    location / {
        index  index.html $index;
        try_files $uri $uri/ /$index?$args;
    }

    location ~ ^/(protected|framework|themes/\w+/views) {
        deny  all;
    }

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        try_files $uri =404;
    }

    location ~ \.php {

        fastcgi_split_path_info  ^(.+\.php)(.*)$;

        set $fsn /$index;
        if (-f $document_root$fastcgi_script_name){
            set $fsn $fastcgi_script_name;
        }

        fastcgi_pass   127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fsn;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
    }

    location ~ /\.ht {
        deny  all;
    }
}

As a result, when I make a call to zurmo.local (which is added to hosts file) i get "This webpage has a redirect loop" with a URI that looks like this http://zurmo.local/app/app/ [...] /app/app/index.php If instead of $document_root$fsn and I comment the PATH_INFO and PATH_TRANSLATED than I get No input file specified. with a URI that looks like http://zurmo.local/app/app/index.php

Looking further into it, when I have added access_log html/zurmo.local/logs/access.log; the Nginx error.log shows me the following: [timestamp] [emerg] 4064#3660: CreateFile() "[path to stack]\nginx/html/zurmo.local/logs/access.log" failed (3: The system cannot find the path specified). As you can see the directory separator is not consistent.

One last note, my Nginx home directory is situated at nginx/html which is in fact a smlink to of ../home This is purely for keeping my file structure in a way that fits my day to day work.

How can I correctly configure Nginx in order to proceed (with the Zurmo installation) ?

Upvotes: 3

Views: 5893

Answers (2)

racerklm
racerklm

Reputation: 21

I know this is an old question, but here is what I have done to make nginx + zurmo work.

server {
    listen       80;
    server_name  zurmo.local;
    root         /home/www/zurmo.local;
    access_log   /var/log/nginx/zurmo.access.log main;
    index index.php;

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

    location ~ ^/(protected|framework|themes/\w+/views) { deny all; }
    location ~ /\. { deny all; access_log off; log_not_found off; }
    location = /favicon.ico { log_not_found off; access_log off; }
    location ~ \.(js|css|png|jpg|gif|ico|pdf|zip|rar)$ {
        try_files $uri =404;
    }

    location ~ \.php {
        fastcgi_split_path_info  ^(.+\.php)(.*)$;

        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;

        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;

        fastcgi_read_timeout 600s;
        fastcgi_send_timeout 600s;
    }
}

Upvotes: 2

Michael Härtl
Michael Härtl

Reputation: 8607

I don't think you need the if() statement in your *.php block. In my nginx setups that's all i ever needed:

# Process PHP files
location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    # Include the standard fastcgi_params file included with nginx
    include fastcgi_params;

    fastcgi_param  PATH_INFO        $fastcgi_path_info;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    fastcgi_pass 127.0.0.1:9000;
}

Upvotes: 0

Related Questions