Install PHPAPC and use an instance in yum in linux

Source: Internet
Author: User
Tags apc
Today, I want to implement the upload progress of a large file. later I said on the Internet that phpapc can be implemented. later I learned about phpapc. PHPAPC provides two caching functions: cache Opcode (target file ), we call it apc_compi... today, I want to implement the upload progress of a large file. later I said on the Internet that php apc can be implemented. later I learned about php apc information, and PHP APC provides two caching functions, that is, cache Opcode (target file), which is called apc_compiler_cache. It also provides some interfaces for PHP developers to store user data in the memory, which is called apc_user_cache, I want to use the APC cache in the end how the effect, but in windows can not find the corresponding version of the php-apc.dll extension file, had to install in linux, do not use the source code installation, direct yum on the line.

First, install the apc dependency package. the code is as follows:

Yum install php-pear php-devel httpd-devel pcre-devel gcc make

Use pecl to install apc. the code is as follows: pecl install apc

Add the apc extension to the configuration file. the code is as follows:

Echo "extension = apc. so">/etc/php. d/apc. ini

Remember to restart the server. the code is as follows:

Service httpd restart

The phpinfo () function of PHP can be used to detect the issue.

APC cache function instance:In APC, we can also enjoy the features of APC that cache the upload progress of large files. set apc in ini. rfc1867 is set to 1, and a hidden domain APC_UPLOAD_PROGRESS is added to the form. The value of this field can generate a random hash to ensure uniqueness.

APC has many settings, which you can set in php. ini. the code is as follows:

[APC] apc.enabled = 1 apc.shm_segments = 1 apc.shm_size = 64 apc.max_file_size = 10M apc.stat=1

I tried the common APC functions in PHP. the code is as follows:

 

In addition, a useful APC cache class is provided. the code is as follows:

  Set_cache ('key', 'Test by www.phprm.com '); print_r ($ apc-> get_cache ('key '));

Summary:

1. use the Spinlocks lock mechanism to achieve optimal performance.

2. APC provides apc. php for monitoring and managing the APC cache. Do not forget to change the administrator name and password

3. by default, APC creates shared memory through mmap anonymous ing, and cache objects are stored in this "large" memory space. APC manages the shared memory

4. we need to adjust the values of apc. shm_size, apc. num_files_hints, and apc. user_entries_hint through statistics. Until the best

5. well, I admit that apc. stat = 0 can achieve better performance. Everything I want to do is acceptable.

6. PHP pre-defined constants. you can use the apc_define_constants () function. However, according to APC developers, the performance of pecl hidef is better, and define is inefficient.

7. the apc_store () function. for PHP variables such as system settings, the life cycle is the whole application (from the httpd daemon process to the httpd daemon). APC is better than Memcached. It must not pass through the network transmission protocol tcp.

8. APC is not suitable for caching user data that frequently changes through the apc_store () function, and some strange phenomena may occur.

Permanent link:

Reprint at will! Include the article address.

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.