Installation Instructions for APC
---------------------------------

APC has been successfully compiled on the following platforms:

    o Linux (RH 6.2/7.2/7.3/8)
    o FreeBSD
    o OpenBSD
    o MacOS 10.2 (statically compiled)

...and has been tested with the following PHP versions:

    o 4.2.2
    o 4.2.3
    o 4.3.0
    o 4.3.2

Versions prior to 4.2.2 have been officially deprecated by the PHP group, and
therefore aren't supported by APC either.

+---------------------+
| QUICK INSTALL (DSO) |
+---------------------+

These instructions assume your PHP installation is located in /usr/local/php.

$ gunzip -c apc_x.y.tar.gz | tar xf -
$ cd apc_x.y
$ /usr/local/php/bin/phpize
$ ./configure --enable-apc
$ make
$ make install

You will probably need to run the final command (make install) as root.

The above sequence of commands will install a .so file in your PHP
installation extension directory. The output of make install should display
that path to the screen.

Next you must edit your php.ini file, which is normally located in
/usr/local/php/lib/php.ini, and add the following line:

    extension="apc.so"

Replace "/path/to/php/extensions" with whatever path was displayed when you
ran make install above.

Then restart your web server and consult the output of phpinfo(). If there is
an informational section for APC, the installation was successful.

+------------------------+
| QUICK INSTALL (Static) |
+------------------------+

APC will not successfully compile on all systems as a DSO. If you run into
problems using the DSO quick install, you can try to compile it statically
into PHP. (The DSO install is recommended, though.)

These instructions assume the current directory is the root of the PHP source
tree, and that you have already configured PHP by running its bundled
configure script.

$ cd ext
$ gunzip -c apc_x.y.tar.gz | tar xf -
$ cd ..
$ ./buildconf
$ ./config.nice
$ make
$ make install

Once this is complete, simply restart your web server. You do not need to
modify your php.ini file to enable APC.

+-----------------+
| VERBOSE INSTALL |
+-----------------+

These instructions assume your PHP installation is located in /usr/local/php.

1.  Unpack your distribution file.

    You will have downloaded a file named something like apc_x.y.tar.gz.
    Unzip this file with a command like
    
        gunzip apc_x.y.tar.gz
    
    Next you have to untar it with
    
        tar xvf apc_x.y.tar

    This will create an apc_x.y directory. cd into this new directory:

        cd apc_x.y

2.  Run phpize.

    phpize is a script that should have been installed with PHP, and is
    normally located in /usr/local/php/bin assuming you installed PHP in
    /usr/local/php. (If you do not have the phpize script, you must reinstall
    PHP and be sure not to disable PEAR.)

    Run the phpize command:
    
        /usr/local/php/bin/phpize

    Its output should resemble this:

        autoheader: `config.h.in' is created
        You should update your `aclocal.m4' by running aclocal.
        Configuring for:
          PHP Api Version:   20020918
          Zend Module Api No:   20020429
          Zend Extension Api No:   20021010
 
    phpize should create a configure script in the current directory. If you
    get errors instead, you might be missing some required development tools,
    such as autoconf or libtool. You can try downloading the latest versions
    of those tools and running phpize again.
 
3.  Run the configure script.
 
    phpize creates a configure script. The only option you need to specify is
    the location of your php-config script:

        ./configure --with-enable-apc

    php-config should be located in the same directory as phpize.

    If you prefer to use mmap instead of the default IPC shared memory support,
    add --enable-mmap to your configure line.  If you don't understand the 
    difference between the two, stick with the default.

	If you prefer to use sysv IPC semaphores over the safer fcntl() locks, add
	--enable-sem to your configure line.  If you don't have a problem
	with your server segaulting, or any other unnatural accumulation of
	semaphores on your system, the semaphore based locking is slightly faster.

4.  Compile and install the files. Simply type: make install

    (You may need to be root in order to install)

    If you encounter errors from libtool or gcc during this step, please
    contact the project maintainer (dcowgill@php.net).

