魔幻精灵

文章 分类 评论
275 7 14

站点介绍

魔幻精灵网

PHP搭配优化插件详解Wincache XCache ZendOPcache ZendGuardLoader eAccelerator memcached

魔幻精灵 2017-11-16 5103 0条评论 网站知识

首页 / 正文

一个系统的运行性能,除了程序本身要写的完善,还有要看php本身的一些问题,对于php的运行优化,主要有这些加速器:wincache,xcache,ZendOPcache,eAccelerator加速器等;

Wincache:(Xee:微软的官网

wincache仅适应iis下搭建PHP,若是在windows下面运行其它php web服务器 wincache不是很好,可以考虑使用zend效果会更好(php5.5版本已经整合zend opache)。

大家都觉得在PHP在windows下远不如在linux下运行的好,于是微软就推出了WinCache Extension for PHP这款程序,目前支持两个版本分别是1.1和1.3,针对php5.2/5.3/5.4/5.5版本而发布,Wincache 是Windows下对PHP进行加速的软件,效果显著。在一些测试中,WinCache的得分比eaccelerator和Xcache得分都要好。WinCache可以在微软的IIS官方网站上下载,也可以在最火软件站下载,目前只支持FastCGI运行模式下,Non Thread Safe版本的PHP。 参考:http://www.veryhuo.com/down/html/72353.html

php官方英文:Windows Cache Extension for PHP is a PHP accelerator that is used to increase the speed of PHP applications running on Windows and Windows Server. Once the Windows Cache Extension for PHP is enabled and loaded by the PHP engine, PHP applications can take advantage of the functionality without any code modifications. The extension includes PHP opcode cache, file system cache and relative path cache. In addition the extension provides cache API's and a PHP session handler.

(详细使用资料Windows Server 2008 R2 64Bit下进行Wincache安装与配置教程 & Windows Cache Extension for PHP: 在 IIS 的 PHP 快取提供者

XCache:

Xcache 和 memcached 是两个不同层面的缓存,不存在可比性。 
Xcache 是 php 底层的缓存,它将PHP程式编译成字节码(byte code),再透过服务器上安装对应的程式来执行PHP脚本。而 memcached 是应用层缓存,它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态、数据库驱动网站的速度。 
xcache 是不需要修改PHP程序的,只要安装了就可以自动为你的程序加速,而 memcached 则需要你修改程序的,需要你在操作数据库之前先询问下 memcached 有没有缓存数据,如果有且没有过期则不再访问数据库,以达到减少数据库查询的目的。 
ps:LAMP 的瓶颈在M,即数据库,以新的KVDB代替旧的关系数据库可以直接提高web应用程序的性能。

ZendOPcache:

Zend OPCache的前身是Zend Optimizer + (Zend O+),在PHP5.5的发行版本中自带了Zend O+,并重新命名为:Zend OPCache。但是默认是没有启用的,可以在ini文件中enable一下。

大家知道目前PHP的缓存插件一般有三个:APCeAcceleratorXCache,但未来它们可能都会消失,因为PHP 5.5已经集成Zend Opcache,功能和前三者相似但又有少许不同,缓存速度据说比它们更快(Xee:Zend Opcache和APC都是php官方的,值得信赖。反正不会慢,但是和其他插件同时使用会不会出问题?哈哈)。

据统计,zend opcache比apc性能要好,可以提升提升 5%-9%。

Zend Optimizer + 通过 opcode 的缓存和优化来提速 PHP 的执行.它通过在共享内存里存储预编译的PHP脚本来提高PHP的性能.这一操作消除了从磁盘读取PHP文件然后编译的过程.此外, 此外它还提供了少量的字节码优化模式使得代码执行更快.

值得关注的是Zend OPCache支持PHP5.2.0+的版本,也就是说只要是5.2以上的PHP,都可以是用Zend OPCache,而不需一定要升级到PHP5.5,所以在我们目前的生产站点可以尝试使用Zend OPCache,如基于Drupal6、Drupal7的PHP5.2,PHP5.3等版本。

(参考:http://www.cnblogs.com/keheng/articles/3721179.html & 用Zend OPCache提高PHP的性能

ZendGuardLoader

php5.3之后是没有Zend Optimizer,但是可以安装Zend Guard Loader。

Xee

1:所以有时会遇到这种情况:由于业务,或者客户系统需要,需要安装php5.4以上的版本,同时由于用的zend加密程序,必须安装zend Guard , 我们的服务器是window平台只好安装 apache+php+mysql+Zend Guard Loader。

2:还有:zend guard loader只支持NTS的版本,意味着如果你的php版本是TS的话,就没法使用zend guard loader了,如果你想查看自己的php是ts还是nts的,只需要输出phpinfo,然后搜索下:Thread Safety,disabled对应nts版本,否则为ts。因此,终极解决办法就是,下载个php NTS版本进行安装即可。

再编辑php.ini文件,添加一段代码(如):

[Zend.loader]

zend_extension="E:\wamp\bin\php\php5.4.12\ext/ZendLoader.dll//填写你的绝对地址

zend_loader.enable=1

zend_loader.disable_licensing=1

zend_loader.obfuscation_level_support=4

zend_loader.license_path=

重启~

Xee

1:Zend OPcache是一个非常优秀的加速器 听说Zend OPcache+Memcached 加速效果不错 
    Zend OPcache和eAccelerator的区别我个人觉得嘛  eAccelerator缓存 存读写都在磁盘 而Zend OPcache则在内存明显代码执行将更快。

2:查阅了不少资料说Zend Guard Loader和Zend Opcache不能共存,果断注释掉Zend Guard Loarder。

3:ZendGuardLoader带有zend解密的功能,Zend Opcache只有加速和缓存。

(官方版本也只支持到5.4版本,估计是PHP 5.5已经集成Zend Opcacheimage

eAccelerator:(Xee:官网好像长时间没有维护了)

eaccelerator无法兼容php5.5.0,好在php在5.5.0默认提供了Zend OPcache,所以一直习惯eaccelerator的朋友如果要升级到php5.5.0的话,可能要暂时和eaccelerator说bye bye了。 
配置Zend OPcache 
一直以来都习惯用eAccelerator为php提供加速,但是目前有两个问题: 
eAccelerator暂时不兼容php5.5.0

eAccelerator和Zend Opcache冲突

好在php5.5.0默认提供了Zend Opcache为php加速,配置方法如下: 
zend_extension =/usr/local/webserver/php-d/php-5.5.0/lib/php/extensions/no-debug-non-zts-20121212/opcache.so 
; 上面zend_extension路径为opcache.so的路径 
opcache.memory_consumption=128 
opcache.interned_strings_buffer=8 
opcache.max_accelerated_files=4000 
opcache.revalidate_freq=60 
opcache.fast_shutdown=1 
opcache.enable_cli=1 
注意:如果在您的php扩展模块找不到opcache.so说明没有安装成功,请重新安装

这几个PHP加速插件的主要原理都相同,就是把PHP执行后的数据缓冲到内存中从而避免重复的编译过程,能够直接使用缓冲区已编译的代码从而提高速度,降低服务器负载,它们的效率是显而易见的,像drupal这种庞大的CMS,每次打开一个页面要调用数十个PHP文件,执行数万行代码,效率可想而知,在安装APC等加速器后打开页面的速度明显加快。

关于每个设置,我们都要仔细,不能太过于优化导致出现某些问题,却又找不到问题所在!这是得不偿失的!

没有人告诉你,生活会是这样:你工作无趣,你袋里没钱,你的爱情总是昙花一现;妈妈警告过你,会有这样的日子但她没有告诉你,世界将让你屈服。但是,别怕,有我在你身边,谁让我们是friends呢……

https://www.cnblogs.com/ChandlerVer5/p/php_wincache.html

评论(0)

最新评论

  • tam compact

    My partner and I absolutely love your blog and find many of your post's to be exactly I'm looking for. Would you offer guest writers to write content available for you? I wouldn't mind writing a post or elaborating on a lot of the subjects you write about here. Again, awesome site!

  • ae888

    Excellent beat ! I would like to apprentice while you amend your website, how could i subscribe for a blog website? The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept

  • mbee.com.vn

    Simply want to say your article is as astounding. The clarity in your post is just cool and i can assume you're an expert on this subject. Fine with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please keep up the enjoyable work.

  • Life insurance

    Hi there, You've done a fantastic job. I will certainly digg it and personally suggest to my friends. I am confident they'll be benefited from this web site.

  • vách vệ sinh

    You've made some good points there. I looked on the web to find out more about the issue and found most people will go along with your views on this site.

  • tam compact

    Hi, I do think this is an excellent web site. I stumbledupon it ;) I am going to revisit once again since i have saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to help others.

  • PG เว็บตรงไม่ผ่านเอเย่นต์

    เดิมพันบาคาร่ามันที่สล็อต666เล่นคาสิโน 777เดิมพันออนไลน์ทดลอง เล่น สล็อต pgสล็อต เครดิตฟรจัดคาสิโนออนไลน์777แทงpgสล็อตวัดใจสล็อต ออนไลน์จัดสล็อต เว็บตรง แตก ง่ายวัดใจสล็อต เว็บ ตรง แตก ง่ายวัดใจสล็อต pg เว็บ ตรงเดิมพันу9สล็อตเทรดซุปเปอร์ สล็อต 666เดิมพันบาคาร่า ออนไลน์ ufa99เดิมพันสล็อตxo168จัดสล็อต ออนไลน์ sabai55แทงสล็อต 68วัดดวงสล็อต ฝาก20รับ100 เว็บตรงวัดใจสล็อต เว็บแท้วัดโคตรเทพnoname auto สล็อตเดิมพันออนไลน์โหลด สล็อต666วัดmgw สล็อต

  • Charlene

    Simply wish to say your article is as surprising. The clarity in your post is just cool and i can assume you are an expert on this subject. Fine with your permission allow me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the gratifying work.

  • đăng nhập ae888

    There's certainly a lot to know about this topic. I love all of the points you made.

  • dp595.com

    Great blog you've got here.. It's difficult to find quality writing like yours these days. I really appreciate individuals like you! Take care!!

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

标签云

文章目录

推荐关键字:

配色方案