[Magento]给Magento提速的方法[复制链接] 1、安装Fooman Speedster插件 插件官方地址:http://www.magentocommerce.com/m ... 57/fooman-speedster 这款插件主要通过合并、压缩js和CSS来加速,不知道这个和使用Magento自带的合并功能有什么区别。2、在.htaccess中开启Gzip压缩 在.htaccess的52行左右的位置移除#号 #php_flag zlib.output_compression on 复制代码 将以下.htaccess ############################################## enable apache served files compression## http://developer.yahoo.com/performance/rules.html#gzip # Insert filter #SetOutputFilter DEFLATE # 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</IfModule> 复制代码 把一些#号去掉 ############################################## enable apache served files compression## http://developer.yahoo.com/performance/rules.html#gzip # Insert filter SetOutputFilter DEFLATE # 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 fineBrowserMatch \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</IfModule> 复制代码 3、安装 APC or Xcache APC - http://pecl.php.net/package/APC Xcache - http://xcache.lighttpd.net/ apc使add to cart两秒内加载的方法 在你安装激活apc之后,找到app/etc/local.xml 文件 在<global>下添加如下block <global>....................<cache><backend>apc</backend><prefix>alphanumeric</prefix></cache>...................... 复制代码 以上需要注意的是如果你的服务器有超过一个Magento程序,apc在缓存上会有一些混乱 可以试着使每个Magento网站<prefix>alphanumeric</prefix>内容不同 第一个网站<prefix>siteA</prefix> 第二个网站<prefix>siteB</prefix> 提速的重点在于成功安装apc4、修改Mysql服务器的配置好好利用服务器的内存 绝大部分Linux发行版提供一个保守的mysql包来确保能运行在大范围的硬件上。如果你有足够的内存(比如,1gb或者更多),接着你可能会想调整设置。一个my.cnf的示例如下, key_buffer = 512Mmax_allowed_packet = 64Mtable_cache = 512sort_buffer_size = 4mread_buffer_size = 4mread_rnd_buffer_size = 2mmyisam_sort_buffer_size = 64mtmp_table_size = 128mquery_cache_size = 96mquery_cache_type = 1thread_cache_size = 8max_connections = 400wait_timeout = 300 复制代码 5、Magento缓存 转到Magento admin->system->Cache management 选中以下条目: -- Configuration -- Layouts -- Block HTML output -- Translations 以下条目就不用选中了 -- Collections Data -- EAV types and attributes -- Web Services Configuration 6、开启编译 转到System > Tools > Compilation,报道称能给你提速25%-50%。7、使用cdn加速 你可以使用Magento插件来帮助你http://www.magentocommerce.com/magento-connect/One+Pica/extension/1279/one-pica-image-cdn 其他关于前端模板代码方面的优化如图片优化、使用CSS Sprite等论坛其他帖子。 以上方法整理来源于以下网站:http://www.magentocommerce.com/boards/viewthread/36225/http://www.gxjansen.com/101-ways-to-speed-up-your-magento-e-commerce-website/ 8. 将magento的var目录挂载到内存中,加快读取速度,如 mount -t tmpfs -o size=100M,mode=0777 tmpfs var 9. 打开apache的KeepAlives,可以让多个请求使用一个TCP连接,加快速度 修改/etc/httpd/conf/httpd.conf: KeepAlive On 10. Magento1.5中可以开启CSS和JS合并 SYSTEM -> CONFIGURATION / ADVANCED -> DEVELOPER enable Merge JavaScript Files set to Yes Merge CSS Files set to Yes 11. 增加PHP Memory Limit 如果2G内存,可以通过修改php.ini 将memory_limit设置为128MB