How to perform Wincache installation and configuration Tutorial _win server under Windows 2008 R2

Source: Internet
Author: User
Tags memory usage naming convention php and php script vc9 zend microsoft iis

Microsoft has launched a new wincache extension in conjunction with the FASTCGI model, a PHP accelerator that can significantly increase the speed with which PHP apps are used in Windows. All PHP applications can take advantage of the acceleration provided by this extension without having to modify any code. All that needs to be done is to activate the extension and read it by the PHP engine. Contrary to Eaccelerator, Wincache requires the use of NTS (not thread-safe) versions of PHP, and is therefore more suitable for use with fastcgi.

The Wincache extension includes three different kinds of cache usage, and the following will cover the three caches and the facilities they can provide.

php opcode Cache
PHP is a script-running engine that reads input data streams that contain text and PHP instructions, and then outputs another data stream that is typically in HTML format. This means that on a server, the PHP engine reads, parses, encodes, and executes a script whenever the network user needs it. This kind of reading, parsing and coding will add extra burden to the server's CPU and file system, so it will affect the overall operation of the PHP script. The PHP opcode cache is used to store encoded script bytecode in memory so that the PHP engine can be reused for subsequent operations on the same script.
• File Caching
In addition to using opcode caching, the PHP engine also needs to read script files from the file system. When a PHP script is stored in a remote UNC (Universal naming convention) file share, a significant action appears in the file operation. The Windows cache extension includes a file cache to store the contents of PHP script files in memory, which reduces the number of file operations for the PHP engine.
• Relative path caching
PHP scripts often refer to or use files accessed through relative paths. And each relative path must be converted by the PHP engine into an absolute path to be able to use. When a PHP application accesses a lot of PHP files through a relative path, the work of turning the relative path into an absolute path will have a negative impact on the operation of the application. The Windows cache extension provides a specific cache for relative paths, which can be stored to transform maps of relative paths to absolute paths, thereby reducing the total amount of conversion of relative paths.

Installation method:
This extension has two installation packages: one for 5.2.X versions of PHP and the other for PHP 5.3.X.
1. Open the installation package for your PHP version
2. Copy the Php_wincache.dll file to the PHP Extensions folder. Usually this folder is called "ext", and all the PHP binaries are in a folder. Like what:
"C:\Program Files\php\ext"
3. Open the php.ini file in a text editor with the same location. Like what:
"C:\Program Files\php\php.ini"
4. At the end of the above document, add a line:
Extension=php_wincache.dll
5. Save and close php.ini.
6. Restart your server's application library to read the configuration changes.

Configuration requirements:
This extension can only be run on the following configurations:
Windows version:
windows XP SP3 with IIS 5.1 and FastCGI Extension
Windows Server 2003 with IIS 6.0 and FastCGI Extension
windows Vista SP1 with IIS 7.0 and FastCGI Module
Windows Server 2008 with IIS 7.0 and FastCGI Module
windows 7 with IIS 7 and FastCGI Module
Windows Server 2008 R2 with IIS 7.0 and FastCGI Module

PHP Version:
php 5.2.X, non-thread-safe Build
PHP 5.3 X86, Non-thread-safe VC9 Build
Note: This extension can only be used when the server is running PHP through FASTCGI, and the version of PHP must be NTS (not thread safe). Wincache Accelerator installation and configuration, Wincache1.1.0 for5.3, this everyone can go to Microsoft IIS official download, he will greatly improve your PHP system to run efficiency! If your server is running open source programs, do not need to Zend, we strongly recommend that you use this configuration!

Open the following URL to download the Wincache module

Http://www.iis.net/downloads/microsoft/wincache-extension


Also pull the page to the bottom to find: Download Wincache

and download Wincache 1.1 for PHP 5.3–x86, this file, be sure to note that the Wincache version should correspond to the PHP version, we are using PHP 5.3.21 here so we choose this Wincache 1.1 for PHP 5.3 –x86 this for download.



Download completed, found Wincache-1.1.0-5.3-nts-vc9-x86.exe, this file is an EXE file, do not rush to open, we unpack it

Extract Wincache-1.1.0-5.3-nts-vc9-x86.exe This file, you can find that there is a php_wincache.dll


Here, we need to copy Php_wincache.dll this file to the "D:\Server\php\ext" directory

Then we'll open the IIS Manager and open the Phpmanager management software.

Click the Enable or disnable an extension to open the Php_wincache function

Pull to the bottom, find Php_wincache.dll, right button enable can be enabled Php_wincache

Here we continue to share some information:

Windows Cache Extension APIs for PHP

