Because the domestic website ICP filing is troublesome, the author places the website in Hong Kong. Although the website is not subject to record filing, the access speed is generally 2-3 times slower than that of websites in China. Therefore, we have made some simple improvements to the website, for example, the cache system is used to speed up website page access.
Currently, many web cache systems are used, including squid, varnish, proxy_cache provided by Nginx, fastcgi_cache, APC, and Xcache in FastCGI. Systems such as squid, varnish, and Nginx's proxy_cache are heavyweight products. Configuration and maintenance are troublesome and are not suitable for small websites. In addition, these systems are generally used to cache static content, such as fastcgi_cache in FastCGI, which is mainly used to cache dynamic content. Therefore, it is extremely fast to access websites using fastcgi_cache, however, when I use it, I find it difficult to maintain it. In particular, after each website has data to be updated, if you need to manually clear the cache after the expiration of the buffer period to see the updated content of the website; as for APC, I personally feel that the performance is normal. When comparing it with Xcache, I found that the speed of accessing the Xcache website is significantly higher than that of using the APC website (I have not specifically tested it ), therefore, Xcache is selected.
We all know that PHP is a dynamic language that is executed in an interpreted manner. Therefore, every execution of PHP code is parsed and converted into an opcode ). Xcache is an open-source operation code Cache/optimizer. It caches the parsed/converted PHP operation code to a file (until the original code is modified) to avoid repeated parsing processes, the code execution speed is improved. Generally, the page generation rate is increased by 2-5 times, server load is reduced, and the website access speed is improved.
1. Install Xcache
# Wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
# Tar zxvf xcache-1.3.0.tar.gz
# Cd xcache-1.3.0
#/Usr/local/php/bin/phpize
#./Configure-enable-xcache-coverager-enable-xcache-optimizer-with-php-config =/usr/local/php/bin/php-config
# Make & make install
Note:-enable-xcache indicates that Xcache support is enabled;-enable-xcache-coverager indicates that additional features are included for measuring accelerator efficacy;-enable-xcache-optimizer indicates that operation code optimization is enabled.
After the installation is complete, the system prompts xcache. so module generated path, this generated path for/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/, and then xcache. so move to the/usr/local/php/include/php/ext directory.
Ii. configure and manage Xcache
1. Modify the php configuration file
During configuration, refer to the xcache configuration template xcache. ini, which is located in the Xcache installer.
# Vi/usr/local/php/lib/php. ini and add the following content:
Extension_dir =/usr/local/php/include/php/ext
[Xcache-common]
Extension = xcache. so
[Xcache. admin]
Xcache. admin. enable_auth = On
Xcache. admin. user = "xcache"
Xcache. admin. pass = ""
[Xcache]
Xcache. shm_scheme = "mmap"
Xcache. size = 60 M
Xcache. count = 1
Xcache. slots = 8 K
Xcache. ttl = 0
Xcache. gc_interval = 0
Xcache. var_size = 4 M
Xcache. var_count = 1
Xcache. var_slots = 8 K
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 = ""
2. Generate Xcache cache files
# Touch/tmp/xcache
# Chmod 777/tmp/xcache
3. Generate the Xcache administrator secret (MD5 ciphertext)
# Echo-n" 123456 "| md5sum
E10adc3949ba59abbe56e057f20f883e
Then paste the generated MD5 ciphertext into the php. ini file xcache. admin. pass = "" option, xcache. admin. pass = "e10adc3949ba59abbe56e057f20f883e"
4. Copy the Xcache hypervisor to the root directory of the website.
# Cp-a/tmp/xcache-1.3.0/admin // usr/local/nginx/html/
Then restart PHP, then access the http://www.2cto.com/admin, the user name is xcache password is 123456; in addition, you can also verify PHP support Xcache through phpinfo.