wiki:PhpIni

Version 2 (modified by moo, 8 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.:

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

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()

XCache.ini

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/xcache.so"
zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
;; For windows users, replace xcache.so 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 = xcache.so
;; or win32:
; extension = php_xcache.dll

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

XCache Administration

NameDefaultChangeable
xcache.admin.user"mOo"PHP_INI_SYSTEM
xcache.admin.pass""PHP_INI_SYSTEM
xcache.testOffPHP_INI_SYSTEM
xcache.coredump_directory""PHP_INI_SYSTEM
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 liek "/tmp/phpcore/" to enable". Make sure it's writable by php (without checking open_basedir).

XCache Cacher

NameDefaultChangeable
xcache.cacherOnPHP_INI_SYSTEM
xcache.size0PHP_ALL
xcache.count1PHP_INI_SYSTEM
xcache.slots8KPHP_INI_SYSTEM
xcache.var_size0PHP_INI_SYSTEM
xcache.var_count1PHP_INI_SYSTEM
xcache.var_slots8KPHP_INI_SYSTEM
xcache.readonly_protectionOffPHP_INI_SYSTEM
xcache.mmap_path"/dev/zero"PHP_INI_SYSTEM
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 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

NameDefaultChangeable
xcache.optimizerOffPHP_ALL

XCache Coverager

NameDefaultChangeable
xcache.coveragedump_directory"/tmp/pcov/"PHP_INI_SYSTEM
xcache.coveragedumperOffPHP_INI_ALL
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.