magento提速!!!!

[Magento]给Magento提速的方法[复制链接]

  


1、安装Fooman Speedster插件
插件官方地址:http://www.magentocommerce.com/m ... 57/fooman-speedster
这款插件主要通过合并、压缩js和CSS来加速,不知道这个和使用Magento自带的合并功能有什么区别。

2、在.htaccess中开启Gzip压缩

在.htaccess的52行左右的位置移除#号
  1. #php_flag zlib.output_compression on
复制代码
将以下.htaccess
  1. ############################################
  2. ## enable apache served files compression
  3. ## http://developer.yahoo.com/performance/rules.html#gzip

  4.     # Insert filter
  5.     #SetOutputFilter DEFLATE

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

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

  10.     # MSIE masquerades as Netscape, but it is fine
  11.     #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  12.     # Don't compress images
  13.     #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

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

  16. </IfModule>
复制代码
把一些#号去掉
  1. ############################################
  2. ## enable apache served files compression
  3. ## http://developer.yahoo.com/performance/rules.html#gzip

  4.     # Insert filter
  5.    SetOutputFilter DEFLATE

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

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

  10.     # MSIE masquerades as Netscape, but it is fine
  11.   BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  12.     # Don't compress images
  13.     SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

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

  16. </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
  1. <global>
  2. ....................
  3. <cache>
  4. <backend>apc</backend>
  5. <prefix>alphanumeric</prefix>
  6. </cache>
  7. ......................

复制代码
以上需要注意的是如果你的服务器有超过一个Magento程序,apc在缓存上会有一些混乱
可以试着使每个Magento网站<prefix>alphanumeric</prefix>内容不同
第一个网站<prefix>siteA</prefix>
第二个网站<prefix>siteB</prefix>
提速的重点在于成功安装apc

4、修改Mysql服务器的配置好好利用服务器的内存
绝大部分Linux发行版提供一个保守的mysql包来确保能运行在大范围的硬件上。如果你有足够的内存(比如,1gb或者更多),接着你可能会想调整设置。一个my.cnf的示例如下,
  1. key_buffer = 512M
  2. max_allowed_packet = 64M
  3. table_cache = 512
  4. sort_buffer_size = 4m
  5. read_buffer_size = 4m
  6. read_rnd_buffer_size = 2m
  7. myisam_sort_buffer_size = 64m
  8. tmp_table_size = 128m
  9. query_cache_size = 96m
  10. query_cache_type = 1
  11. thread_cache_size = 8
  12. max_connections = 400
  13. wait_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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值