Version 6 (modified by moo, 14 years ago) (diff)


XCache and php.ini

We're explaining where to put XCache settings (the php.ini), and what options can be tuned with XCache, in this page.

Locating php.ini

It is simply to locate php.ini, simply check phpinfo() from your browser. Normally it's /etc/php.ini or /usr/local/lib/php.ini /usr/lib/php.ini etc.

SAPI Specified ini

PHP will scan for SAPI specified ini first in the form of php-{$sapi}.ini, and the general php.ini later. e.g.:

cgi/etc/php-cgi.ini(if cgi is built without fcgi)
cgi-fcgi/etc/php-cgi-fcgi.ini(if cgi is built with fcgi)

It's useful if you want to load/enable XCache in cgi-fcgi, while not in cli.

Separating php.ini

It depends on you or the one who distribute php at configure time. say, if you php is configure with

$ ./configure --with-config-file-scan-dir=/etc/php/
$ make

the built php will scan /etc/php/ for *.ini, and use all of them as additions to the normal php.ini above. You may put your custom xcache.ini into that directory and it will work, but you can't separate for different sapi.

If you don't know what the directory is, check phpinfo()

INI for XCache

It's time to explain xcache.ini itself, finally, no matter if you do or don't have all the basic aboves in mind.

Loading XCache module

;; install as zend extension (recommended), normally "$extension_dir/"
zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/
;; For windows users, replace with php_xcache.dll
zend_extension_ts = c:/php/extensions/php_xcache.dll
;; or install as extension, make sure your extension_dir setting is correct
; extension =
;; or win32:
; extension = php_xcache.dll

; required for >=php5.1 if you turn XCache on
auto_globals_jit = Off

XCache Administration

xcache.admin.user string
auth name.
xcache.admin.pass string
Should be md5($your_password), or empty to disable administration.
xcache.test string
Turn on to enable testing functionals. It will be explained where the option is needed.
xcache.coredump_directory string
Directory to save core dump on crash (SIGSEGV SIGABRT). Leave it empty to disable or somethink like "/tmp/phpcore/" to enable". Make sure it's writable by php (without checking open_basedir).

XCache Cacher

xcache.cacher boolean
Enable or disable opcode cacher. Not available if xcache.size is 0.
xcache.size int
0 to disable, non 0 to enable. Check if your system mmap allows.
xcache.count int
Specify how many chunks to split the cache. see SplitedCache?
xcache.slots size
Just a hash slot hints, you can always store count(items) > slots
xcache.var_size int
xcache.var_count int
xcache.var_slots size
Same as above, but for variables
xcache.readonly_protection boolean
If ReadonlyProtection is turned on, it will be a bit slower, but much safer. It won't be available for /dev/zero.
xxcache.mmap_path string
for *nix, xcache.mmap_path is a file path, not directory. for win32, xcache.mmap_path is anonymous map name, not a file path. Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection, 2 group of php won't share the same /tmp/xcache.

XCache Optimizer


XCache Coverager

xcache.coveragedump_directory string
Directory to dump coverage data. Make sure it's readable (care open_basedir) by coverage viewer script.
xcache.coveragedumper boolean
Enable or disable dumping coverage data. Not available if xcache.coveragedump_directory is empty.