PHP cache xcache Installation notes

Source: Internet
Author: User

Wednesday,-Jason
Xcache is a fast and stable PHP opcode cache. it has been well tested and runs stably on high-traffic/high-load production machines. tested on Linux and supports the latest of all existing PHP branches
Released, such as php4.4 php5.2, and supports thread security. It is better than similar opcode caches. For example, you can quickly follow up the PHP version. For more information, see http://xcache.lighttpd.net.
The following describes two features of xcahce:
Compile PHP code (similar to. NET and Java compilation, with different internal mechanisms), so that you do not need to read PHP files repeatedly to accelerate the efficiency of the entire program;
You can cache data to the memory and directly call the data. For example, you can only read data from the database once and save the data to the xcache, you don't need to use the database anymore (this is an ideal environment ).
Before installation, let's talk about my testing environment: WINXP + apache2.2.8 + php5.2.5 + mysql5.0.45
You can download the corresponding version you need: http://xcache.lighttpd.net/wiki/Release-1.2.2
Here we want to explain the problems that may occur in Windows:
Whether you are using IIS or Apache, if you are using FAST-CGI, download xcache 1.2.2 For PHP 5.2.5-CNT, note that you must set C: users of/Windows/temp or related users can read and write permissions.
If Apache on windows is not using the FAST-CGI method, download xcache 1.2.2 For PHP 5.2.5
Note: our general installation method is not FAST-CGI, so directly download xcache 1.2.2 For PHP 5.2.5 just fine. Another point is that xcache 1.2.2 currently does not support php5.2.6, so it can only be installed with php5.2.5!
How to configure how to load PHP using Apache on Windows:
Open CONF/httpd. conf in the Apache directory and find loadmodule php5_module.
FAST-CGI Mode settings:
Loadmodule php5_module "D:/program files/PHP-Apache/php5apache2_2_filter.dll"
Non FAST-CGI Mode settings:
Loadmodule php5_module "D:/program files/PHP-Apache/php5apache2_2.dll"
 
NOTE: For the installation of the mysqldata library, use this mode switch in Windows to install mysql-5.1.26-rc-win32.exe.
Otherwise, the problem that MySQL can be loaded but cannot be used will occur. Apache will automatically fail!
 
Decompress the downloaded xcache file and decompress it to a release_ts folder. Put php_xcache.dll in this folder to your PHP ext directory.
For example, if my PHP file is installed on the D Drive, use the following path: D:/PHP/EXT/php_xcache.dll.
Copy the xcache. ini content in the release_ts folder to the end of PHP. ini. The following shows my configurations and related descriptions of each configuration. The configuration is as follows:
[Xcache-common]
; Install Zend extension (recommended). The path is generally "$ extension_dir/xcache. So"
; Zend_extension =/usr/local/lib/PHP/extensions/non-debug-non-ZTS-xxx/xcache. So
; Windows System example:
; Zend_extension_ts = D:/PHP/EXT/php_xcache.dll
; Or you can install xcache into extension. Make sure that your extension_dir is correctly set and put xcache. So or php_xcache.dll in this directory.
; Extension = xcache. So
; Or Win32 system: (Note: Because I have already set extension_dir, the following settings are correct. If extension_dir is not configured, use zend_extension_ts)
Extension = php_xcache.dll
[Xcache. admin]
Xcache. admin. enable_auth = on
Xcache. admin. User = "username"
; Xcache. admin. Pass = MD5 ($ your password)
Xcache. admin. Pass = "password"
[Xcache]
Most of the options here can be modified only in ini. All options listed here are default values, unless otherwise stated
; Select low level SHM/Allocator scheme implemenation
Xcache. shm_scheme = "MMAP"
; Disabled: xcache. size = 0
Enabled: xcache. size = 64 m (any value> 0). Pay attention to the upper limit of your system MMAP.
Xcache. size = 64 m
We recommend that you set the number of CPUs (CAT/proc/cpuinfo | grep-C processor)
Xcache. Count = 1
; Is just a reference value, you can safely store more projects (PHP scripts/variables)
Xcache. Slots = 8 K
; Cache item TTL, 0 = Permanent
Xcache. TTL = 0
; Interval between scanning expired items, 0 = No scanning, other values in seconds
Xcache. gc_interval = 0
; Same as above, only for variable cache settings
Xcache. var_size = 32 m
Xcache. var_count = 1
Xcache. var_slots = 8 K
; By default, ini_set () is allowed ()
Xcache. var_ttl = 0
; Maximum TTL value
Xcache. var_maxttl = 0
Xcache. var_gc_interval = 0
; For testing only
Xcache. test = off
;/Dev/zero is invalid
Xcache. readonly_protection = off
For * nix systems, xcache. mmap_path indicates the file path rather than the directory (it may not exist but must be created ).
If you want to enable readonlyprotection, you can use "/tmp/xcache"
; Two PHP groups will not share the same/tmp/xcache
For Win32 systems, xcache. mmap_path = anonymous Map Name, not the file path. We recommend that you use xcache to avoid conflicts with other software.
Xcache. mmap_path = "zero"
; Only for * nix Systems
; Set to null (disabled) or similar to "/tmp/phpcore /"
; Note that this directory should be able to be written to a file by PHP (not related to open_basedir)
Xcache. coredump_directory = ""
The following project will implement PHP code caching after enabling
Xcache. cacher = off
Xcache. Stat = off
Xcache. optimizer = off
[Xcache. coverager]
If xcache. coveragedump_directory is set to null, this setting is automatically set to off
Xcache. coverager = off
; Make sure that this directory can be read by the coverage viewer script (Note: open_basedir)
; Dependent on xcache. coverager = on
Xcache. coveragedump_directory = ""
 The following describes the code in the configuration information above.
