Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ WordPress blog installation Redis Cache     - PLSQL often lose resolution process automatically disconnect the connection (Database)

- Help you enhance Python programming languages 27 (Programming)

- Python MySQL database connection (Database)

- MacBook Air install Ubuntu dual system (Linux)

- Java proxy mode (Programming)

- PostgreSQL Stream Configuration (Database)

- Seven kinds of NIC binding mode Detail (Linux)

- MySQL error: ERROR 1175: You are using safe update mode solution (Database)

- ssh using scp: / directory: Permission denied (Server)

- Asynchronous JavaScript loading (Programming)

- Automate deployment of Docker-based Rails applications (Server)

- Setting up Linux machine through a proxy firewall (Linux)

- MySQL innodb_table_stats table does not exist solution (Database)

- Keepalived + HAProxy high availability load balancing (Server)

- Preliminary understanding of SELinux security management (Linux)

- Linux upgrade Glibc (Linux)

- How to Debian Linux the default Python version switch to alternative version (Linux)

- HomeKit Human Interface Guidelines (Linux)

- C ++ you can become a new scripting language (Programming)

- Oracle Client Easy Connection error ORA-12154, TNS-03505 (Database)

 
         
  WordPress blog installation Redis Cache
     
  Add Date : 2018-11-21      
         
         
         
  Redis is an open source, network support, memory-based key-value storage system, similar to memcached, high performance, support more than 100K + per second read and write frequency, some large sites such as ITeye (JavaEye) and CSDN now uses Redis .

Compared with memcached, Redis provides a persistent store, restart the server memcached need to re-create the cache, Redis dependent snapshots persist even if the server just getting started and will not cause the load increased sharply. Redis cache Wordpress more suitable for large traffic.

When your WordPress articles reach the tens of thousands of articles, with the increasing traffic pressure Wordpress server also will continue to increase, Wordpress publishing articles and background related operations will become slow, then if a single input from the hardware Wordpress to improve performance is clearly worthwhile.

The WordPress pages directly use Redis cache in the server's memory, so you avoid the PHP repeated operations, response speed memory access speed can maximize Wordpress pages, tribal actual test found page execution time can be reduced to 0.00 X seconds level than without the use Redis cache upgrade several times or even ten times or more.

Environment Description: CentOS6.6 LNMP environment
redis official website to download Source: http: //redis.io/download
[Root @ localhost src] # wget http://download.redis.io/releases/redis-3.0.2.tar.gz
[Root @ localhost src] # tar zxvf redis-3.0.2.tar.gz
[Root @ localhost redis-3.0.2] # cd redis-3.0.2
[Root @ localhost redis-3.0.2] # make

#redis installation is very simple, there are already existing Makefile file, you can directly run make command

After installation in the src directory, will generate several executable files: redis-benchmark, redis-check-aof, redis-check- dump, redis-cli, redis-sentinel, redis-server. These documents, plus a redis.conf constitutes the entire final redis available packages.

Below you can just copy the executable file and redis.conf several files to your desired place, such as / usr / local / redis / bin and / usr / local / redis / etc the following command is as follows:
[Root @ localhost src] # cd redis-3.0.2
[Root @ localhost redis-3.0.2] # mkdir -p / usr / local / redis / {bin, var, etc}
[Root @ localhost redis-3.0.2] # cd src /
[Root @ localhost src] # cp redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server / usr / local / redis / bin /
[Root @ localhost redis-3.0.2] # cp /usr/local/src/redis-3.0.2/redis.conf / usr / local / redis / etc
[Root @ localhost redis-3.0.2] # ln -s / usr / local / redis / bin / * / usr / bin /

Redis.conf modify the configuration file:
[Root @ localhost redis-3.0.2] # sed -i 's # pidfile. * $ # Pidfile /var/run/redis.pid#' /usr/local/redis/etc/redis.conf
[Root @ localhost redis-3.0.2] # sed -i 's # logfile. * $ # Logfile /usr/local/redis/var/redis.log#' /usr/local/redis/etc/redis.conf
[Root @ localhost redis-3.0.2] # sed -i 's # ^ dir. * $ # Dir / usr / local / redis / var #' /usr/local/redis/etc/redis.conf
[Root @ localhost redis-3.0.2] # sed -i 's # daemonize no # daemonize yes #' /usr/local/redis/etc/redis.conf

Note that the default parameter copy daemonize past redis.conf file is no, so redis will not run in the background, when you want to test, we need to re-open a terminal. Yes was modified to run in the background redis. Further configuration file specifies the address pid files, log files and data files, if there is a need to modify the default log information is directed to the standard output.

[Root @ localhost redis-3.0.2] # echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
[Root @ localhost redis-3.0.2] # sysctl -p

Redis-server configuration boot
[Root @ localhost src] # wget https://raw.githubusercontent.com/lj2007331/lnmp/master/init/Redis-server-init-CentOS
[Root @ localhost src] # mv Redis-server-init-CentOS /etc/init.d/redis-server
[Root @ localhost src] # chmod + x /etc/init.d/redis-server
[Root @ localhost src] # chkconfig --add redis-server
[Root @ localhost src] # chkconfig redis-server on

