LAMP/LNMP Optimized Cache

Source: Internet
Author: User
About lamp and LNMP combination is not much mention, lamp is mainly apache+php (libphp5.so), LNMP is mainly nginx+php (fcgi php-fpm), here is the main introduction to PHP optimization, corresponding to a master configuration file for optimization, Is php.ini.

Why cache is required because PHP is an interpreted language, and each request is parsed from the beginning, compiled into a specific opcode, and then executed and discarded by the PHP engine. With the cache, you can save the opcode and reuse it the next time the page is called, which can greatly duplicate the cost of parsing. Another situation is that when there is a dynamic request to request the database, this time there may be bottlenecks, also need to cache.

Here, let's look at the problem of opcode caching. This is actually the installation of additional modules to solve this problem. We can choose PHP eaccelerator (php5.3 and below), XCache, Zend, or APC. According to the recommended choice of the previous two, more recommended XCache. Because faster, the community is more active.

For the above mentioned section of the database optimization we choose memcached here. Read the data here will first read the cache, the cache will not go to the database to find data, and stored in a cache copy. We also need to install the Pdo_mysql plugin, which is equivalent to the SQL statement PHP package.

Next installs the ImageMagick to process the image, this software needs to install Imagick PHP to use. The above will be the cache optimization needs of the plug-ins are all finished.

First of all, we need to write all the plug-ins installed in php.ini to make sure PHP is in effect.

eg.

Extension=memcache.so

Extension=pdo_mysql.so

Extension=imagick.so

Next Configure PHP eaccelerator, please search the relevant parameters of the software, then follow the requirements to write the parameters php.ini. XCache Also, write the configuration file related parameters to php.ini. But the two software can only choose one of them, and also write the conflict.

For the above software, similar to drawing or database plug-in, there is demand, no need to install. The best fit for performance optimization like XCache or eaccelerator.

The above is mainly for the PHP cache optimization.

The above describes the LAMP/LNMP optimization of the cache, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.