php apc install(ubuntu)

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.
大的网站都用它
 sudo apt-get install apache2-threaded-dev php5-dev php-pear make 
sudo ln -s /usr/bin/apxs2 /usr/bin/apxs
 sudo pecl install apc
回答:YES

 sudo vi /etc/php5/apache2/php.ini 
增加:extension=apc.so
sudo vi /usr/share/php/pearcmd.php
增加:@ini_set('memory_limit', '16M');

测试
使用APC
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Finished 300 requests


Server Software:        Apache/2.2.8
Server Hostname:        localhost
Server Port:            80

Document Path:          /PHPUnit/src/test/runall_test.php
Document Length:        3935 bytes

Concurrency Level:      1
Time taken for tests:   23.418973 seconds
Complete requests:      300
Failed requests:        0
Write errors:           0
Total transferred:      1335000 bytes
HTML transferred:       1180500 bytes
Requests per second:    12.81 [#/sec] (mean)
Time per request:       78.063 [ms] (mean)
Time per request:       78.063 [ms] (mean, across all concurrent requests)
Transfer rate:          55.64 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:    67   77  14.7     73     250
Waiting:        2    2   3.7      2      60
Total:         67   77  14.7     73     250

Percentage of the requests served within a certain time (ms)
  50%     73
  66%     76
  75%     83
  80%     85
  90%     88
  95%     91
  98%    103
  99%    129
 100%    250 (longest request)

不使用APC
enchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Finished 300 requests


Server Software:        Apache/2.2.8
Server Hostname:        localhost
Server Port:            80

Document Path:          /PHPUnit/src/test/runall_test.php
Document Length:        3935 bytes

Concurrency Level:      1
Time taken for tests:   51.773192 seconds
Complete requests:      300
Failed requests:        0
Write errors:           0
Total transferred:      1335000 bytes
HTML transferred:       1180500 bytes
Requests per second:    5.79 [#/sec] (mean)
Time per request:       172.577 [ms] (mean)
Time per request:       172.577 [ms] (mean, across all concurrent requests)
Transfer rate:          25.17 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   156  172  21.7    163     367
Waiting:       15   20   3.6     20      48
Total:        156  172  21.7    163     367

Percentage of the requests served within a certain time (ms)
  50%    163
  66%    166
  75%    177
  80%    193
  90%    196
  95%    204
  98%    216
  99%    283
 100%    367 (longest request)


时间消耗几乎相差一倍。
注意,如果是用phpinfo()类的简单函数,测试效果将非常不明显。

使用系统默认的apc.php查看cache情况,可以把apc.php cp到你的web目录。我机器上该文件默认目录是:
/usr/share/php

你可能感兴趣的:(apache,PHP,Web,cache,ubuntu)