標籤:apc
參見官方文檔
http://php.net/manual/en/book.apc.php
The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.
通過以下方式可以查看是否安裝了APC擴充
$ php -r ‘phpinfo();‘ |grep apcapcapc.cache_by_default => On => Onapc.canonicalize => On => Onapc.coredump_unmap => Off => Offapc.enable_cli => Off => Offapc.enabled => On => Onapc.file_md5 => Off => Offapc.file_update_protection => 2 => 2apc.filters => no value => no valueapc.gc_ttl => 3600 => 3600apc.include_once_override => Off => Offapc.lazy_classes => Off => Offapc.lazy_functions => Off => Offapc.max_file_size => 1M => 1Mapc.mmap_file_mask => no value => no valueapc.num_files_hint => 1000 => 1000apc.preload_path => no value => no valueapc.report_autofilter => Off => Offapc.rfc1867 => Off => Offapc.rfc1867_freq => 0 => 0apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESSapc.rfc1867_prefix => upload_ => upload_apc.rfc1867_ttl => 3600 => 3600apc.serializer => default => defaultapc.shm_segments => 1 => 1apc.shm_size => 32M => 32Mapc.shm_strings_buffer => 4M => 4Mapc.slam_defense => On => Onapc.stat => On => Onapc.stat_ctime => Off => Offapc.ttl => 0 => 0apc.use_request_time => On => Onapc.user_entries_hint => 4096 => 4096apc.user_ttl => 0 => 0apc.write_lock => On => On
1.安裝APC擴充
tar -zxvf APC-3.1.14.tgz
cd APC-3.1.14
phpize
./configure --with-php-config=/data/app_platform/php/bin/php-config
make && make install
2.配置php.ini
以下是建議使用的參數
extension=apc.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=7200
apc.user_ttl=7200
apc.enable_cli=1
3.配置APC參數
參考文檔
http://php.net/manual/en/apc.configuration.php
有兩個首要考慮的問題是:1.給APC分配多少記憶體空間。2.對於每個請求是否讓APC檢查一個檔案是否被更改。這個兩個參數是apc.shm_size和apc.stat
APC內建一個監控頁面apc.php,可以從源碼包中複製apc.php到一個nginx虛擬機器主機,然後通過http://xxxxxx/apc.php查看APC緩衝的狀態。
如果安裝PHP的GD擴充,則可以看到圖表
apc.shm_size
本文出自 “Linux SA John” 部落格,請務必保留此出處http://john88wang.blog.51cto.com/2165294/1579158
PHP APC緩衝