加速器php三种加速器安装

php安装  时间:2021-02-23  阅读:()

三款免费的PHP加速器APC、 eAcce lera tor、XCache比较

2012-03-22 13:34:25| 分类 php|举报|字号订阅

一、 PHP加速器介绍

PHP加速器是一个为了提高PHP执行效率从而缓存起PHP的操作码这样PHP后面执行就不用解析转换了可以直接调用PHP操作码这样速度上就提高了不少。

Apache中使用mod_php的请求、响应执行流程

1、Apache接收请求。

2、Apache传递请求给mod_php。

3、mod_php定位磁盘文件并加载到内存中。

4、mod_php编译源代码成为opcode树。

5、mod_php执行opcode树。

PHP加速器相应的就是第四步它的目的就是防止PHP每次请求都重复编译PHP代码因为在高访问量的网站上大量的编译往往没有执行速度快呢所以这里面有个瓶颈就是PHP的重复编译既影响了速度又加载了服务器负载为了解决此问题 PHP加速器就这样诞生了。

二、 PHP加速器安装与配置

1、安装配置APC

APC全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”,它是PHP PECL中的一个扩展好像是f acebook在使用它下面开始安装ubuntu环境 

$wget

$tar xvzf APC-3.0.19. tgz

$cd APC-3.0.19/APC-3.0.19

$/usr/local/php/bin/phpize

$./conf igure –enable-apc –enable-apc-mmap –wi th-php-config=/usr/local/php/bin/php-config

$make

$sudo make install

下面我们再配置APC,因为我的PECL扩展路径改变了所以我得移动下编译好的文件

$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/local/php/lib/php/extensions/PECL

然后我们再编辑php. i n i文件进行配置请把下面的代码加入到php. i n i中即可extension_dir = "/usr/local/php/lib/php/extensions/PECL"extension =apc.so

; APCapc.enabled = 1apc.shm_segment s = 1apc.shm_size =64apc.optimization = 1apc.num_=0apc.ttl =0apc.gc_ttl = 3600apc.cache_by_defaul t =on

这样重启apache就会在php info()信息中显示。

2、安装配置eAccelerator

eAcce lera tor的前身其实是t ruck-mmcache 因为开发t ruk-mmcache的人被Zend给招安了所以开发eAccelerator的人继承了truk-mmcache的一些特性设计出eAccelerator加速器。安装如下

$wget

$tar -jxf eaccelerator-0.9.5. tar.bz2

$cd eaccelerator-0.9.5

$/usr/local/php/bin/phpize

$./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config

$make

$sudo make install

$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so /usr/local/php/lib/php/extensions/PECL

将下面代码加入php. i n i文件中extension =eaccelerator.so

; eAcceleratoreaccelerator.shm_size = "16"eaccelerator.cache_dir = "/tmp/eaccelerator"eaccelerator.enable = "1"eaccelerator.optimizer = "1"eaccelerator.check_mtime = "1"eaccelerator.debug = "0"eaccelerator.fi lter = ""eaccelerator.shm_max = "0"eaccelerator.shm_ttl = "0"eaccelerator.prune_period = "0"eaccelerator.shm_only = "0"eaccelerator.compress = "1"eaccelerator.compress_level = "9"

创建缓存目录,重启apache

$sudo mkdir /tmp/eaccelerator

$sudo chmod 777 /tmp/eaccelerator

$sudo /usr/local/apache/apachectl restart

在php in fo()检查是否安装成功.

3、安装配置XCac h e

XCach e作为国人自己开发的东西做小菜鸟的我也感到骄傲而且XCach e无论在速度还是性能上都做的不错。下面就赶紧让我们品尝它吧

$wget

$tar xvzf xcache-1 .2.2. tar.gz

$cd xcache-1 .2.2

$/usr/local/php/bin/phpize

$./conf igure –enable-xcache –enable-xcache-coverager –with-php-config=/usr/local/php/php-config

$make

$sudo make install

$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so /usr/local/php/lib/php/extensions/PECL

在php. i n i添加配置信息extension =xcache.so

