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

working example of phalcon on nginx

Hi,

Can anyone give me a working example of phalcon on nginx



51.1k
server {
    listen      80;
    server_name www.mysite.dev;
    set         $root_path '/path-to-project/public';
    root        $root_path;

    client_max_body_size 20M;

    access_log  /var/log/nginx/mysite.dev-access.log;
    error_log   /var/log/nginx/mysite.dev-error.log error;

    index index.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

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

    location ~ \.php {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;

        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

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

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

Also, reading the docs, sometimes can be very useful. https://docs.phalcon.io/en/latest/reference/nginx.html