Permalink
Fetching contributors…
Cannot retrieve contributors at this time
321 lines (246 sloc) 13.6 KB
Installation Instructions for APCu
---------------------------------
This version of APCu should work on PHP 4.3.0 - 4.4.x and
5.1.0 - 5.2.x. Yes, that means PHP 5.0.x is no longer
supported. Upgrade to PHP 5.1.x or 5.2.x and you will
notice all sorts of performance increases.
CVS Instructions
----------------
Building from CVS can be done like this:
git clone https://github.com/krakjoe/apcu
cd apcu
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
export TEST_PHP_ARGS='-n'
make test
make install
Suggested Configuration (in your php.ini file)
----------------------------------------------
extension=apcu.so
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=1
These are fully described at the bottom of this file.
+---------------------+
| QUICK INSTALL (DSO) |
+---------------------+
These instructions assume your PHP installation is located in /usr/local/php and you
want Apache optimizations (--with-apxs).
$ gunzip -c apcu_x.y.tar.gz | tar xf -
$ cd apcu_x.y
$ /path/to/phpize
$ ./configure [--with-php-config=/path/to/php-config]
$ 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="apcu.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 APCu, the installation was successful.
+------------------------+
| QUICK INSTALL (Static) |
+------------------------+
APCu 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 apcu_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 APCu.
+-----------------+
| 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 apcu_x.y.tar.gz.
Unzip this file with a command like
gunzip apcu_x.y.tar.gz
Next you have to untar it with
tar xvf apcu_x.y.tar
This will create an apcu_x.y directory. cd into this new directory:
cd apcu_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 --enable-apcu [--with-php-config=/path/to/php-config]
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="apcu.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 APCu in the
list of installed modules, the installation was successful.
If APCu is not listed, consult your web server error log. If it contains an
error message saying that it can't load the APCu extension, your system
might not be able to load shared libraries created with PHP's build
system. One alternative would be to compile APCu statically into PHP. See
the Quick Install (Static) instructions above.
You should consult your error log anyway to see if APCu generated any
errors. On BSD-based platforms, it is typical for APCu to be unable to
allocate the default-sized shared memory segment. See below for hints on
raising your system's shared memory limitations.
+------------------+
| CONFIGURING APCu |
+------------------+
OPTION DESCRIPTION
------------------ --------------------------------------------------
apc.enabled This can be set to 0 to disable APCu. This is
primarily useful when APCu is statically compiled
into PHP, since there is no other way to disable
it (when compiled as a DSO, the extension
line can just be commented-out).
(Default: 1)
apc.enable_cli Mostly for testing and debugging. Setting this enables APCu
for the CLI version of PHP. Normally you wouldn't want to
create, populate and tear down the APCu cache on every CLI
request, but for various test scenarios it is handy to be
able to enable APCu for the CLI version of APCu easily.
(Default: 0)
apc.preload_path Sets the path to text files containing caches to load
from disk upon initialization of APCu.
preload_path should be a directory where each file follows
$key.data
where $key should be used as the entry name and the contents
of the file contains serialized data to use as the value of
the entry.
(Default: null)
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. M/G suffixes must be used.
(Default: 32)
apc.shm_segments The number of shared memory segments to allocate
for the compiler cache. If APCu 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. Setting this to a
value other than 1 has no effect in mmap mode
since mmap'ed shm segments don't have size limits.
(Default: 1)
apc.ttl The number of seconds a cache entry is allowed to
idle in a slot in case this cache entry slot is
needed by another entry. Leaving this at zero
means that your cache could potentially fill up
with stale entries while newer entries won't be
cached.
(Default: 0)
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.smart If you begin to get low on resources, an expunge of the cache
is performed if it is less than half full. This is not always
a suitable way of determining if an expunge of the cache
should be per
apc.smart allows you to set a runtime configuration value which
is used to determine if an expunge should be run
if (available_size < apc.smart * requested_size)
apc_cache_expunge()
(Default: 0)
apc.entries_hint A "hint" about the number variables expected in the
cache. Set to zero or omit if you're not sure.
(Default: 4096)
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 determining 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.
(Default: "")
apc.slam_defense On very busy servers whenever you start the server or
modify files you can create a race of many processes
all trying to cache the same data at the same time.
By default, APCu attempts to prevent "slamming" of a key.
A key is considered "slammed" if it was the last key set,
and a context other than the current one set it ( ie. it
was set by another process or thread )
Note:
APCu does not store enough information to
catch every occurrence, sufficient none the less.
(Default: 1)
apc.serializer Defines which serializer should be used. Default is the
standard PHP serializer. Other can be used without having
to re compile apc, like igbinary for example.
(apc.serializer=igbinary)
/* The remaining entries concern file upload progress support */
apc.rfc1867 RFC1867 File Upload Progress hook handler is only available
if you compiled APCu against PHP 5.2.0 or later. When enabled
any file uploads which includes a field called
APCu_UPLOAD_PROGRESS before the file field in an upload form
will cause APCu to automatically create an upload_<key>
user cache entry where <key> is the value of the
APCu_UPLOAD_PROGRESS form entry.
Note that the file upload tracking is not threadsafe at this
point, so new uploads that happen while a previous one is
still going will disable the tracking for the previous.
(Default: 0)
apc.rfc1867_prefix Key prefix to use for the user cache entry generated by
rfc1867 upload progress functionality.
(Default: "upload_")
apc.rfc1867_name Specify the hidden form entry name that activates APCu upload
progress and specifies the user cache key suffix.
(Default: "APCu_UPLOAD_PROGRESS")
apc.rfc1867_freq The frequency that updates should be made to the user cache
entry for upload progress. This can take the form of a
percentage of the total file size or a size in bytes
optionally suffixed with 'k', 'm', or 'g' for kilobytes,
megabytes, or gigabytes respectively (case insensitive).
A setting of 0 updates as often as possible, which may cause
slower uploads.
(Default: 0)