


こんなのあるんですね。
WordPressを2.5倍速くするPHPアクセラレータ「APC」
http://www.atmarkit.co.jp/ait/articles/1601/25/news004.html
WordPressのパフォーマンスを上げる為、APCを導入しました
http://www.checksite.jp/pecl-apc-php/
早々に当サイトにもインストールしてみました。
- php-pearインストール
- apcインストール
- phpにapcの組み込み
- apacheの再読み込み
- 確認
足りないと思われるphp-pearをインストールしました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
[root@host01 ~]# yum info php-pear 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * epel: mirrors.hustunique.com * extras: ftp.iij.ad.jp * remi: mirrors.thzhost.com * updates: ftp.iij.ad.jp 利用可能なパッケージ 名前 : php-pear アーキテクチャー : noarch エポック : 1 バージョン : 1.10.1 リリース : 1.el7.remi 容量 : 349 k リポジトリー : remi 要約 : PHP Extension and Application Repository framework URL : http://pear.php.net/package/PEAR ライセンス : BSD and LGPLv3+ 説明 : PEAR is a framework and distribution system for reusable PHP : components. This package contains the basic PEAR components. [root@host01 ~]# yum -y install php-pear 読み込んだプラグイン:fastestmirror base | 3.6 kB 00:00:00 epel/x86_64/metalink | 6.2 kB 00:00:00 epel | 4.3 kB 00:00:00 extras | 3.4 kB 00:00:00 remi | 2.9 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): epel/x86_64/updateinfo | 482 kB 00:00:00 (2/3): epel/x86_64/primary_db | 3.8 MB 00:00:00 (3/3): remi/primary_db | 1.2 MB 00:00:01 Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * epel: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * remi: mirrors.thzhost.com * updates: ftp.iij.ad.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ php-pear.noarch 1:1.10.1-1.el7.remi を インストール --> 依存性の処理をしています: php-xml のパッケージ: 1:php-pear-1.10.1-1.el7.remi.noarch --> 依存性の処理をしています: php-posix のパッケージ: 1:php-pear-1.10.1-1.el7.remi.noarch --> トランザクションの確認を実行しています。 ---> パッケージ php-process.x86_64 0:5.4.45-3.el7.remi を インストール ---> パッケージ php-xml.x86_64 0:5.4.45-3.el7.remi を インストール --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.24)(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.22)(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.18)(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.13)(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.11)(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> 依存性の処理をしています: libxslt.so.1()(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> 依存性の処理をしています: libexslt.so.0()(64bit) のパッケージ: php-xml-5.4.45-3.el7.remi.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ libxslt.x86_64 0:1.1.28-5.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました =================================================================================================== Package アーキテクチャー バージョン リポジトリー 容量 =================================================================================================== インストール中: php-pear noarch 1:1.10.1-1.el7.remi remi 349 k 依存性関連でのインストールをします: libxslt x86_64 1.1.28-5.el7 base 242 k php-process x86_64 5.4.45-3.el7.remi remi 73 k php-xml x86_64 5.4.45-3.el7.remi remi 194 k トランザクションの要約 =================================================================================================== インストール 1 パッケージ (+3 個の依存関係のパッケージ) 総ダウンロード容量: 858 k インストール容量: 3.3 M Downloading packages: (1/4): libxslt-1.1.28-5.el7.x86_64.rpm | 242 kB 00:00:00 (2/4): php-pear-1.10.1-1.el7.remi.noarch.rpm | 349 kB 00:00:00 (3/4): php-process-5.4.45-3.el7.remi.x86_64.rpm | 73 kB 00:00:01 (4/4): php-xml-5.4.45-3.el7.remi.x86_64.rpm | 194 kB 00:00:01 --------------------------------------------------------------------------------------------------- 合計 582 kB/s | 858 kB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : libxslt-1.1.28-5.el7.x86_64 1/4 インストール中 : php-xml-5.4.45-3.el7.remi.x86_64 2/4 インストール中 : php-process-5.4.45-3.el7.remi.x86_64 3/4 インストール中 : 1:php-pear-1.10.1-1.el7.remi.noarch 4/4 検証中 : php-process-5.4.45-3.el7.remi.x86_64 1/4 検証中 : libxslt-1.1.28-5.el7.x86_64 2/4 検証中 : php-xml-5.4.45-3.el7.remi.x86_64 3/4 検証中 : 1:php-pear-1.10.1-1.el7.remi.noarch 4/4 インストール: php-pear.noarch 1:1.10.1-1.el7.remi 依存性関連をインストールしました: libxslt.x86_64 0:1.1.28-5.el7 php-process.x86_64 0:5.4.45-3.el7.remi php-xml.x86_64 0:5.4.45-3.el7.remi 完了しました! |
すべてデフォルトでインストールしました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[root@host01 ~]# pecl install apc downloading APC-3.1.13.tgz ... Starting to download APC-3.1.13.tgz (171,591 bytes) .....................................done: 171,591 bytes 55 source files, building running: phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 Enable internal debugging in APC [no] : Enable per request file info about files used from the APC cache [no] : Enable spin locks (EXPERIMENTAL) [no] : Enable memory protection (EXPERIMENTAL) [no] : Enable pthread mutexes (default) [no] : Enable pthread read/write locks (EXPERIMENTAL) [yes] : building in /var/tmp/pear-build-rootmzfeqF/APC-3.1.13 (snip) Build process completed successfully Installing '/usr/lib64/php/modules/apc.so' Installing '/usr/include/php/ext/apc/apc_serializer.h' install ok: channel://pecl.php.net/APC-3.1.13 configuration option "php_ini" is not set to php.ini location You should add "extension=apc.so" to php.ini |
別途/etc/php.d/apc.iniを作成します。
実行時設定
http://php.net/manual/ja/apc.configuration.php
1 2 3 4 5 6 7 8 |
[root@host01 ~]# vi /etc/php.d/apc.ini [root@host01 ~]# cat /etc/php.d/apc.ini [apc] extension = apc.so apc.shm_size = 128M apc.enable = 1 ;apc.enable_cli = 1 ;apc.filters = filename |
1 2 3 |
[root@host01 ~]# apachectl -t Syntax OK [root@host01 ~]# apachectl graceful |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
[root@host01 ~]# php -i | grep apc Additional .ini files parsed => /etc/php.d/apc.ini, apc apc.cache_by_default => On => On apc.canonicalize => On => On apc.coredump_unmap => Off => Off apc.enable_cli => Off => Off apc.enabled => On => On apc.file_md5 => Off => Off apc.file_update_protection => 2 => 2 apc.filters => no value => no value apc.gc_ttl => 3600 => 3600 apc.include_once_override => Off => Off apc.lazy_classes => Off => Off apc.lazy_functions => Off => Off apc.max_file_size => 1M => 1M apc.mmap_file_mask => no value => no value apc.num_files_hint => 1000 => 1000 apc.preload_path => no value => no value apc.report_autofilter => Off => Off 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 => default => default apc.shm_segments => 1 => 1 apc.shm_size => 128M => 128M apc.shm_strings_buffer => 4M => 4M apc.slam_defense => On => On apc.stat => On => On apc.stat_ctime => Off => Off apc.ttl => 0 => 0 apc.use_request_time => On => On apc.user_entries_hint => 4096 => 4096 apc.user_ttl => 0 => 0 apc.write_lock => On => On |
apcの動作状況の確認をWebでできるようです。
1 2 3 |
[root@host01 ~]# find / -name apc.php /usr/share/pear/apc.php [root@host01 ~]# cp /usr/share/pear/apc.php /var/www/html/ |
これでhttp://server_ip/apc.phpにアクセスすると状況の確認ができます。
ログインはデフォルトでapc/passwordですので常時設置する場合は変更して下さい。
1 2 |
defaults('ADMIN_USERNAME','apc'); // Admin Username defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!! |
ところがWordPressのダッシュボードに警告が表示されました。
NOTICE: ZenCache + PHP APC Extension
As of December 1st, 2015 ZenCache will no longer run with the outdated PHP APC extension. It appears that you’re currently running PHP v5.4.x with APC enabled. You will need to follow one of the actions below to run the next version of ZenCache.
Options Available (Action Required):Please add ini_set(‘apc.cache_by_default’, false); to the top of your /wp-config.php file. That will get rid of this message and allow ZenCache to run without issue.
Or, contact your web hosting provider and ask about upgrading to PHP v5.5+; which includes the new OPcache extension for PHP. The new OPcache extension replaces APC in modern versions of PHP.To learn more about this upcoming change, please see the announcement: PHP APC Extension No Longer Supported
Dismiss this notice.
ZenCache + PHP APC Extensionの組合せはダメみたいですね。
PHP 5.5+にするかini_set(‘apc.cache_by_default’, false);をwp-config.phpに追記すればいいようですが、取り敢えずZenCacheを止めました。
警告は消えましたがどれぐらい改善されるのでしょうか?