Zendcache: Let the website fly

Source: Internet
Author: User
Tags copy gz file php file php code php script phpinfo zend linux

For commercial websites, efficiency is very important. At some e-commerce sites, the server's response speed determines its quality of service, and the server's load determines the maximum access capacity it can provide. Technicians always try their best to improve the response speed of the server.

zendcache--is an excellent product to improve the response speed of a server. There is data to prove that using Zendcache can increase the response speed of the server to the original 300% or more.

What's Zendcache?

First look at how PHP is running, a request for PHP script sent to the server, the server from the disk to find the appropriate files, first compile the script, and then execute it, and finally send the results. The time spent by: Find files + open files + read files + compile a few parts of the file. Zendcache is a PHP script cache that can store the compiled results of just the PHP script file in the Web server's memory, and it can be sent out soon if the next time someone requests it. Eliminates the time it takes for a server to compile a script every time a user requests a PHP file. Also, avoid the time it takes to find and read PHP files from disk. Therefore, it can greatly improve the response speed of the server.

Currently Zendcache can only run on Linux (glibc 2.1), Solaris 2.6, FreeBSD 3.4, and 4.0. Unfortunately, it does not support Windows systems at the moment.

Installation and use of Zendcache

Register a user on the zend.com, log on to the zend.com, and then download http://www.zend.com/store/products/zend-cache.php at the following address. Since Zendcache is a pay-as-you-go software, we can only download a 30-day beta, but it's a full-featured package. Try it, you can experience its powerful function. To download its trial version, select the "Test drive available" download directly.

The entire download should be divided into three steps, the first step is to download the Zendcache package. Select the appropriate platform packages directly from "supported Platforms". Note the application of the software platform and the corresponding version of PHP, class library type.

The second step is "Request Product License" (i.e. obtaining authorization from zend.com). The user is required to provide the host ID of his machine, or the MAC address of the computer's Internet card. Zend.com provides a tool to read the host card address, the user can download a small program called Lmutil.z from Zend.com, after decompression, execute it, you can get the computer's network card address. How to execute:

#./lmutil Lmhostid

In addition, the user can also check the MAC address of the NIC from the/var/log/messages.

Fill out this ID number in the form of the application license, select Request, and then wait patiently. Zend.com will email you within 48 hours, informing you that you can download your license.

The third step, after receiving the message, directly into the http://www.zend.com/store/pickup.php to download. License is a file called Zend_cache.dat.

installation process in Linux environment

First, unzip the zendcache-1[1].0.0-php_4.0.4-linux_glibc2.1-i386.tar.gz file:

# TAR-ZXVF Zendcache-1[1].0.0-php_4.0.4-linux_glibc2.1-i386.tar.gz

# CD Zendcache-1[1].0.0-php_4.0.4-linux_glibc2.1-i386

# CP *.so/usr/local/zend/lib

Then, copy the Zend_cache.dat to the/usr/local/zend directory.

Next, edit the php.ini file and add the following lines:

; Start of sample Zend Cache configuration section

Zend_cache.use_cwd=1

zend_cache.memory_consumption=64; 64MB

Zend_cache.validate_timestamps=1

Zend_extension=/usr/local/lib/zendcache.so

; End of sample Zend Cache configuration section

Restart the Apache server to take effect on the changes that you just made.

Edit a simple php file test.php in the Htdocs directory of the Web server, as follows:

?

Phpinfo ();

? >

Finally, in the browser, type: localhost/test.php, if the second part of the screen appears as follows, it means that Zendcache is working properly. The rest is to see the cache hit effect.

This program makes the Zend scripting language engine:

Zend Engine v1.x.x, Copyright (c) 1998-2000 Zend Technologies with Zend Cache v1.x.x, Copyright (c) 1999-2000, by Zend Tec Hnologies

Test Zendcache hit Ratio

Along with the Zendcache package, there is also a portion of the PHP code that is called in the browser to visually display the Zendcache hit effect. Simply copy the Cache_gui subdirectory to the Htdocs directory of the Web server. Type http://localhost/cach_gui/index.html in the browser URL bar to see the cache hit effect (as shown in the attached picture).

If the graphics in your browser are not displayed and you are prompted to compile the GD module in PHP that does not support PNG graphics, you will have to compile PHP again to enable the GD module to support the PNG graphics display. Articles on how to compile PHP so that it supports PNG can be found on the web, and this article is not documented. If you don't know if your PHP supports PNG, you can use the Phpinfo () function to view it. In general, if you do not specifically indicate that PNG is supported at compile time, GD will not support PNG by default at compile time.

Note: If you use the Zend Optimizer at the same time, you should place the above lines after Zend Optimizer, or your Apache server will not start.



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.