5.  Edit your php.ini

    make install should have printed a line resembling the following:

        Installing shared extensions: /path/to/extension/

    Copy the path /path/to/extension/ and add the following line to your
    php.ini file (normally located in /usr/local/php/lib/php.ini):

        extension="apc.so"

    If you don't have a php.ini file in that location, you can create it now.

6.  Restart the web server and test the installation.

    Restart your web server now (for apache, it's apachectl restart) and
    create a small test PHP file in your document root. The file should
    contain just the following line:

        <?php phpinfo() ?>

    Request that file in a web browser. If there is an entry for APC in the
    list of installed modules, the installation was successful.

    If APC is not listed, consult your web server error log. If it contains an
    error message saying that it can't load the APC extension, your system
    might not be able to load shared libraries created with PHP's build
    system. One alternative would be to compile APC statically into PHP. See
    the Quick Install (Static) instructions above.

    You should consult your error log anyway to see if APC generated any
    errors. On BSD-based platforms, it is typical for APC to be unable to
    allocate the default-sized shared memory segment. See below for hints on
    raising your system's shared memory limitations.

If all else fails, ask for help on the APC mailing list. Visit
http://apc.communityconnect.com/ for more information.

+-----------------+
| CONFIGURING APC |
+-----------------+

Although the default APC settings are fine for many installations, serious
users should consider tuning the following parameters:

    OPTION                  DESCRIPTION
    ------------------      --------------------------------------------------
    apc.enabled             This can be set to 0 to disable APC. This is
                            primarily useful when APC is statically compiled
                            into PHP, since there is no other way to disable
                            it (when compiled as a DSO, the zend_extension
                            line can just be commented-out).
                            (Default: 1)
                            
    apc.shm_segments        The number of shared memory segments to allocate
                            for the compiler cache. If APC is running out of
                            shared memory but you have already set
                            apc.shm_size as high as your system allows, you
                            can try raising this value.
                            (Default: 1)
                            
    apc.shm_size            The size of each shared memory segment in MB.
                            By default, some systems (including most BSD
                            variants) have very low limits on the size of a
                            shared memory segment.
                            (Default: 30)
                            
    apc.optimization        The optimization level. Zero disables the
                            optimizer, and higher values use more aggressive
                            optimizations. Expect very modest speed
                            improvements. Note: not implemented yet!!
                            (Default: 0)
    
    apc.num_files_hint      A "hint" about the number of distinct source files
                            that will be included or requested on your web
                            server. Set to zero or omit if you're not sure;
                            this setting is mainly useful for sites that have
                            many thousands of source files.
                            (Default: 1000)

    apc.gc_ttl              The number of seconds that a cache entry may
                            remain on the garbage-collection list. This value
                            provides a failsafe in the event that a server
                            process dies while executing a cached source file;
                            if that source file is modified, the memory
                            allocated for the old version will not be
                            reclaimed until this TTL reached. Set to zero to
                            disable this feature.
                            (Default: 3600)

    apc.filters             A comma-separated list of POSIX extended regular
                            expressions. If any pattern matches the source
                            filename, the file will not be cached. Note that
                            the filename used for matching is the one passed
                            to include/require, not the absolute path.
                            (Default: "")

    apc.mmap_file_mask      If compiled with MMAP support by using --enable-mmap
                            this is the mktemp-style file_mask to pass to the
                            mmap module for determing whether your mmap'ed memory
                            region is going to be file-backed or shared memory
                            backed.  For straight file-backed mmap, set it to
                            something like /tmp/apc.XXXXXX (exactly 6 X's).
                            To use POSIX-style shm_open/mmap put a ".shm"
                            somewhere in your mask.  eg.  "/apc.shm.XXXXXX"
                            You can also set it to "/dev/zero" to use your 
                            kernel's /dev/zero interface to anonymous mmap'ed 
                            memory.  Leaving it undefined will force an 
                            anonymous mmap.
