Installation
There are two primary ways to install the APCu extension: using PECL or compiling from source.
Installing with PECL (Recommended)
The easiest way to install APCu is by using the PECL installer.
pecl install apcu
After installation, you need to add the following line to your php.ini file:
extension=apcu.so
Compiling from Source
If you prefer to compile the extension from the source code, follow these steps:
-
Clone the repository or download the source code.
git clone https://github.com/krakjoe/apcu.git cd apcu -
Prepare the build environment using
phpize.phpize -
Configure the build script. You can enable or disable features using the flags below.
./configure -
Compile and install the extension.
make sudo make install -
Finally, enable the extension in your
php.inifile:extension=apcu.so
Configuration Options
When running ./configure, you can customize the build with the following flags based on the config.m4 file:
| Flag | Description |
|---|---|
--enable-apcu |
(Default) Enables APCu support. |
--disable-apcu-rwlocks |
Disables POSIX read/write locks, falling back to other locking mechanisms. |
--enable-apcu-debug |
Builds APCu in debug mode, which adds extra checks and logging. |
--enable-apcu-clear-signal |
Enables a signal handler that clears the cache upon receiving SIGUSR1. |
--disable-apcu-mmap |
Disables mmap for memory allocation, falling back to System V shm. |
--enable-apcu-spinlocks |
Uses spinlocks as a locking mechanism before trying file-based locks. |
Windows Installation
For Windows users, pre-compiled DLLs are available directly from the PECL website. Download the appropriate DLL for your PHP version, architecture (x64/x86), and thread-safety (TS/NTS), and place it in your PHP extension directory (ext). Then, add extension=php_apcu.dll to your php.ini.