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

[STICKY][discussion] How to setup on NGINX #622

Closed
FAlbanni opened this issue Mar 2, 2015 · 8 comments
Closed

[STICKY][discussion] How to setup on NGINX #622

FAlbanni opened this issue Mar 2, 2015 · 8 comments

Comments

@FAlbanni
Copy link

FAlbanni commented Mar 2, 2015

Hey thank you for this framework is great, but still not 100% functional at my end...

Do you have any experience with nginx? if so can you recommend me some rewrite rules?

I am using right now...

location /{
try_files $uri $uri/ @Huge;
}

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

but it doesn't do it

thank you again!

@FAlbanni
Copy link
Author

FAlbanni commented Mar 2, 2015

I make it work!!!

    location / {
            try_files $uri $uri/ @huge;
    }

    location @huge {
            rewrite ^/(.*)$ /index.php?url=$request_uri last;
    }

it took me a good hour to figure it out lol

this is all you need for using this amazing framework with nginx, enjoy!

@panique
Copy link
Owner

panique commented Mar 5, 2015

Thanks you very very much, I'll test it and work this into the readme within the next weeks.

@panique panique changed the title Nginx rewrite rules [3.1][improvement] Nginx rewrite rules Mar 5, 2015
@FAlbanni
Copy link
Author

FAlbanni commented Mar 7, 2015

Well the configuration I posted before didn't work with GET requests, this one 100% works, I personally checked.

Here you have an standard configuration for Nginx that works with Huge, so you can include it as a basic starting point in the documentation

server {
    # your listening port
    listen 80;

    # your server name
    server_name example.com;

    # your path to access log files
    access_log /srv/www/example.com/logs/access.log;
    error_log /srv/www/example.com/logs/error.log;

    # your root
    root /srv/www/example.com/public_html;

    # huge
    index index.php;

    # huge
    location / {
        try_files $uri /index.php?url=$uri&$args;
    }

    # your PHP config
    location ~ \.php$ {
        try_files $uri  = 401;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

@panique panique changed the title [3.1][improvement] Nginx rewrite rules [3.x][improvement] Nginx rewrite rules Mar 9, 2015
@panique panique added the v3.x label Mar 14, 2015
@ghost
Copy link

ghost commented May 11, 2015

Hello!
It's my version

if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?url=/$1 last;
break;
}

@panique panique changed the title [3.x][improvement] Nginx rewrite rules [STICKY][discussion] How to setup on NGINX Jul 9, 2015
@panique
Copy link
Owner

panique commented Sep 7, 2015

Hey @Jumong and @FAlbanni , can I ask you if this now runs fine on your side ? I would like to collect some infos about how huge runs on nginx and what the people use as configs.

@FAlbanni
Copy link
Author

FAlbanni commented Sep 8, 2015

@panique it runs 100% perfect with my last config the @Jumong way even if it works is incorrect and totally discouraged since it will lead to problems.

@panique
Copy link
Owner

panique commented Oct 11, 2015

Thanks, I'll close this ticket as this is now part of the readme, and the main solution here is linked from there.

@panique panique closed this as completed Oct 11, 2015
@paradxum
Copy link

OK, so I know this is closed, but Since I spent about a day trying to figure this out I wanted to give others a solution. All the above solutions assume that the entire website is using huge. I have a client with a website that is wordpress. For various reasons, the myaccount section will not use wordpress at all, but will use huge. So, we need huge in it's own suburl. Here is the nginx config for that (to be put in the server block above any default location matches):

        location @huge {
                rewrite ^/myaccount2/(.*)$ /myaccount2/index.php?url=/$1 last;
                }

        location ~ ^/myaccount2/ {
                root /websites/website/private_data/huge;
                try_files $uri $uri/ @huge;

                location ~ \.php$ {
                        fastcgi_pass   $php_socket;
                        fastcgi_index  index.php;
                        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
                        include        fastcgi_params;
                        }
                }

yes, it's a combination of a couple earlier comments, but it was non-trivial for me at least.

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

3 participants