Installation

There are two primary ways to install the APCu extension: using PECL or compiling from source.

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:

  1. Clone the repository or download the source code.

    git clone https://github.com/krakjoe/apcu.git
    cd apcu
  2. Prepare the build environment using phpize.

    phpize
  3. Configure the build script. You can enable or disable features using the flags below.

    ./configure
  4. Compile and install the extension.

    make
    sudo make install
  5. Finally, enable the extension in your php.ini file:

    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.