---
title: "magento 性能优化"
author: "chinacode"
date: "2010-09-19T17:59:32Z"
tags: []
categories: ["操作系统"]
slug: "magento"
draft: false
lastmod: "2010-09-19T17:59:32Z"
id: 767489
url: "https://chinacode.iteye.com/blog/767489"
---

前言:  
[Magento](http://www.blags.org/tags/magento/ "magento") 是一个开源电子商务系统，尤其以扩展性高著称，但是很高的扩展性往往是牺牲了速度为代价的，虽然现在magento为速度提升做了很多工作，但是还是没能 达到人们对速度的要求。既然如此还是有很多企业选择了它，速度问题还是让很多客户无法接受，最近忙碌于magento性能优化。  
同时速度也上了几个台阶，据本人目测最少快了(7-8倍)。

参考了合同前辈的经验总结了如下几点:  
1\) Magento Caching. Magento 自身cache  
Goto Magento Admin -&gt; System -&gt; Cache Management  
\- Tick the following items:  
– Configuration  
– Layouts  
– Block HTML output  
– Translations

2) [MySQL](http://www.blags.org/tags/mysql/ "mysql") Cache Size 设置  
query\_cache\_size=128M  
innodb\_buffer\_pool\_size=64M  
innodb\_additional\_mem\_pool=16M

4\) Enabling Gzipping 启用gzip压缩  
.ht[access](http://www.blags.org/tags/access/ "access数据库")  
php\_flag zlib.output\_compression on  
AddHandler application/x-httpd-php5 .css

修改 .htaccess mod\_deflate 配置  
本人配置如下:

```
# Insert filter on all content
    SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
```

5\) Install Fooman Speedster 安装该插件

6\) Install APC or Xcache 安装apc机器码缓存

&lt;cache&gt;  
&lt;backend&gt;apc&lt;/backend&gt;  
&lt;prefix&gt;alphanumeric&lt;/prefix&gt;  
&lt;/cache&gt;  
添加到 app/etc/local.xml &lt;global&gt;&lt;/global&gt; 之间.

7\) 设置apache 开启 KeepAlive

KeepAlive ＝ On

LoadModule deflate\_module     modules/mod\_deflate.so #开启mod\_deflate

参考地址:

[http://www.magentocommerce.com/wiki/groups/168/optimising\_your\_web\_stack\_performance\_for\_magento](http://www.magentocommerce.com/wiki/groups/168/optimising_your_web_stack_performance_for_magento)

[http://www.magentocommerce.com/boards/viewthread/36225/](http://www.magentocommerce.com/boards/viewthread/36225/)

**出处:** [马丁博客](http://www.blags.org/)［[http://www.blags.org/](http://www.blags.org/)］

**本文链接地址:** [http://www.blags.org/magento-performance-optimization/](http://www.blags.org/magento-performance-optimization/)