Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon + nginx + php_fpm #22

Closed
netandreus opened this issue Jun 29, 2012 · 7 comments
Closed

Phalcon + nginx + php_fpm #22

netandreus opened this issue Jun 29, 2012 · 7 comments

Comments

@netandreus
Copy link

Hello, how can i setup phalcon test app in nginx environment?
I receive this error message:

Mod-Rewrite is not configured!
Seems that your mod-rewrite module is missing or not configured. Enable it to get this application working properly.

Phalcon installed at /home/andrey/sandbox/phalcon.dev
nginx config:

server {
    listen 80;
    server_name phalcon.dev;
    set $root_path '/home/andrey/sandbox/$host';
    root $root_path;

    access_log /var/log/nginx/$host-access.log;
    error_log  /var/log/nginx/phalcon-error.log error;

    index index.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

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

    location ~ \.php {
        # try_files $uri =404;

        fastcgi_index /public/index.php;
        fastcgi_pass 127.0.0.1:9000;

        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/public;
    }

    location ~ /\.ht {
        deny all;
    }
}
@phalcon
Copy link
Collaborator

phalcon commented Jun 29, 2012

Hi @netandreus, your document root should include the public directory too.

set $root_path '/home/andrey/sandbox/$host/public'

And

rewrite ^/(.*)$ /index.php?_url=$1;

regards,

@netandreus
Copy link
Author

It works. Thanks a lot!

@phalcon phalcon closed this as completed Jun 29, 2012
@jerejones
Copy link
Contributor

It should be noted using rewrite is not the recommended way to handle front controllers for nginx. Instead, use this:

try_files $uri $uri/ /index.php?_url=$uri&$args;

Using this will only rewrite urls to files that don't exist. Urls to assets like images and css will go through unmolested.

@netandreus
Copy link
Author

I'm using such way:
try_files $uri $uri/ @rewrite;
see above

ovr pushed a commit to ovr/cphalcon that referenced this issue Dec 25, 2013
Fixed spelling of Utils::addSlashes() which fixes error on line 578 of Library/ClassMethod.php
@swobjects
Copy link

formy Webserver ( nginx) this doesnt resolve anything. I still get also the Error page
Mod-Rewrite is not enabled

Please enable rewrite module on your web server to continue

any special params for create-project for nginx instead of apache2?

@hex0gen
Copy link

hex0gen commented Dec 16, 2015

@jerejones , You're the greatest coder in over the world! Thx a lot.

@arcechava
Copy link

arcechava commented Aug 15, 2016

I can't fix given that I'm using Vagrant

server {
    listen      80;
    server_name localhost.dev;
    root        /var/www/html/public;
    index       index.php index.html index.htm;

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

    location ~ \.php$ {
        try_files     $uri =404;

        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index /index.php;

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants