Magento安装在Nginx下的配置

来源:互联网 发布:q宠大乐斗门派数据详解 编辑:程序博客网 时间:2024/06/05 09:10
参考 http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento 

假设域名www.abc.com要配置指向magento(服务器的d:/abc.com/shop目录)应用,配置如下: 
Conf代码  收藏代码
  1. server {  
  2.     listen 80;  
  3.     server_name abc.com;  
  4.     rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www  
  5. }  
  6.   
  7. server {  
  8.     listen       80;  
  9.     server_name  www.abc.com;  
  10.     set  $DOC_ROOT d:/abc.com/shop;  
  11.     root $DOC_ROOT;  
  12.     location / {  
  13.         index index.html index.php; ## Allow a static html file to be shown first  
  14.         try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler  
  15.         expires 30d; ## Assume all files are cachable  
  16.     }  
  17.   
  18.     ## These locations would be hidden by .htaccess normally  
  19.     location ^~ /app/                { deny all; }  
  20.     location ^~ /includes/           { deny all; }  
  21.     location ^~ /lib/                { deny all; }  
  22.     location ^~ /media/downloadable/ { deny all; }  
  23.     location ^~ /pkginfo/            { deny all; }  
  24.     location ^~ /report/config.xml   { deny all; }  
  25.     location ^~ /var/                { deny all; }  
  26.   
  27.     location /var/export/ { ## Allow admins only to view export folder  
  28.         auth_basic           "Restricted"; ## Message shown in login window  
  29.         auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword  
  30.         autoindex            on;  
  31.     }  
  32.   
  33.     location  /. { ## Disable .htaccess and other hidden files  
  34.         return 404;  
  35.     }  
  36.   
  37.     location @handler { ## Magento uses a common front handler  
  38.         rewrite / /index.php;  
  39.     }  
  40.   
  41.     location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler  
  42.         rewrite ^(.*.php)/ $1 last;  
  43.     }  
  44.   
  45.      location ~ .php$ { ## Execute PHP scripts  
  46.         if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss  
  47.    
  48.         expires        off; ## Do not cache dynamic content  
  49.         fastcgi_pass   127.0.0.1:9000;  
  50.         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;  
  51.         fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores  
  52.         fastcgi_param  MAGE_RUN_TYPE store;  
  53.         include        fastcgi_params; ## See /etc/nginx/fastcgi_params  
  54.     }  
  55.       
  56.     location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {  
  57.         root  $DOC_ROOT;  
  58.         index  index.php;  
  59.         access_log off;  
  60.         expires 30d;  
  61.    }  
原创粉丝点击