ini nginx下magento的配置文件。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini nginx下magento的配置文件。相关的知识,希望对你有一定的参考价值。

#####################################################
# 
# Provided by the Magento Support Center
# http://magentosupport.help/knowledgebase/configuring-nginx-to-work-with-magento-advanced/
#
# Your Magento Tutorial specialists
#
server {
    listen       *:8080;
    server_name  fanatik.redrokk.com www.fanatikbike.com fanatikbike.com;
    root /home/production/www.fanatikbike.com/web/webroot/;
    
    ##
    # redirect to www
    ##
    #if ($host !~* ^www\.) {
    #    rewrite ^(.*)$ http://www.$host$1 permanent;
    #}

    ##
    # dont log robots.txt requests
    ##
    location /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
 
    ## These locations would be hidden by .htaccess normally
    location ^~ /app/                { deny all; }
    location ^~ /includes/           { deny all; }
    location ^~ /lib/                { deny all; }
    location ^~ /media/downloadable/ { deny all; }
    location ^~ /pkginfo/            { deny all; }
    location ^~ /report/config.xml   { deny all; }
    location ^~ /var/                { deny all; }
    location /var/export/            { deny all; }
	# deny htaccess files
    location ~ /\. {
        deny  all;
        access_log off;
        log_not_found off;
    }

    ##
    # Rewrite for versioned CSS+JS via filemtime
    ##
    location ~* ^.+\.(css|js)$ {
        rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
        expires 31536000s;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "max-age=31536000, public";
    }
    ##
    # Aggressive caching for static files
    # If you alter static files often, please use 
    # add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
    ##
    location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
        expires 31536000s;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "max-age=31536000, public";
    }

	# error pages
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
	
    location / {
        try_files /maintenance.html $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable
    }
    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }
    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*.php)/ $1 last;
    }
    
    ##
    # pass the PHP scripts to FastCGI server listening at unix:/tmp/php5-fpm.sock
    ##
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SERVER_PORT 80;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
        fastcgi_param  MAGE_RUN_TYPE store;
    }


    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;
}

ini Magento Nginx VPS配置

server {
    listen 80;
    server_name localhost;
 
    root /var/www/cabocla;
 
    autoindex off;
    location /app/                { deny all; }
    location /includes/           { deny all; }
    location /lib/                { deny all; }
    location /media/downloadable/ { deny all; }
    location /pkginfo/            { deny all; }
    location /report/config.xml   { deny all; }
    location /var/                { deny all; }
    location = /RELEASE_NOTES.txt { deny all; }
    location = /LICENSE_AFL.txt   { deny all; }
    location = /LICENSE.html      { deny all; }
    location = /LICENSE.txt       { deny all; }
    location = /php.ini.sample    { deny all; }
    location = /index.php.sample  { deny all; }
    location  /.                  { return 404; }
 
    location ~ \.css {
            add_header  Content-Type    text/css;
    }
 
    location ~ \.js {
            add_header  Content-Type    application/x-javascript;
    }
    location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico|txt|xml|bmp|pdf|doc|docx|ppt|pptx|zip)$ {
        access_log off;
        expires 30d;
    }
 
    location ~* ^(/downloader|/js|/404|/report)(.*) {
        include /usr/local/etc/nginx/fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$1/index.php$1;
        fastcgi_read_timeout 600;
        fastcgi_pass  fpm_backend;
    }
 
    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }
 
    location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*\.php)/ $1 last;
    }
 
    location ~ \.php$ { ## Execute PHP scripts
        expires        off; ## Do not cache dynamic content
 
        fastcgi_pass   fpm_backend;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params; ## See /etc/nginx/fastcgi_params
    }
 
    location / {
        index index.html index.php; ## Allow a static html file to be shown first
            try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
            expires 30d; ## Assume all files are cachable
            if ($request_uri ~* "\.(png|gif|jpg|jpeg|css|js|swf|ico|txt|xml|bmp|pdf|doc|docx|ppt|pptx|zip)$") {
                expires max;
            }
 
        # set fastcgi settings, not allowed in the "if" block
        include /usr/local/etc/nginx/fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$; #this line
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param  MAGE_RUN_CODE default;
        fastcgi_param  MAGE_RUN_TYPE store;
 
        # rewrite - if file not found, pass it to the backend
        if (!-f $request_filename) {
            fastcgi_pass fpm_backend;
            break;
        }
    }
}

以上是关于ini nginx下magento的配置文件。的主要内容,如果未能解决你的问题,请参考以下文章

ini 为Magento进行经过实战考验的Nginx配置(来源:www.hypernode.com)

ini 为Magento进行经过实战考验的Nginx配置(来源:www.hypernode.com)

ini 为Magento进行经过实战考验的Nginx配置(来源:www.hypernode.com)

ini 为Magento进行经过实战考验的Nginx配置(来源:www.hypernode.com)

ini 为Magento进行经过实战考验的Nginx配置(来源:www.hypernode.com)

win php nginx 配置小细节