Start redis
[Root @ localhost src] # service redis-server start

test:
[Root @ localhost src] # / usr / local / redis / bin / redis-cli
127.0.0.1:6379> set 123 baby
OK
127.0.0.1:6379> get 123
"Baby"
127.0.0.1:6379> exit

Close redis
[Root @ localhost src] # service redis-server stop

Install redis php client
[Root @ localhost src] # wget http://pecl.php.net/get/redis-2.2.3.tgz
[Root @ localhost src] # tar zxf redis-2.2.3.tgz
[Root @ localhost src] # cd redis-2.2.3

Phpize execute commands to generate executable files configure

[Root @ localhost redis-2.2.3] # / usr / local / php-fpm / bin / phpize
[Root @ localhost redis-2.2.3] # ./configure --with-php-config = / usr / local / php-fpm / bin / php-config
[Root @ localhost redis-2.2.3] # make && make install

php.ini configuration file, add the extension
12 [root @ localhost ~] # sed -i '/; extension_dir = "ext" / a \ extension = "redis.so"' /usr/local/php-fpm/etc/php.ini
[Root @ localhost ~] # service php-fpm restart

Make wordpress support redis
You need a client development package for PHP redis can connect to the server, where we recommend predis. Join WordPress root directory, execute the following
[Root @ localhost src] # wget http://uploads.staticjw.com/ji/jim/predis.php
[Root @ localhost src] # chown php-fpm: php-fpm predis.php

Front-end cache PHP scripts added WordPress root directory, execute the following

[Root @ localhost src] # wget https://gist.githubusercontent.com/JimWestergren/3053250/raw/d9e279e31cbee4a1520f59108a4418ae396b2dde/index-with-redis.php
[Root @ localhost src] # chown php-fpm: php-fpm index-with-redis.php
[Root @ localhost src] # mv predis.php index-with-redis.php / data / www / blog

According to their own needs to modify the index-with-redis.php, modified as follows:
$ Cf = 0; // set to 1 if you are using cloudflare
$ Debug = 1; // set to 1 if you wish to see execution time and cache actions
$ Display_powered_by_redis = 0; // set to 1 if you want to display a powered by redis message with execution time, see below

If you are using cloudflare, set cf = 1;,
If you want to see on the page script execution time and cache load time, set $ debug = 1; the bottom of the browser will show this is cache:
display_powered_by_redis = 1 denotes a display powered_by information.

Replace index.php
[Root @ localhost blog] # mv index.php index.php.bak
[Root @ localhost blog] # mv index-with-redis.php index.php

Caching Issues
index-with-redis.php in Notes
    -? Appending a c = y to a url deletes the entire cache of the domain, only works when you are logged in
    -? Appending a r = y to a url deletes the cache of that url
    - Submitting a comment deletes the cache of that page
    - Refreshing (f5) a page deletes the cache of that page

The background behind the login site url add? C = y to refresh the entire site
Web pages can be added later? R = y to manually refresh
Submit comments will automatically refresh the page
Refresh (f5) page can also refresh the page
Refresh the page to see the effect of the cache, view the source code
360 browser page appears similar to the lowermost corner: this is a cache: 0.04534
F5 to refresh the page cache time vary


Precautions
1, note, Wordpress Redis caching PHP version 5.3 or more
2, Wordpress Redis cache acceleration effect is undoubtedly significant, especially access to large multi-page website blog, when you use Wordpress Redis cache acceleration disallow all other caching plugin, so as to avoid unnecessary conflicts.
     
         
         
         
  More:      
 
- How to make GRub instead of the default Ubuntu software center (Linux)
- UNIX how to restrict users by IP Telnet (Linux)
- How to implement large-scale distributed Yahoo depth study on the Hadoop cluster (Server)
- Ubuntu Live CD by updating Grub resume boot the Boot Menu (Linux)
- RabbitMQ Getting Started Tutorial (Linux)
- CentOS7 compile and install Tengine + PHP + MariaDB notes (Server)
- Linux User Management (Linux)
- Storm how to ensure that at least once semantics (Programming)
- Forwarding module with Apache reverse proxy server (Server)
- Installation and operation GAMIT software under Linux operating system (Linux)
- How to use the process on the desktop xkill end Linux (Linux)
- Ubuntu installation under Scrapy (Linux)
- Fedora10 use Git version Configuration Management (Linux)
- Use PDFBox processing PDF documents (Linux)
- To restore the last time applications running when Ubuntu user log in again (Linux)
- Turning off the interface eth0: error: Disconnect the device 'eth0' (Linux)
- Linux installation Jetty deployment under RedHat5 8 (Linux)
- 20 Advanced Java interview questions summary (Programming)
- Zookeeper cluster deployment (Server)
- Install the Red Hat Container Development Kit on OSX (Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.