; xcachexcache.admin.user = "admin"xcache.admin.pass = "(执行) echo ’(你的密码)’ |md5sum(得出的密文)"

;xcache.size =24Mxcache.shm_scheme = "mmap"xcache.count =2xcache.slots = 8kxcache. ttl =0xcache.gc_interval =0xcache.var_size = 8Mxcache.var_count = 1xcache.var_slots = 8kxcache.var_ttl =0xcache.var_maxtt l =0xcache.var_gc_interval = 300xcache. tes t =Offxcache.readonly_protection =Onxcache.mmap_path = "/tmp/xcache"xcache.coredump_directory = ""xcache.cacher =Onxcache.stat =Onxcache.optimizer =Off

;xcache.coverager =Onxcache.coveragedump_directory = ""

创建缓存目录重启apache

$sudo mkdir /tmp/xcache

$sudo chmod 777 /tmp/xcache

$sudo /usr/local/apache/bin/apachectl restart

去查看php in fo()信息吧

三、 PHP加速器测试

1、测试环境

硬件: AMD Athlon 64 X2 Dual Core Processor 4400+@2.2GHz CPU, 2GB内存. 160GBSATA硬盘

软件: Linux Ubuntu server Gutsy 7.10, Apache 2.2.4,MySQL 5.0.45和PHP 5.2.3测试指令: ab -c5 -n3000 (我们使用的是Apache Benchmark (ab) 工具并发连接为

5  3000次请求)

2、测试结果

无任何加速器:

Document Path: /

Document Length: 21757 byte s

Concurrency Level : 5

Time taken for tests : 288.255212 seconds

Complete requests : 3000

Failed requests : 0

Write errors: 0

Total transferred: 66777000 bytes

HTMLtransferred: 65271000 bytes

