FAQ

Page Discussion History

Difference between revisions of "Magento"

m (Replace "^~" with "~" for hiding directories)
m (added ^ before first slash to ensure that its matching from root)
(2 intermediate revisions by one user not shown)
Line 52: Line 52:
 
     expires 30d;
 
     expires 30d;
 
   }
 
   }
   location ~ /(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
+
   location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
 
   location /var/export/ { internal; }
 
   location /var/export/ { internal; }
 
   location /. { return 404; }
 
   location /. { return 404; }
Line 67: Line 67:
 
   }
 
   }
 
}
 
}
 +
</geshi>
 +
 +
 +
Fooman Speedster is a popular extension that requires editing your server configuration.  If you use it add this at the bottom of one of the server configurations above, right before the closing bracket.
 +
 +
<geshi>
 +
rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
 +
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
 +
 +
location /lib/minify/ {
 +
  allow all;
 +
}
 
</geshi>
 
</geshi>

Revision as of 20:53, 28 July 2013

Magento is becoming a very popular web based commerce system.

This config currently seems to work for the <1.4 versions

server {
  server_name example.com;
  root /var/www/vhost/example.com/htdocs;
  access_log /var/log/nginx/example.com.access.log main;
  index index.php;
 
  location / {
    try_files $uri $uri/ /index.php?$args; 
  }
 
  # set a nice expire for assets
  location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
    expires    max;
    add_header Cache-Control public;
  }
 
  # the downloader has its own index.php that needs to be used
  location ~* ^(/downloader|/js|/404|/report)(.*) {
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$1/index.php$1;
    fastcgi_read_timeout 600;
    fastcgi_pass  127.0.0.1:9000;
  }
 
  location ~* \.php {
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_read_timeout 600;
    fastcgi_pass  127.0.0.1:9000;
  }
 
}


This config works for version 1.7:

server {
  root	   /home/magento/web/;
  index	   index.php;
  server_name	magento.example.com;
  location / {
    index index.html index.php;
    try_files $uri $uri/ @handler;
    expires 30d;
  }
  location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
  location /var/export/ { internal; }
  location /. { return 404; }
  location @handler { rewrite / /index.php; }
  location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
  location ~* .php$ {
    if (!-e $request_filename) { rewrite / /index.php last; }
    expires off;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param MAGE_RUN_CODE default;
    fastcgi_param MAGE_RUN_TYPE store;
    include fastcgi_params;
  }
}


Fooman Speedster is a popular extension that requires editing your server configuration. If you use it add this at the bottom of one of the server configurations above, right before the closing bracket.

 rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
 rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
 
 location /lib/minify/ {
   allow all;
 }