安装

» PECL 扩展未与 PHP 捆绑。

安装此 PECL 扩展相关的信息可在手册中标题为 PECL 扩展的安装章节中找到。更多信息如新的发行版本、下载、源文件、 维护人员信息及变更日志等,都在此处: » https://pecl.php.net/package/apc.

PECL 扩展的 DLL 当前不可用。参见 在 Windows 上构建章节。

Note: 在Windows上,APC需要一个临时目录,并且Web服务器对这个目录可写,APC会检测TMP,TEMP,USERPROFILE这些Windows的环境变量,如果这些都没有,会检查系统文件夹下的WINDOWS目录。

Note: 更深层次,更高级别的技术实现细节,请参阅 »  开发人员提供的 TECHNOTES 文件 .

User Contributed Notes

JoeB at modernizedmedia dot com 04-Apr-2016 06:01
After spending a few hours investigating this I have come to learn that as of php 5.5, there is an opcode cache built into php that you should use instead of wrestling with trying to install this one.  Especially on WAMP.
nhhecker+php_net at gmail dot com 18-Dec-2013 03:59
The below steps should work on Red Hat Enterprise Linux (RHEL) 6.x / CentOS 6.x. By way of introduction I had a bit of trouble installing php-devel but finally found an RPM on pbone.net that wold work with my version of php...
  # yum install gcc automake php httpd httpd-devel
  # yum list installed | grep php
  # rpm -Uvh ftp://ftp.sunet.se/pub/Linux/distributions/scientific/6.3/x86_64/updates/security/php-devel-5.3.3-27.el6_5.x86_64.rpm

With that out ofthe way, I could continue the installation of APC...
  # yum install php-pear
  # pecl install apc
  # echo "extension=apc.so" >> /etc/php.ini
  # echo "apc.enabled=1" >> /etc/php.ini
  # cp /usr/share/pear/apc.php /var/www/html/apc.php (this step is optional)
  # /etc/init.d/httpd restart

Finally, test opening the apc.php file in a Web browser if you opted to copy the file. If all goes well, you may want to delete the apc.php file when you're done.

-nick
adonis at aynacorp dot com 26-Dec-2012 03:01
Installation Steps For on Centos 6.3 / PHP 5.3.3

#use pecl to install it (you will be prompted during installation, I used the default values)
pecl install apc

# you should see something like this
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
54 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
...
...
...
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.9

#Great now that it is built,
#enable apc in php.ini
nano /etc/php.ini

# somewhere in you php.ini file add please not that path may be different for you installation
extension="/usr/lib64/php/modules/apc.so"
apc.enabled=1

# copy the shipped apc.php to see what is going on wit apc on your server
cp /usr/share/pear/apc.php /root_dir_of_your_web_app

# now you should be able to see stats of APC running
flydian80 at yahoo dot com 01-May-2012 05:45
Install successfully on RHEL5 with user-defined path. In case someone needs it, I put the steps here.

I am not the su user and don't have its right too. Basically I installed the Apache and PHP 5.3.10 on the folder under my user directory.
My user directoy like /home/dxxx, php is at /home/dxxx/php, apache is at /home/dxxx/php.

1: I get APC-3.1.9.tar.gz from PECL and put in at /home/dxxx/php/etc.
2: /home/dxxx/php/etc: tar -xvfz APC-3.1.9.tar.gz
3: We get a folder named APC-3.1.9, then cd APC-3.1.9
4: /home/dxxx/php/etc/APC-3.1.9: /home/dxxx/php/bin/./phpize ( because I installed php on user-defined foler, need to go there to find the "phpize")
It shows:
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

5: /home/dxxx/php/etc/APC-3.1.9: ./config --with-php-config=/home/dxxx/php/bin/php-config --enable-apc --enable-apc-debug ( Because I am asked to put --with-php-config=PATH, if I don't provide it)

--Ignore the output message

6: /home/dxxx/php/etc/APC-3.1.9: make
We should be able to see a "apc.so" file under modules/.

7:  /home/dxxx/php/etc/APC-3.1.9: make install
This step copies that "apc.so" file to your extension folder. We can do it manually either.

8: Add extension=apc.so to you php.ini, then restart the apache server

9: /home/dxxx/php/etc/APC-3.1.9: /home/dxxx/php/bin/./php -m
We should be able to see the "apc" on the list
Anonymous 24-Jan-2012 12:16
On my Debian Squeeze 64-bit I also had to install the package "apache2-threaded-dev" with this command "apt-get install apache2-threaded-dev". Afterwards I did "pecl install apc" and everything seemed to work fine.
scarywound at gmail com 22-Nov-2011 12:45
Pay attention to the fact that installing php-apc package gives you APC version 3.1.3p1, which is according to http://pecl.php.net/package/APC UNSTABLE. If you want the latest STABLE edition (3.1.9 by now), you should use 'sudo pecl install apc' instead.
brian at diamondsea dot com 17-Jun-2011 07:34
When installing on Plesk and cPanel machines, I get the following error message:

[root@web1 ~]# pecl install apc
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes
54 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
/usr/bin/phpize: /tmp/pear/temp/APC/build/shtool: /bin/sh: bad interpreter: Permission denied
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

The problem is caused by the /tmp/ filesystem being mounted noexec, which keeps any programs on /tmp/ from being allowed to be executed, which breaks the install script. 

To remount /tmp/ as executable, use:

[root@web1 ~]# mount -o remount,exec,suid /tmp

The it should install correctly.

After the install is done, remount the /tmp/ filesystem with the noexec permissions reset.

[root@web1 ~]# mount -o remount,noexec,nosuid /tmp
pr at outwit dot com 15-Aug-2009 02:11
Installed successfully on different FreeBSD servers, with mmap and IPC semaphores, but I got an error on a 64 bits box :

apc_sem_create: semctl(65536,...) failed: Result too large

I had to increase maximum semaphore value :

# sysctl kern.ipc.semvmx=131068
kern.ipc.semvmx: 32767 -> 131068
# echo "kern.ipc.semvmx=131068" >>  /etc/sysctl.conf

Works like a charm.
toby at telegraphics dot com dot au 04-Apr-2009 10:04
On Gentoo,

# emerge pecl-apc

Check installation:

 $ php -r 'phpinfo();' |grep apc
additional .ini files parsed => /etc/php/cli-php5/ext-active/apc.ini,
apc
apc.cache_by_default => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.max_file_size => 1M => 1M
apc.num_files_hint => 1024 => 1024
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.shm_segments => 1 => 1
apc.shm_size => 30 => 30
apc.slam_defense => 0 => 0
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 7200 => 7200
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 7200 => 7200
apc.write_lock => On => On
suhosin.apc_bug_workaround => Off => Off
61924 dot 00 at gmail dot com 11-Dec-2008 10:23
sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart

Was enough for me. I use Ubuntu Server 8.10.
Anonymous 25-Jul-2008 03:18
On Ubuntu I had to install the apache2-threaded-dev package.  It's the the Etch repos.
consistency 23-Jul-2008 01:07
debian etch installation

apt-get install apache2
apt-get install libapache2-mod-php5
apt-get install php-pear
apt-get install php5-dev
apt-get install make
apt-get install apache2-prefork-dev
pecl install apc

apache2-prefork-dev is necessary for not having the
"Sorry, I was not able to successfully run APXS."
error