WordPress knowledge sharing

The process record and memory cache acceleration effect of installing memcached and object-cache.php in the lnmp1.4 environment

As we all know, the weakness of WordPress is that it frequently accesses the database, which leads to unsatisfactory website opening speed. Using the Linux server, you can add a memcached cache to cache common data in memory, and read data directly from memory when accessing in the future, which improves the access speed and reduces the consumption of php database resources, killing two birds with one stone. This article mainly introduces how to use the Install the memcached cache system Process.

Memcached is a high-performance distributed memory object caching system for dynamic Web applications to reduce database load. It reduces the number of times to read the database by caching data and objects in memory, thus providing dynamic, database driven website speed. Memcached can greatly reduce the pressure of querying the Mysql database.

1、 Installation

Enter the directory after lnmp decompression

cd /root/lnmp1.4

Execute the command (this is the lnmp built-in installation script. Other environments search for the installation method themselves)

./addons.sh install memcached


You can choose php memcache or php memcached extension according to your needs. At present, the former is used by discoz x, and php memcached is more powerful in function. We use WordPress's option 2, namely, memcached.

Enter the corresponding serial number, press Enter, and confirm Enter again to start the installation.

Knowledge points: both memcache and memcached are php caching systems. The former was developed earlier and is an older generation; The latter is developed late and has new and comprehensive functions. Wordpress chooses the latter.

The installation can be completed in about 2~3 minutes. After seeing the following prompt, the installation is completed.

uninstall
Execute command

./addons.sh uninstall memcached

2、 PHP client for Memcached

After installing Memcached, you need to use object-cache.php as the PHP client of Memcached.

In order to write this article, Lao Wei looked up a lot of information on the Internet, but after reading it, he was confused: there was no easy to use version for beginners. Because it is also the first time to install this caching system on Weieis Blog, it really took a little effort to test and sort out the data.

At first, Lao Wei thought that only Memcached could be installed. After installing it on his website, he observed for a few days and did not feel that the website speed had improved much. Later, I found that we need to upload an object-cache.php as the PHP client driver.

In the process of searching for information these days, I found that many experts had finished their sentences in a few words, but it took a lot of effort for a novice like Old Wei to achieve it. So when Lao Wei wrote his article, he always followed the principle of making it easy to understand, and did not miss any steps. Many people can't understand the online Linux tutorial because there are too many simplified steps.

Go to Wordpress background plug-in to search for memcached is your friend and install it. The plug-in will automatically generate the object-cache.php file under the wp content directory and call it as the WordPress object caching mechanism.

Note: If your server has multiple WordPress installations, be sure to check in advance that each WordPress site uses a different database prefix. If the prefix is the same, such as wp_, it will cause a conflict, because the data of each website is cached through memory, and the prefix will be confused.

Memcached is equivalent to the background cache system. The object-cache.php file is a front-end driver file, and both are indispensable.

At present, when I open the foreground and background of the website, I feel that the opening time and speed have really improved. Using Memcached cache, the effect of accelerating WordPress is quite obvious. The most obvious experience is that when using the "Add Media" function to edit articles and open the media library to refresh images, the speed of using memcached is significantly improved compared with that of useless. Before useless, images are brushed off one by one, and after using it, all images are opened.

3、 WordPress optimization

How to optimize and improve the speed of WordPress is an eternal task. To make the website load faster, the key to optimization is to find a balance point, Click me to open The online course starts to learn, comprehensively analyze the reasons and provide a corresponding set of solutions.

In addition, using the pagoda Linux panel, you can directly find Memcached in the background and install it, which is much more convenient than the command line mode of lnmp, especially for novices. If you have also set up a php environment, you can refer to this article to try. It can improve the speed of the VPS server by a large margin without using a lot of memory.

Like( four )
Article name: Process Record and Memory Cache Acceleration Effect of Installing Memcached and object-cache.php in the lnmp1.4 Environment
Article link: https://www.vpsss.net/4168.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.