PHP 5.5 の表示速度を高速化したくて

ZendOpcache の導入が完了したので

APCu を導入する事にしました

早速、以下の方法で導入しました

①.pecl install APCu-4.0.7

②.Enable full APC compatibility [yes] :

yes を選択します。

③.Enable internal debugging in APCu [no] :

no を選択します。

Build process completed successfully と表示している事を確認します。

また、extension=apcu.sophp.ini に書き込みます。

Build process completed successfully
Installing '/usr/include/php5/ext/apcu/apc.h'
Installing '/usr/include/php5/ext/apcu/apc_lock_api.h'
Installing '/usr/include/php5/ext/apcu/apc_cache_api.h'
Installing '/usr/include/php5/ext/apcu/apc_pool_api.h'
Installing '/usr/include/php5/ext/apcu/apc_serializer.h'
Installing '/usr/include/php5/ext/apcu/apc_sma_api.h'
Installing '/usr/include/php5/ext/apcu/apc_api.h'
Installing '/usr/include/php5/ext/apcu/apc_bin_api.h'
Installing '/usr/lib64/php5/apcu.so'
install ok: channel://pecl.php.net/apcu-4.0.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=apcu.so" to php.ini

 

④.vi /etc/php5/php.ini

php.ini を編集します。

extension=/usr/lib64/php5/apcu.so
apc.optimization = 1
apc.check_compiled_source = 1
apc.check_mtime = 1
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 1G
apc.num_files_hint = 100
apc.user_entries_hint = 640000
apc.ttl = 86400
apc.user_ttl = 86400
apc.gc_ttl =86400

 

⑤./etc/init.d/apache2 restart

apache を再起動します。

⑥.php -i | grep “apc\|intl”

設定内容を確認します。

Configure Command => './configure' '--host=x86_64-unknown-linux-gnu' '--build=x86_64-unknown-linux-gnu' '--program-prefix=' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/share' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--prefix=/usr' '--libdir=/usr/lib64/php5' '--with-libdir=lib64' '--sysconfdir=/etc/php5' '--with-layout=GNU' '--with-config-file-path=/etc/php5' '--with-config-file-scan-dir=/etc/php5/php.d' '--with-exec-dir=/usr/lib64/php5/bin' '--program-suffix=5' '--enable-safe-mode' '--disable-rpath' '--enable-zend-multibyte' '--enable-bcmath' '--enable-calendar' '--enable-dba=shared' '--with-gdbm' '--with-db4' '--with-inifile' '--enable-exif' '--enable-ftp' '--enable-inline-optimization' '--enable-intl=shared' '--enable-mbstring' '--enable-pcntl=shared' '--enable-pdo=shared' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--enable-zip=shared' '--with-bz2' '--with-curl' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-gd=shared,/usr' '--enable-gd-native-ttf' '--with-iconv' '--with-gettext' '--with-gmp' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos' '--with-ldap=shared' '--with-mcrypt=shared,/usr' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd' '--with-pdo-mysql=shared,mysqlnd' '--with-openssl' '--with-pgsql=shared' '--with-pdo-pgsql=shared,/usr' '--with-pic' '--with-snmp=shared,/usr' '--with-sqlite=shared' '--enable-sqlite-utf8' '--with-pdo-sqlite=shared,/usr' '--with-unixODBC=shared,/usr' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-xmlrpc=shared' '--with-xsl' '--with-zlib' '--with-pear=/usr/share/php5-pear' '--with-readline'
/etc/php5/php.d/intl.ini,
apc
apcu
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 2G => 2G
apc.slam_defense => On => On
apc.smart => 0 => 0
apc.ttl => 86400 => 86400
apc.use_request_time => On => On
apc.writable => /tmp => /tmp
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0

 

筆者の環境では、apc.enabledon なのに有効にならない状態でした

また、WordPressw3 Total Cache を導入後

APCu を使用する設定にする事で、WordPress の環境だけ

APCu が使用出来る状態になりました