[Xcache. admin]
Xcache. admin. enable_auth = on
Xcache. admin. User = "username"
; Xcache. admin. Pass = MD5 ($ your password)
Xcache. admin. Pass = ""
This code is set for the admin folder under the release_ts directory. Copy the admin folder to the Apache document directory and directly access http: // localhost/admin. A dialog box is displayed, enter the user name and password. This user name and password are set for login in this dialog box. Note that the password is a string that requires MD5 encryption instead of plaintext. The main page is the xcache monitoring page.
Xcache INI file configuration reference
Http://xcache.lighttpd.net/wiki/XcacheIni
Http://www.ibm.com/developerworks/cn/opensource/os-php-fastapps1/
After the configuration is complete, restart your Web Server (IIS or Apache) and view phpinfo () to see that xcache has been loaded.
The following figure shows the configured xcache.

Note that xcache can only cache some default objects, such as int, string, and array, but cannot cache objects. Otherwise, an error will be reported during reading.
If you want to cache an object, you can also serialize the object and deserialize it again during reading.
The following is a simple xcache class I wrote:
Program code
<? PHP
/**
* Xcache Moudle
*/
Class cachehelper {
Public $ prefix;
Function _ construct (){
If (! Function_exists ('xcache _ get ')){
Exit ("This application must required xcache module .");
}
}
/**
* _ Set
*
* @ Param mixed $ name
* @ Param mixed $ Value
* @ Access public
* @ Return void
*/
Public Function _ set ($ name, $ value ){
Xcache_set ($ this-> prefix. $ name, $ value );
}
/**
* _ Get
*
* @ Param mixed $ name
* @ Access public
* @ Return mixed
*/
Public Function _ Get ($ name ){
Return xcache_get ($ this-> prefix. $ name );
}
/**
* _ Isset
*
* @ Param mixed $ name
* @ Access public
* @ Return bool
*/
Public Function _ isset ($ name ){
Return xcache_isset ($ this-> prefix. $ name );
}
/**
* _ Unset
*
* @ Param mixed $ name
* @ Access public
* @ Return void
*/
Public Function _ unset ($ name ){
Xcache_unset ($ this-> prefix. $ name );
}
}
?>
Several articles to be referenced
Http://hi.baidu.com/binarie/blog/item/619ccf0efedd19e336d122bd.html
Http://www.ibm.com/developerworks/cn/opensource/os-php-fastapps1/

========================================================== ====================
High-load-Oriented Architecture: Lighttpd + PhP (FastCGI) + memcached + squid

December 21st, 2006 Michael posted in other technologies, Sila East pull 6,855 views
Because of the new project, I started to transfer from Apache to Lighttpd, and there was a lot of memcached usage. I would like to take this opportunity to make some modifications to the server environment of toplee.com, and sort out a document by the way!
For more experience in large architecture, see my previous blog: http://www.toplee.com/blog/71.html
12.31 The following content has been completed as of today:
1. Complete Lighttpd installation and configuration, and perform a lot of optimization;
2. I have read the documents on http://trac.lighttpd.net/trac/wiki;
3. configured FastCGI support for Lighttpd and PHP;
4. Added PHP support for xcache;
5. Set resolution for some domain names on Lighttpd;
6. Apache has completed mod_rewrite and mod_proxy to transfer some domain names and all PHP accesses to Lighttpd;
7. Complete the memcached environment setup and modify some database operations to cache on MC;

Effect:
1. The system load has reduced a lot and the response speed has been improved;
2. The effect of MC is very good, and the pressure on the database is greatly reduced.
Todo:
(The following things will be done after I buy the second server. At present, I am only doing this for my friend's project)
-Configure the Master/Slave Mode of MySQL to separate write and read operations on the database.
-. Join the squid group for cache Acceleration
-. Others (such as DNS load balancing and LVS layer-4 switching ...)
To be continued...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.