カテゴリー
Linux

【PHP】APC のインストール方法整理!【CentOS 5.9】

APC インストール方法の情報整理まとめ

  • yum で php-pecl-apc をインストールする方法が最も簡単
  • PEAR 導入済みなら、pecl install apc でもよい

php-pecl-apc でインストールしても依存の関係で PEAR もインストールされます。ですのでAPC の利用には結局のところ PEAR がインストールが必要です。

いろいろ調べてみましたその1。APC パッケージ、なにがあるでしょう?

yum で apc を含むパッケージを調べてみました。たくさんのパッケージが出て来ましたけれども、APC(Alternative PHP Cache)に関係するパッケージは3つでした。

  • apc-panel.i386 : APC control panel
  • php-pecl-apc.i386 : APC caches and optimizes PHP intermediate code
  • php-pecl-apc-devel.i386 : APC developer files (header)

実際に調べたときの記録です。

[root@localhost ~]# yum --enablerepo=epel,remi,rpmforge search apc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fairway.ne.jp
 * epel: ftp.riken.jp
 * extras: mirror.fairway.ne.jp
 * remi: fr2.rpmfind.net
 * rpmforge: mirror.fairway.ne.jp
 * updates: mirror.fairway.ne.jp
base                                                                    | 1.1 kB     00:00    
epel                                                                    | 3.6 kB     00:00    
extras                                                                  | 2.1 kB     00:00    
remi                                                                    | 2.5 kB     00:00    
rpmforge                                                                | 1.9 kB     00:00    
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Fri Dec 21 11:45:21 2012
  Downloaded: Wed Jul 25 10:45:07 2012
updates                                                                 | 1.9 kB     00:00    
======================================== Matched: apc =========================================
apc-panel.i386 : APC control panel
apcupsd.i386 : APC UPS Power Control Daemon for Linux
apcupsd-cgi.i386 : Web interface for apcupsd
apcupsd-gui.i386 : GUI interface for apcupsd
cfg2html.noarch : Tool to collect Linux system configuration into a HTML and text file.
mapchan.i386 : Program that allows to transform input and output of a terminal
perl-Mail-IMAPClient.noarch : IMAP Client API
perl-NTLM.noarch : NTLM Perl module
perl-YAPC.noarch : Perl module that implements Yet Another Perl Conference
php-Assetic.noarch : Asset Management for PHP
php-ZendFramework-Cache-Backend-Apc.noarch : Zend Framework APC cache backend
php-doctrine-DoctrineCommon.noarch : Doctrine Common PHP Extensions
php-ezc-Cache.noarch : Provides a collection of lightweight classes to cache different kinds of
                     : data
php-horde-Horde-Cache.noarch : Horde Caching API
php-horde-Horde-Thrift.noarch : Thrift
php-pecl-apc.i386 : APC caches and optimizes PHP intermediate code
php-pecl-apc-devel.i386 : APC developer files (header)
php-symfony2-ClassLoader.noarch : Symfony2 ClassLoader Component
php-symfony2-Validator.noarch : Symfony2 Validator Component
[root@localhost ~]#

いろいろ調べてみましたその2。個々の APC パッケージはどんな内容でしょう?

Description を読みましたところ、どうやら最低限 php-pecl-apc があればよさそうです。

まずは apc-panel です。これは APC のコントロールパネルを提供していただけるツールのようです。つまり APC の拡張機能の位置づけのようです。

[root@localhost ~]# yum --enablerepo=epel,remi,rpmforge info apc-panel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fairway.ne.jp
 * epel: ftp.riken.jp
 * extras: mirror.fairway.ne.jp
 * remi: fr2.rpmfind.net
 * rpmforge: mirror.fairway.ne.jp
 * updates: mirror.fairway.ne.jp
base                                                                    | 1.1 kB     00:00    
epel                                                                    | 3.6 kB     00:00    
extras                                                                  | 2.1 kB     00:00    
remi                                                                    | 2.5 kB     00:00    
rpmforge                                                                | 1.9 kB     00:00    
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Fri Dec 21 11:45:21 2012
  Downloaded: Wed Jul 25 10:45:07 2012
updates                                                                 | 1.9 kB     00:00    
Available Packages
Name       : apc-panel
Arch       : i386
Version    : 3.1.14
Release    : 1.el5.remi
Size       : 20 k
Repo       : remi
Summary    : APC control panel
URL        : http://pecl.php.net/package/APC
License    : PHP
Description: This package provides the APC control panel, with Apache
           : configuration, available on http://localhost/apc-panel/

[root@localhost ~]#

続きまして、php-pecl-apc です。これが APC の本体ですね。

[root@localhost ~]# yum --enablerepo=epel,remi,rpmforge info php-pecl-apc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fairway.ne.jp
 * epel: ftp.riken.jp
 * extras: mirror.fairway.ne.jp
 * remi: fr2.rpmfind.net
 * rpmforge: mirror.fairway.ne.jp
 * updates: mirror.fairway.ne.jp
Available Packages
Name       : php-pecl-apc
Arch       : i386
Version    : 3.1.14
Release    : 1.el5.remi
Size       : 180 k
Repo       : remi
Summary    : APC caches and optimizes PHP intermediate code
URL        : http://pecl.php.net/package/APC
License    : PHP
Description: APC is a free, open, and robust framework for caching and optimizing PHP
           : intermediate code.

[root@localhost ~]#

最後に、php-pecl-apc-devel です。APC serializer というものを使いたいときに必要なようですが、よくわかりません。ただ、APC の拡張機能のような雰囲気を感じます。

[root@localhost ~]# yum --enablerepo=epel,remi,rpmforge info php-pecl-apc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fairway.ne.jp
 * epel: ftp.riken.jp
 * extras: mirror.fairway.ne.jp
 * remi: fr2.rpmfind.net
 * rpmforge: mirror.fairway.ne.jp
 * updates: mirror.fairway.ne.jp
Available Packages
Name       : php-pecl-apc-devel
Arch       : i386
Version    : 3.1.14
Release    : 1.el5.remi
Size       : 8.9 k
Repo       : remi
Summary    : APC developer files (header)
URL        : http://pecl.php.net/package/APC
License    : PHP
Description: These are the files needed to compile programs using APC serializer.

[root@localhost ~]#

おわりに

そもそも APC とは Alternative PHP Cache の略で PHP コードをキャッシュするもので、結果として実行速度が早くなります。PHP サイトでの説明はこちらです。

それで、APC をインストールするためには PECL をまずインストールしてね!ということなのですけれども、そのためかだんだんわけがわからなくなってきていました。

PECL をインストールするためにはどうしたらよいのでしょう。。。調べてみますと PEAR のインストールも必要なようです。。。複雑で、難しいです。

ですので、今回自分なりに整理いたしました。とても、スッキリしました。

以上です。