We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Problem with nginx configuration on vagrant

Hello, first of all, i want to say hi :) I am new on forum. I have a small problem with configuration nginx for phalcon. I am using vagrant, and the box is: https://github.com/slogsdon/vagrant-phalcon

Phalcon works, but only loads IndexController, and if i go to: localhost:8081:/users, phalcon loads IndexController, not UsersController. It's becouse i don't configure nginx. So i try to do this.

Now, my nginx.conf file is:

 user www-data;
 worker_processes  1;

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

events {
    worker_connections  1024;
    # multi_accept on;
}

http {

    types_hash_max_size 2048;
    include       /etc/nginx/mime.types;
    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server {

        listen   8081;
        server_name localhost;

       index index.php index.html index.htm;
       set $root_path '/vagrant/www/src/Public';
       root $root_path;

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

      location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
      }

      location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
          root $root_path;
      }

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

I don't konw many about nginx configuration... but when i run "sudo nginx -s reload" i hav an error:

nginx: [emerg] open() "/etc/nginx/fastcgi_params" failed (2: No such file or directory) in /etc/nginx/nginx.conf:54

line 54 in nginx.conf file is:

include fastcgi_params;

What's the problem?

edited May '14

Hi @JacekJagiello

try this:

location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_param REQUEST_URI $uri?$args;
            include        fastcgi_params;
}

here is a full example of my nginx setup for INVO (development only)

// invo.dev config
    server {

        listen    80;
        server_name invo.dev;

        index index.php index.html index.htm;
        set $root_path '/usr/local/var/www/invo/public';

        root $root_path;

        try_files $uri $uri/ @rewrite;

        location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/$1;
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_param REQUEST_URI $uri?$args;
            include        fastcgi_params;
        }

        location ~*^/(css|img|js|flv|swf|download)/(.+)$ {
            root $root_path;
        }

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

Would love to have both your input on https://github.com/phalcon/cphalcon/issues/10981, I want to produce a new vagrant VM using 14.04, just played around a bit this AM, but it looks like you both know a bit about vagrant and phalcon