Dan WalmsleyCoding so you don't have to

I’ve been sitting here all day bashing my head against one simple problem – getting Concrete5 working behind Nginx.

Concrete5 is a beautiful, simple php-based CMS – a loud answer to the complexity of Joomla and Drupal, but of course missing some of the power too. It’s perfect for web sites that aren’t managed by total geeks.

Nginx is the world’s fastest and most efficient web server. Hands down, no competition, no argument.

The problem I had integrating the two stems from nginx+php-fastcgi not correctly passing through the PATH_INFO variable so you can have URLs like “http://example.com/index.php/path/to/file”.

The solution was to slightly alter the usual php-fastcgi parameter processing. Below is my complete config for my concrete5 site. This worked on Debian Lenny with nginx 0.7.59.

 

 
server {
        listen          80;
        server_name     www.example.com;
        autoindex on;
 
	location / {
	       root /var/www/example.com/concrete5/;
                index index.php;
 
		if (!-f $request_filename){
                   set $rule_0 1$rule_0;
               }
               if (!-d $request_filename){
                    set $rule_0 2$rule_0;
               }
               if ($rule_0 = "21"){
                    rewrite ^/(.*)$ /index.php/$1 last;
               }
	}
 
        location ~ \.php($|/) {
           set  $script     $uri;
            set  $path_info  "";
 
            if ($uri ~ "^(.+\.php)(/.+)") {
              set  $script     $1;
              set  $path_info  $2;
            }
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  /var/www/example.com/concrete5$fastcgi_script_name;
	  fastcgi_param URI $uri; 
	  fastcgi_param PATH_INFO $path_info;
          include        /etc/nginx/fastcgi.conf;
        }
}
This entry was posted in General. Bookmark the permalink.

4 Responses to Running Nginx with Concrete5

  1. Philip King says:

    Thanks for this post really saved me a lot of time.

  2. Tom says:

    Thanks for the tip. Very helpful. I’ll try it out.
    As for Nginx not having competitors, from my experience there are both commercial (Zeus) and open source (Cherokee) web servers that are even faster.

    I haven’t been able to run Cherokee with Concrete5, though. Not yet.

  3. Gaëtan says:

    It works for me with
    fastcgi_param SCRIPT_FILENAME /var/www/example.com/concrete5$script;

  4. andreas says:

    wow thanks! saved me time!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Browse by Topic