This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Install & configuration » eZPublish 5 - working NGINX...
expandshrink

eZPublish 5 - working NGINX configuration

eZPublish 5 - working NGINX configuration

Wednesday 28 November 2012 9:17:03 am - 3 replies

Hi there,

I want to share my NGINX configuration, probably not perfect and some sort of basic, but working so far. Maybe we can enhance these settings together over time...

 server {
        listen 80;
        server_name example.com;
 
        client_max_body_size 20M;
 
        access_log /var/log/nginx/ezpublish5/access.log;
        error_log /var/log/nginx/ezpublish5/error.log notice;
 
        rewrite_log off;
 
        set $ezp_root /var/www/ezpublish5/web;
        set $fastcgi_port 9000;
 
        root $ezp_root;
        index index.php;
 
        location / {
 
                rewrite ^/api/([^/]+)v1/?$ /index_rest.php break;
                rewrite ^/var/(([^/]+/)?)storage/images(-versioned)?/(.*)$ /var/$1storage/images$2/$3/$4 break;
                rewrite ^/var/(([^/]+/)?)cache/(texttoimage|public)/(.*)$ /var/$1cache/$3/$4 break;
                rewrite ^/design/([^/]+)/(stylesheets|images|javascript|fonts)/(.*)$ /design/$1/$2/$3 break;
                rewrite ^/share/icons/(.*)$ /share/icons/$1 break;
                rewrite ^/extension/([^/]+)/design/([^/]+)/(stylesheets|images|javascripts|javascript|flash|lib?)/(.*)$ /extension/$1/design/$2/$3/$4 break;
                rewrite ^/packages/styles/(.+)/(stylesheets|images|javascript)/([^/]+)/(.*)$ /packages/styles/$1/$2/$3/$4 break;
                rewrite ^/packages/styles/(.+)/thumbnail/(.*)$ /packages/styles/$1/thumbnail/$2 break;
                rewrite ^/var/storage/packages/(.*)$ /var/storage/packages/$1 break;
                rewrite ^/favicon\.ico$ /favicon.ico break;
                rewrite ^/robots\.txt$ /robots.txt break;
                rewrite ^/w3c/p3p\.xml$ /w3c/p3p.xml break;
                #rewrite ^/var/(([^/]+/)?)cache/debug\.html$ /var/$1cache/debug.html break;
                rewrite ^/bundles/(.*)$ /bundles/$1 break;
 
                if (-f $request_filename) {
                      break;
                }
 
                if (!-e $request_filename) {
                        rewrite ^(.+)$ /index.php$1 last;
                        break;
                }
        }
 
        location ~ ^/(index|index_dev|config)\.php(/|$) {
                fastcgi_pass 127.0.0.1:$fastcgi_port;
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME    $ezp_root$fastcgi_script_name;
                fastcgi_param  HTTPS  off;
        }
}

Modified on Wednesday 28 November 2012 9:24:19 am by Dirk Blicker

Wednesday 05 December 2012 9:36:15 am

Hi, thanks for sharing this!

Did you manage to get the ezpublish 5 setup assistant to run on nginx? I can't get past the first step but I've done it successfully on apache so I'm thinking it could be related to something in nginx.

Wednesday 05 December 2012 5:04:01 pm

@Rayomond - maybe the problem is the same as described here: http://share.ez.no/forums/ez-publish-5-forum-formerly-known-as-new-php-api/ezsetup-does-nothing/%28offset%29/last ?

Saturday 18 May 2013 8:39:14 am

tiny note:
I guess the following:

set $ezp_root /var/www/ezpublish5/web;
...
fastcgi_param  SCRIPT_FILENAME    $ezp_root$fastcgi_script_name;

could be easily replaced with

root /var/www/ezpublish5/web;
...
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

and

     rewrite_log off;

could be removed, too, since it's anyhow the default.

btw: did you skip the following in purpose?

 location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|swf|flv|eot|ttf|woff|svg)$ {
    access_log        off;
    expires           30d;
    }

Modified on Saturday 18 May 2013 8:48:37 am by Francesco Ronzon

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from