CentOS 6 System Compile and install the APC extension tutorial for PHP

Source: Internet
Author: User
Tags apc garbage collection posix regular expression centos


Download Address: Http://pecl.php.net/package/APC. This extended update is slow and recommends installing the latest version because some unknown bugs have been resolved by the latest version.

Install APC

Get APC:


# CD/USR/LOCAL/SRC &&
wget http://pecl.php.net/get/APC-3.1.13.tgz &&
TAR-ZXVF apc-3.1.13.tgz &&
CD APC-3.1.13

Compile Installation:


#/usr/local/php5/bin/phpize &&
./configure--ENABLE-APC--enable-apc-mmap--with-php-config=/usr/local/php5/bin/php-config &&
Make && make install

Configure PHP.ini and add the following:


Extension = "apc.so"
apc.rfc1867 = On
Apc.cache_by_default = Off
Apc.enabled=1
Apc.shm_segments=1
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
APC.MMAP_FILE_MASK=/TMP/APC. Xxxxxx
Apc.enable_cli=off
Apc.max_file_size = 5M
Apc.include_once_override = Off
Apc.stat = On
Restart Apache to view phpinfo:
Php-apc


Expand your reading:
1. Official Documents: http://cn2.php.net/manual/zh/book.apc.php
2, http://www.neatstudio.com/show-2061-1.shtml


; Alternative PHP cache for caching and optimizing PHP intermediate code

Apc.cache_by_default = On
; sys
; Whether to enable buffering for all files by default.
; When set to off and used with a apc.filters instruction that starts with a plus sign, the file is cached only when the filter is matched.

APC.ENABLE_CLI = Off
; sys
; Whether to enable the APC feature for the CLI version and open this directive only for testing and debugging purposes.

apc.enabled = On
; If APC is enabled, it is the only way to disable it if the APC is statically compiled into PHP.

Apc.file_update_protection = 2
; sys
; When you modify a file on a running server, you should perform an atomic operation.
; That is, first write in a temporary file, and then rename the file (MV) to the final name.
; Programs such as text editors and CP, TAR, and so on, do not operate this way, resulting in the possibility of buffering the defective files.
; The default value of 2 indicates that when the file is accessed, it is not buffered if it finds that the modified time distance is less than 2 seconds.
; The unfortunate visitor may get the incomplete content, but the bad effect will not be magnified by the cache.
; If you can make sure that all of the update operations are atomic, you can turn off this feature with 0.
; If your system is slow to update due to a large number of IO operations, you need to increase this value.

Apc.filters =
; sys
; A comma-delimited list of POSIX-extended regular expressions.
; If the source file name matches any one of the patterns, the file is not cached.
; Note that the filename used to match is the file name passed to Include/require, not the absolute path.
; If the first character of the regular expression is "+", it means that any file that matches the expression will be cached.
; If the first character is "-", no matches are cached. "-" is the default value and can be omitted.

Apc.ttl = 0
; sys
; The number of seconds the cache entry allowed to linger in the buffer. 0 means never times out. The recommended value is 7200~36000.
; A setting of 0 means that the buffer may be filled with old cache entries, resulting in the inability to cache new entries.

Apc.user_ttl = 0
; sys
; Similar to Apc.ttl, the recommended value is 7200~36000 for each user.
; A setting of 0 means that the buffer may be filled with old cache entries, resulting in the inability to cache new entries.

Apc.gc_ttl = 3600
; sys
; The number of seconds the cache entry can exist in the garbage collection table.
; This value provides a security measure, even if a server process crashes while executing the cached source files.
; And the source file has been modified, and the memory allocated for the old version will not be reclaimed until this TTL value is reached.
; Setting to zero disables this attribute.

Apc.include_once_override = Off
; sys
; There is no documented documentation for this directive, see: http://pecl.php.net/bugs/bug.php?id=8754
; Keep off, or you may cause unexpected results.

Apc.max_file_size = 1m
; sys
; Prevents files larger than this size from being cached.

Apc.mmap_file_mask =
; sys
; If you use –enable-mmap (default enabled) to compile Mmap support for APC,
; The value here is the Mktemp-style file mask passed to the Mmap module (the recommended value is "/tmp/apc.xxxxxx").
; The mask is used to determine whether the memory-mapped area is to be file-backed or shared memory backed.
; For a direct file-backed memory mapping, set to "/tmp/apc.xxxxxx" (exactly 6 x).
; To use POSIX-style shm_open/mmap, you need to set it to "/apc.shm.xxxxxx."
; You can also set the "/dev/zero" to use the kernel's "/dev/zero" interface for anonymous mapped memory.
; Not defining this directive means enforcing the use of anonymous mappings.

Apc.num_files_hint = 1000
; sys
; The approximate number of different source files that may be included or requested on the Web server (the recommended value is 1024~4096).
; If you are unsure, set to 0; This setting is primarily used for sites that have thousands of source files.

apc.optimization = 0
; Optimization level (recommended value is 0).
; A positive integer value indicates that the optimizer is enabled, and the higher the value, the more aggressive optimization is used.
; Higher values may have very limited speed increases, but are still being tested.

Apc.report_autofilter = Off
; sys
; Whether to log all scripts that are automatically not cached due to early/late binding reasons.

Apc.shm_segments = 1
; sys
; The number of shared memory blocks allocated for the compiler buffer (the recommended value is 1).
; If the APC runs out of shared memory and the Apc.shm_size directive is set to the maximum allowed by the system,
; You can try to increase this value.

Apc.shm_size = 30
; sys
; The size of each shared memory block (in MB, the recommended value is 128~256).
; Some systems, including most BSD variants, have a very small default shared memory block size.

Apc.slam_defense = 0
; Sys (against using the directive, recommended to use the Apc.write_lock Directive)
; On a very busy server, whether you start a service or modify a file,
; can result in competitive conditions because multiple processes attempt to cache a single file at the same time.
; This directive is used to set the percentage of cache steps that the process skips when processing files that are not cached.
; For example, set to 75 means that when you encounter a file that is not cached, 75% of the probability is not cached, thereby reducing the collision probability.
; Encourage set to 0来 disable this feature.

Apc.stat = On
; sys
; Whether to enable script update checking.
; Change this instruction value to be very careful.
; The default value on means that the APC checks whether the script is updated every time the script is requested.
; If updated, the compiled content is automatically recompiled and cached. But doing so has a detrimental effect on performance.
; If set to OFF, the performance is significantly improved by not checking.
; But for the updated content to take effect, you must restart the Web server.
; This instruction is also valid for Include/require files. But it should be noted that
; If you are using a relative path, the APC must check every time it include/require to locate the file.
; Using an absolute path allows you to skip the check, so you are encouraged to use an absolute path for include/require operations.

Apc.user_entries_hint = 100
; sys
; Similar to the Num_files_hint directive, just for each individual user.
; If you are unsure, set to 0.

Apc.write_lock = On
; sys
; Whether write locks are enabled.
; On a very busy server, whether you start a service or modify a file,
; can result in competitive conditions because multiple processes attempt to cache a single file at the same time.
; Enabling this directive avoids the appearance of competitive conditions.

apc.rfc1867 = Off
; sys
; After you open the directive, for each upload file that contains the Apc_upload_progress field just before the file field,
; APC will automatically create a Upload_ user cache entry (that is, the Apc_upload_progress field value).

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.