eZ Community » Forums » Discussions » eZ Publish 4.2011 Community (4.5)...
expandshrink

Friday 06 May 2011 6:45:56 pm - 17 replies

» Read full tutorial

Introduction

After completing this tutorial, you should have a working eZ Publish 4.2011 Community (or 4.5) installation running on a single Debian 6 server with the following features:

  • Nginx 1.0.0+ as web server
  • PHP 5.3.6+ invoked through PHP-FPM (FastCGI Process Manager)
  • APC (Alternative PHP Cache)
  • Rewrites for friendly URLs (virtual host mode)
  • Proper http cache headers for static files
  • Gzip compression
 

Monday 09 May 2011 12:24:36 pm

Great tutorial! Well done and thanks for sharing to the community.

I've been using Nginx for some times now but as a proxying server. I've basically configure it to proxy cache all binary files and optionally forward the requests to dynamic content to another server running with Apache. Then using a modified all2evcc extension I can clear the cache on publishing by calling the purge URL handled by NGX Cache Purge plugin.

Monday 09 May 2011 12:58:58 pm

For purging cache of reverse proxies upon content publishing, ezflow and ezworkflowcollection extensions can do it too (only drawback: only for current node url, no smart view cache mgmt)

Saturday 04 June 2011 2:08:22 pm

Update: with the recent Dotdeb packages, the tutorial should work exactly the same on a Debian 5 "Lenny" server, with the following exception:

in /etc/apt/sources.list, add

deb http://packages.dotdeb.org oldstable all
deb-src http://packages.dotdeb.org oldstable all

instead of 

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

Modified on Saturday 04 June 2011 2:12:37 pm by Daniel Arnrup-Øien

Saturday 11 June 2011 11:03:43 pm

Thanks for sharing this! I'm seriously considering ditching Apache from my development environment and replacing it with Nginx.

I still have one small problem. Your set of rewrite rules works like a charm but index.php is still in the url string. This used to work in Apache (even with the rewrite rules in .htaccess, although I needed the ForceVirtualHost=true ini setting).

Anyone got a solution to this?

Edit: I had a misconfiguration in the MatchOrder. Don't know how this reflected on the above problem, but solved!

Modified on Sunday 12 June 2011 4:16:14 pm by Sander van den Akker

Friday 19 August 2011 10:32:00 am

Another detail that you might find useful: to control upload filesizes, there are three settings that you need to configure, one of which is particular to Nginx.

