XCache Working principle:
XCache is the open source opcode and var cache, it can speed up PHP is the reason is xcache by caching the user has requested PHP compiled results, Save the PHP compilation cache in the server's memory so that the user can request the same PHP resolution again and then compile the PHP again directly from the XCache cache result. Prevent PHP from being compiled again to bring too much load to the server. Here's how to use XCache to speed up your PHP server under the LNMP environment.
System environment: CentOS 6.3 (Final) + Nginx 1.6.0 + MariaDB-5.5.37 + PHP-5.5.10 + xcache-3.1.0
LNMP environment Here I have set up, for the LNMP environment optimization, I think the follow-up I will record them all together for discussion.
Install xcache-3.1.0:
The code is as follows |
Copy Code |
wget http://xcache.lighttpd.net/pub/Releases/3.1.0/xcache-3.1.0.tar.gz Tar zxvf xcache-3.1.0.tar.gz CD xcache-3.1.0 |
My PHP installation directory in:/data/app/php5/so enter the xcache-3.1.0 source directory before we execute:
/data/app/php5/bin/phpize otherwise prompts the error cannot find: Config.m4 file.
Configure XCache:
The code is as follows |
Copy Code |
./configure–enable-xcache–enable-xcache-coverager–enable-xcache-optimizer–with-php-config=/data/app/php5/bin/ Php-config |
Compiling and installing Xcache:make && make install
The above XCache installation results will return a:
Installing Shared extensions:/data/app/php5/lib/php/extensions/no-debug-non-zts-20121212/
Finally, we can only load xcache.so extensions on the php.ini. By the way, the new version XCache does not support Zend loading. Here's my profile:
The code is as follows |
Copy Code |
extension_dir=/data/app/ php5/lib/php/extensions/no-debug-non-zts-20121212/ [xcache-common] Extension = xcache.so [ Xcache.admin] Xcache.admin.enable_auth = on Xcache.admin.user = "XCache" Xcache.admin.pass = " C8837b23ff8aaa8a2dde915473ce0991″ [XCache] Xcache.shm_scheme = "Mmap" xcache.size=60m Xcache.count =1 xcache.slots =8k xcache.ttl=0 xcache.gc_interval =0 xcache.var_size=4m Xcache.var_ Count =1 xcache.var_slots =8k xcache.var_ttl=0 xcache.var_maxttl=0 Xcache.var_gc_interval =300 Xcache.test =off Xcache.readonly_protection = on Xcache.mmap_path = "/tmp/xcache" Xcache.coredump_ Directory = "" Xcache.cacher =on xcache.stat=on Xcache.optimizer =off [Xcache.coverager] Xcache.coverager =on Xcache.coveragedump_directory = " |
Finally, create the Xcache.mmap_path file. Touch/tmp/xcache && chmod 777/tmp/xcache
By this, your PHP server has been installed with xcache acceleration. You can access phpinfo to view it.
For the administration of XCache caching, you can do this:
Copy the files in the XCache source directory Htdocs to your site root directory. Here I copy and rename the XCache folder.
This allows you to manage and monitor your XCache cache by Http://yourdomain/xcache, as shown below:
Test, this is not going to be the case. Because this is my real environment, not the test machine used in the experiment. But by checking XCache official website, see XCache Update very quickly. Proof that XCache has been moving forward.