If a PHP developer wants to use Windows cache Extension for PHP cache application data, Windows cache Extension has an array API available for developers and Windows cache Extension Interactive, including the storage of cache data, access to the system, such as the fast state.
1. The session is stored in Windows Cache.

In PHP preset mode, the session data is stored in the file, Windows Cache Extension for PHP open a set, so that PHP can store session memory, to speed up the session access speed, as long as the changes in PHP The session.save_handler in. INI can be:

[Session]
; Headler used to store/retrieve data.
; Session.seve_handler = Files <-Original configuration
Session.save_handler = Wincache <-apply session store into Windows Cache Extension

Windows Cache Extension is currently supported on the 1.1 version of the transfer feature for the session.

Then restart the IIS server. This time the Wincache Accelerator has been installed!

The following information is from the Microsoft Taiwan official website!
Address: http://www.microsoft.com/taiwan/technet/iis/expand/Windows_Cache_Extension_for_PHP.aspx

Set Value Description Preset values
Wincache.fcenabled Enable file cache. 1
Wincache.fcenabledfilter The IIS platform identification code to use the file cache, separated by commas if there are multiple groups. Null
Wincache.fcachesize Maximum memory usage for file cache (MB) 24
Wincache.fcndetect Whether to enable file change detection (Opcode cache to determine whether the file changes and clear the Opecode cache). 1
Wincache.maxfilesize Maximum single file size to be placed in cache (KB) 256
Wincache.ocenabled Whether to enable Opcode Cache 1
Wincache.ocenabledfilter To use the IIS platform identifier for Opcode Cache, separated by commas if there are multiple groups. Null
Wincache.ocachesize Maximum memory usage for Opcode Cache (MB) 96
Wincache.filecount Define the maximum number of files that are expected to be fetched quickly, which can be preconfigured when PHP is initialized, but if the number is actually exceeded, PHP will be reconfigured. 4096
Wincache.chkinterval Define the cycle time (in seconds) of the PHP check cache. 30
Wincache.ttlmax Sets the maximum time (in seconds) that a cache is persisted when not in use. 1200
Wincache.enablecli Sets whether command line mode is enabled 0
Wincache.ignorelist Set which files are not included in the cache, and if you have multiple files, use the line symbol "|" to separate. Null
Wincache.namesalt Set a salt value to avoid collisions with key values that are set when the user is fast fetching. Null
Wincache.ucenabled Whether to enable the user cache. 1
Wincache.ucachesize Sets the maximum memory usage (MB) of the user's cache. 8

After you have set up, you will recycle the PHP application's set area, or restart IIS before it takes effect.

Type Open or close How much memory is allocated Maximum number
File caching Fcenabled= 1/0 Fcachesize= 128M Single Maximum file maxfilesize
OpCode caching Ocenabled =1/0 Ocachesize= 128M Maximum number of files FileCount 4096
Path caching
Session Cache Scachesize
Ucenabled Ucachesize

Wincache.fcenabled= 1 (ON) 0 (off) enables or turns off the file caching feature
The wincache.fcachesize= 128M defines the maximum memory space (in megabytes) allocated for the file cache. If the total cache file size exceeds the set value, most of the stale files are removed from the file cache.
Wincache.maxfilesize =256m defines the size of a single file to be cached. If the file size exceeds this value, it will not be cached. This setting is limited to file caching.
Wincache.ocenabled =1 (ON) 0 (off) turn on or off the opcode caching feature
Wincache.ocachesize= 128M defines the maximum memory space allocated for opcode caching
Wincache.filecount 4096 1024 16384 defines how many files will be cached so that the memory space can be allocated at the outset. If the number of files exceeds the preset value, the extension will reallocate more memory space as needed.
Wincache.chkinterval= 2 Php_ini_system Define how often (in seconds) This extension examines file changes to update the cache
Wincache.ttlmax 1200 60 7200 defines the maximum presence time of the entry in the cache without being used.
Wincache.ignorelist defines a series of files that should not be cached by this extension. File lists can only specify files in the form of file names, and the "|" Interval. For example:wincache.ignorelist = "index.php|misc.php|admin.php"
Wincache.namesalt No value no no value No value Php_ini_system defines a string that is used when naming the cached object in memory. This is done to prevent errors when other applications in the server attempt to use shared memory.

Note: Wincache and Zendloader conflict, so the two can only choose one, because the Wincache is memory-level optimization, the speed of natural than zendloader much faster, this according to the specific configuration options. How the program needs to Zend encryption and decryption and then use Wincache words that can only turn off the Wincache file caching function.

Related Article

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.