Requests per second: 10.41 [#/sec] (mean)

Time per request : 480.425 [ms] (mean)

Time per request : 96.085 [ms] (mean, across all concurrent requests)Transfer rate: 226.23 [Kbytes/sec] received

Connection Times (ms)min mean[+/-sd]median max

Connec t: 0 0 0.5 0 19

Processing: 181 479 186.0 444 1822

Waiting: 166 461 184.7 427 1708

Total : 181 479 186.0 444 1822

Percentage of the requests served within a certain time (ms)50%444

66%525

75%577

80%619

90%732

95%819

98%946

99%1012

100%1822 (longest request)

APC加速器:

Document Path: /

Document Length: 21757 byte s

Concurrency Level : 5

Time taken for tests : 98.530068 seconds

Complete requests : 3000

Failed requests : 0

Write errors: 0

Total transferred: 66777000 bytes

HTMLtransferred: 65271000 bytes

Requests per second: 30.45 [#/sec] (mean)

Time per request : 164.217 [ms] (mean)

Time per request : 32.843 [ms] (mean, across all concurrent requests)Transfer rate: 661 .84 [Kbytes/sec] received

Connection Times (ms)min mean[+/-sd]median max

Connec t: 0 0 0.0 0 2

Processing: 58 163 71 .2 155 2452

Waiting: 53 158 69.6 150 2329

Total : 58 163 71 .2 155 2452

Percentage of the requests served within a certain time (ms)50%155

66%178

75%193

80%204

90%235

95%258

98%285

99%302

100%2452 (longest request)eAccelerator加速器:

Document Path: /

Document Length: 21757 byte s

Concurrency Level : 5

Time taken for tests : 95.983986 seconds

Complete requests : 3000

Failed requests : 0

Write errors: 0

Total transferred: 66777000 bytes

HTMLtransferred: 65271000 bytes

Requests per second: 31 .26 [#/sec] (mean)

Time per request : 159.973 [ms] (mean)

Time per request : 31 .995 [ms] (mean, across all concurrent requests)Transfer rate: 679.39 [Kbytes/sec] received

Connection Times (ms)min mean[+/-sd]median max

Connec t: 0 0 0.1 0 3

Processing: 57 159 91 .3 148 3830

Waiting: 50 152 89.8 142 3704

Total : 57 159 91 .3 148 3830

Percentage of the requests served within a certain time (ms)50%148

66%174

75%193

80%205

90%239

95%263

98%289

99%309

100%3830 (longest request)

XCach e加速器:

Document Path: /

Document Length: 21757 byte s

Concurrency Level : 5

Time taken for tests : 99.76300 seconds

Complete requests : 3000

Failed requests : 0

Write errors: 0

Total transferred: 66777000 bytes

HTMLtransferred: 65271000 bytes

Requests per second: 30.28 [#/sec] (mean)

Time per request : 165.127 [ms] (mean)

Time per request : 33.025 [ms] (mean, across all concurrent requests)Transfer rate: 658.19 [Kbytes/sec] received

Connection Times (ms)min mean[+/-sd]median max

Connec t: 0 0 0.0 0 2

Processing: 59 164 83.4 155 3367

Waiting: 52 156 66.4 148 1802

Total : 59 164 83.4 155 3367

Percentage of the requests served within a certain time (ms)50%155

66%178

75%196

80%206

90%237

95%263

98%287

99%305

100%3367 (longest request)

3、结果摘要

四、 PHP加速器比较结果总结

1、通过测试得出eAccelerator在请求时间和内存占用综合方面是最好的。

2、通过测试得出使用加速器比无加速器在请求时间快了3倍左右。

3、通过各个官方观察XCac h e是更新最快的这也说明最有发展的。

这几个Vultr VPS主机商家的优点造就商家的用户驱动力

目前云服务器市场竞争是相当的大的,比如我们在年中活动中看到各大服务商都找准这个噱头的活动发布各种活动,有的甚至就是平时的活动价格,只是换一个说法而已。可见这个行业确实竞争很大,当然我们也可以看到很多主机商几个月就消失,也有看到很多个人商家捣鼓几个品牌然后忽悠一圈跑路的。当然,个人建议在选择服务商的时候尽量选择老牌商家,这样性能更为稳定一些。近期可能会准备重新整理Vultr商家的一些信息和教程。以前...

妮妮云(100元/月)阿里云香港BGP专线 2核 4G

妮妮云的来历妮妮云是 789 陈总 张总 三方共同投资建立的网站 本着“良心 便宜 稳定”的初衷 为小白用户避免被坑妮妮云的市场定位妮妮云主要代理市场稳定速度的云服务器产品,避免新手购买云服务器的时候众多商家不知道如何选择,妮妮云就帮你选择好了产品,无需承担购买风险,不用担心出现被跑路 被诈骗的情况。妮妮云的售后保证妮妮云退款 通过于合作商的友好协商,云服务器提供2天内全额退款,超过2天不退款 物...

ZJI:韩国BGP+CN2线路服务器,国内三网访问速度优秀,8折优惠码每月实付440元起

zji怎么样?zji最近新上韩国BGP+CN2线路服务器,国内三网访问速度优秀,适用8折优惠码zji,优惠后韩国服务器最低每月440元起。zji主机支持安装Linux或者Windows操作系统,会员中心集成电源管理功能,8折优惠码为终身折扣,续费同价,全场适用。ZJI是原Wordpress圈知名主机商:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服...

php安装为你推荐
木马病毒木马病毒的区别可以发外链的论坛有哪些可以发外链的论坛?赵雨润星辰变电影是真的启动了吗?百度抢票浏览器百度浏览器怎么抢票?手机区号手机号码安卓应用平台哪个手机应用平台的软件比较正版,安全?qq空间打扮QQ空间怎么打扮如何打扮分词技术搜索引擎采用的是什么技术?youtubemp3mp4视频MP3和视频MP4有什么不同iphone闪退苹果6闪退是什么原因?
godaddy主机 vultr美国与日本 外国域名 网站监控 win8升级win10正式版 ubuntu更新源 国内php空间 一元域名 绍兴高防 e蜗 电信托管 双线机房 空间登陆首页 数据库空间 独立主机 日本代理ip 谷歌台湾 酸酸乳 ssl加速 国外代理服务器 更多