In the server block of your nginx sites (usually in /etc/nginx/sites-available/mysite, or in /etc/nginx/nginx.conf if you're not using sites)  you need to add (examples using 50 MB):

client_max_body_size 51m;   

Where XX is the desired maximum post size. This needs to be slightly higher than upload_max_filesize (see below).

You should also set in php.ini (/etc/php5/fpm/php.ini):

upload_max_filesize = 50M

post_max_size = 51M

The last one needs to be higher than upload_max_filesize as it takes into account other POST data in addition to the actual file.

Tuesday 21 February 2012 10:39:17 am

Great tutorial. well explained and very easy to have it working on my dev machine. 

Thanks!

Monday 27 February 2012 9:15:36 pm

Glad to hear it was useful, Carlos happy.gif Emoticon

On a side note, it seems one of the rewrite rules may be broken:

rewrite "ezjscore/call/?$" "/index_ajax.php" break;

Comment this out if you are experiencing problems such as priority changes not working in admin2. I only noticed this after upgrading to 2011.8 and at first erroneously attributed the problem to the eZ release.

I have yet to set aside a day or two to truly optimise Nginx rewrites for eZ, but I'll try to give it some tender loving care when I'm in the mood happy.gif Emoticon

Monday 23 April 2012 4:37:16 pm

Great tutorial, thanks!

I have to point something out. The following nginx rule is wrong:

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|swf|flv|eot|ttf|woff|svg)$ {

In my case it forces 404 errors with url endings with "ico", "eot"... (ie: http://www.domain.com/mypico)

Should be (escaping the "."blunk.gif Emoticon:

location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|swf|flv|eot|ttf|woff|svg)$ {

Cheers

Tuesday 24 April 2012 11:09:00 am

Quote from Jose Ignacio Honrado :

Should be (escaping the "."blunk.gif Emoticon:

location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|swf|flv|eot|ttf|woff|svg)$ {

Cheers

Thanks, I've updated the online version.

Wednesday 17 October 2012 5:31:06 pm

Hi everybody, 

many thanks Daniel for this article, we've been taking advantage from it so many times. Everything have been working perfectly smooth.

Now we have to move to RHEL: do you, Daniel, or you guys, know if there are big differences from the way nginx + ez it's installed in Debian, vs. RHEL?  suggestions? tricks?

are there other howto for RHEL as good as this one for Debian?

 

thanks

/francesco

Saturday 20 October 2012 11:29:20 am

Quote from Francesco Ronzon :

Now we have to move to RHEL: do you, Daniel, or you guys, know if there are big differences from the way nginx + ez it's installed in Debian, vs. RHEL?  suggestions? tricks?

are there other howto for RHEL as good as this one for Debian?

thanks

/francesco

I post here the results of our installation on RHEL 6, with some advice that may help others:

Installed following this howto: http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/

it was pretty smooth then adapting this Debian howto to REHL.  Here some little differences: 

* the bad is that nginx run with user "nginx", and php-fpm run with user "apache".  Changing nginx user to "apache" is easy, but we did not make it to create user "www-data" and running php-fpm correctly with that user: so at the end we left php-fpm running with user "apache" (so changing ownership of ez document root accordingly).

* in /etc/nginx/fastcgi_params we had to add the following line

fastcgi_param  SCRIPT_FILENAME    $request_filename;

the rest seems the same so far.

does anybody know additional issues? 



Monday 29 October 2012 11:25:55 am

ezjscore not working? nginx method not allowed? 405? 

add this on the nginx virtual host:

if (!-f $request_filename) {

  rewrite ^(.*)$ /404;

}

Thursday 22 November 2012 8:37:41 pm

Quote from Francesco Ronzon :

* in /etc/nginx/fastcgi_params we had to add the following line

fastcgi_param  SCRIPT_FILENAME    $request_filename;

First of all, sorry for the late reply - I hadn't been watching this thread for a while, but it's nice to see people are using it happy.gif Emoticon

The above is standard on the Debian 6 distribution of nginx - and for comparison, here are all the standard fastcgi_params values:

fastcgi_param QUERY_STRING   $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE   $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME   $fastcgi_script_name;
fastcgi_param REQUEST_URI   $request_uri;
fastcgi_param DOCUMENT_URI   $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
#fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

Modified on Thursday 22 November 2012 8:47:50 pm by Daniel Arnrup-Øien

Thursday 27 June 2013 11:27:34 pm

Hi Daniel,

with the virtualhost you suggest (and that we are using in several websites) some *.php are exposed, e.g. http://www.openconc.....pt.no/runcronjobs.php

do you think is all right? shouldn't we hide such responses?

 

/thanks

Modified on Thursday 27 June 2013 11:43:29 pm by Francesco Ronzon

Thursday 27 June 2013 11:46:17 pm

and, to enable treemenu, ezjscore and index_rest we just had to add the following

  rewrite "content/treemenu/?$" "/index_treemenu.php" last;
  rewrite "ezjscore/call/?$" "/index_ajax.php" last;
  rewrite "^/api/(.*)$" "/index_rest.php" last;

how does it sound?  it works apparently...

Friday 28 June 2013 12:13:55 am

Quote from Francesco Ronzon :

Hi Daniel,

with the virtualhost you suggest (and that we are using in several websites) some *.php are exposed, e.g. http://www.openconc.....pt.no/runcronjobs.php

do you think is all right? shouldn't we hide such responses?

 

/thanks

maybe should we solve it with

 

location ~ "^/(index|index_rest|index_ajax|index_treemenu)\.php$"

in the first line of

 

location ~ "^/[^/]*\.php$" {
  set $script "index.php";
  if ( $uri ~ "^/(.*\.php)" ) {
     set $script $1;
  }
  fastcgi_pass   unix:/tmp/php-fpm.sock;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME $document_root$script;
  include        fastcgi_params;
}

am I missing something?

Friday 08 November 2013 4:48:17 pm

to be able to download binary files (i.e. *.jpg) from /content/download we had to modify

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

into

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

It works, but we are not sure it's the best fix.

expandshrink

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

36 542 Users on board!

Forums menu