Liên Kết Thiết Bị Giá Rẻ

Chia Sẽ Kinh Nghiệm Về IT

Tìm Kiếm Với Google

Gởi Ðề Tài Mới  Gửi trả lời
Công Cụ Xếp Bài
Tuổi 24-05-2023, 08:43 AM   #1
Trả Lời: n/a
Hướng dẫn cài đặt Redis Cache on Plesk
Hướng dẫn cài đặt Redis Cache on Plesk

Bước 1: Vào plesk cài đặt Extention tên là Docker
Bước 2: SSH vào Plesk và chạy lệnh sau để cài đặt Redis có password:

docker run --name redis -d -p 6379:6379 redis redis-server --requirepass "Redis@9999"


Redis is an open source, in-memory data structure store, mainly used as cache system. We can improve the speed of websites using Redis cache server. Popular website platform like WordPress has a plugin named “Redis-object-cache” to integrate with Redis cache server. So in this example through Plesk we install Redis cache server and integrate with a WordPress website which is hosted on a Plesk server itself.
As of now Redis Server is currently not supported in Plesk panel. Which means we can’t directly install Redis server as a plugin on Plesk portal. We need to do it manually. So in this blog post we implement the Redis server using different methods. We only have to follow any of them.

Method 1. Install Redis Server as a docker container

In this method we are trying to install and run Redis server package as docker container. For that follow below steps.
  • First Login into Plesk Panel
  • Click extensions from the left side panel
  • Type docker in the search box and choose docker extension

  • Install Docker extension by clicking get it free button

  • We will see the docker extension is installing in the popup window.

  • Once the install got completed, the docker icon will be available in the plesk left side panel itself.
  • After that go the Docker extension tab and search “redis” in the docker extension catalog search box.
  • Click the run button next to the first redis docker image available from the official repository.

  • First the redis image will be downloaded locally on your server and it will be visible in the popup window

  • Once the download completed the redis docker image config option will show up automatically.
  • From that Uncheck “Automatic port mapping ” option and give the port as 6379 as external too.
  • After that click OK.

  • The redis container will start automatically and we will see the start log.

  • After that if we click the docker option from the Plesk left panel we will see the running status for the redis docker image.

This completes the installation of redis server through Plesk docker section. Now We can also confirm if the redis docker image is running in the server using netstat command. For that first log in to the Plesk server through SSH terminal as root user and issue below netstat command and look for port 6379 is listening in the server.

Copy to Clipboard


netstat -nlpa | grep 6379

Now we also have the option to create the Redis container directly from the command line. For that first uninstall the docker image from Plesk terminal by using remove button available in the docker redis image.

Confirm the removal by clicking on Yes button. This action will uninstall the redis docker image.

Once the uninstall got completed, we will see below message.

After that go back to the SSH terminal and from the ssh terminal run below docker command.

Copy to Clipboard


docker run -d -it --name redis -p 6379:6379 redis:latest

From the command itself we can see, we are installing the latest redis docker image and binding the redis port to 6379 and giving the name as redis.
After running the docker run command if we go back to the Plesk docker section, we can see the redis image is running again.

Now we can verify the installed docker image using below command. So issue this command in the ssh terminal and we can see the redis docker image is running.

Copy to Clipboard


docker ps

Also we can see the listening port for redis server is 6379 by running below netstat command in the ssh terminal.

Copy to Clipboard


netstat -nlpa | grep 6379

Now in order to make sure Redis is working, we can run command “redis-cli ping”. If you get result “PONG”, that shows Redis is working.
So lets see how it can be accomplished in case of Redis docker image. For that first issue below command in the ssh terminal.

Copy to Clipboard


docker exec -it redis sh

Now we’re attached to our redis docker container terminal and from there Let’s run below command.

Copy to Clipboard



Now we are in the redis terminal. From there run redis command “ping” and we will see the output as “pong”
Which confirms that the redis server installed in the server is working fine.
Below is the screenshot of SSH terminal after we issued few above discussed commands.

Okay, now if we don’t want to install the redis server as docker image, we have another option to install redis server as rpm package. So lets also see how this can be accomplished.

Method 2. Install Redis server using yum.

We only have to follow this method if we are not installing the Redis server using docker image as we mentioned in the first method.
So first thing is uninstall the redis docker container by clicking the “remove” button available in the Plesk docker terminal section.

Confirm the removal by clicking Yes button.

Wait some time and we will see the message as redis container removed.

Now go back our ssh terminal and first issue below command. Here we are trying to install Redis server using yum command if you have Centos Servers. For that run below commands.

Copy to Clipboard


yum install epel-release

yum install redis -y

systemctl start redis.service

systemctl enable redis

Now If you are having debian/Ubuntu server use below command. Normally it will install the Redis server.

Copy to Clipboard


apt install redis-server

Now open file /etc/redis/redis.conf and make sure “supervised” value is set to “systemd” not “no”. After that restart the redis service again by issuing below command.

Copy to Clipboard


systemctl restart redis.service

After that we can confirm the redis is running the server by issuing below netstat command again in the ssh terminal.

Copy to Clipboard


netstat -nlpa | grep 6379

Okay, this completes the install of redis server on a plesk server and now we are proceeding with the installation of Redis php extension.
Install Redis PHP extension

Without redis php extensions our websites won’t be able to communicate with out redis server installed in the server. So lets see how redis php extension can be installed in our server. For that first issue below command. Here we assume that your website is using PHP version as 7.4. If your website PHP version is different, change the binary path location of below command accordingly.

Copy to Clipboard


/opt/plesk/php/7.4/bin/pecl install redis

Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in PEAR/PackageFile/v2/Validator.php on line 1933
PHP Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in /opt/plesk/php/7.4/share/pear/PEAR/PackageFile/v2/Validator.php on line 1933
29 source files, building
running: phpize
sh: phpize: command not found
ERROR: `phpize’ failed
In my case, I got above error, So I have installed devel package using below command.

Copy to Clipboard


yum install plesk-php74-devel

 [Errno 14] HTTP Error 404 – Not Found ] 0.0 B/s | 0 B –:–:– ETA
Trying other mirror.
if you got error like above. Open file /etc/yum.conf and set “gpgcheck” value to “0” and run “yum update” command.
And we can see the Redis php extension rpm package is installing from Plesk repository. So in short we don’t need to install the Redis php extension in a Plesk server because its included by default. We only need to perform the install if its missing from the server. We can verify the extension using below command.

Copy to Clipboard


/opt/plesk/php/7.4/bin/php -m | grep redis


If its still not enabled try to issue below command

Copy to Clipboard


yum install plesk-php74-redis

Now if you still not succeeded with the yum install try the pecl install of Redis.

Copy to Clipboard


yum install plesk-php74-devel

/opt/plesk/php/7.4/bin/phpize --version

/opt/plesk/php/7.4/bin/pecl install redis

echo "" > /opt/plesk/php/7.4/etc/php.d/redis.ini

plesk bin php_handler --reread

After the successful install of redis php extension. If we go to plesk panel and click tools and settings >> then under General Settings click php settings >> click 7.4.26 FPM application handler , from there we can see the “redis” php extension is enabled in the server.

Okay, this concludes the php-redis extension install in the server. Now lets proceed with the next section.
Install Redis-object-cache in WordPress

Lets see how can integrate the installed Redis cache server using WordPress plugin named ” Redis-object-cache”. Then only the caching will work for our WordPress websites. If your website is not WordPress use corresponding code or plugins available for integration. So follow below method if you have WordPress Website.
Here I already have a website name I have also installed the wordpress application in it using Plesk Panel.
So first log in to the wp-admin area of our website. for that click on “login button” available under plesk wordpress toolkit section.

  • A new browser window will open and wp-admin area will be available.
  • From wp-admin area left panel, under plugins section click add new option
  • Now search a plugin named “Redis Object Cache”
  • The “Redis Object Cache” plugin will show up and click install now button.

  • Wait untin the plugin got successfully installed
  • After that, click activate button

  • Now we will automatically redirected to settings >> redis section.
  • From there use enable “redis object cache option

Now we will see the status message as Connected

Which means that, our word-press website is successfully connected to our redis server. This completes the install of redis cache plugin through wp-admin area.
Now in order to test whether the WordPress install is cached by WordPress, issue “redis-cli monitor” command over SSH and click any link in the wp-admin area. The result should be like below. It means we can see log entries appear and that conclude WordPress is communicating with Redis.
If you used docker redis image, first connect to the docker command line and then use the “redis-cli monitor” command.

Copy to Clipboard


# docker exec -it redis sh

# redis-cli monitor


1594726813.585189 [0] "PING"

1594726813.585552 [0] "INFO"

1594726813.587372 [0] "GET" "stringZ1k2KT1:default:is_blog_installed"

1594726813.601559 [0] "GET" "stringZ1k2KT1:options:notoptions"

1594726813.602196 [0] "GET" "stringZ1k2KT1:options:alloptions"

1594726813.603121 [0] "GET" "stringZ1k2KT1:site-options:1-notoptions"

1594726813.609017 [0] "GET" "stringZ1k2KT1:userlogins:brads_y48002f9"

1594726813.609488 [0] "GET" "stringZ1k2KT1:users:1"

1594726813.609909 [0] "GET" "stringZ1k2KT1:user_meta:1"

1594726813.619404 [0] "GET" "stringZ1k2KT1:options:can_compress_scripts"

1594726813.620616 [0] "GET" "stringZ1k2KT1:transient:doing_cron"

1594726813.623672 [0] "GET" "stringZ1k2KT1:site-transient:update_plugins"

1594726813.624146 [0] "GET" "stringZ1k2KT1:site-transient:update_themes"

1594726813.624503 [0] "GET" "stringZ1k2KT1:site-transient:update_core"

1594726813.628105 [0] "GET" "stringZ1k2KT1:posts:3"

1594726813.628549 [0] "GET" "stringZ1k2KT1:post_meta:3"

1594726813.639773 [0] "GET" "stringZ1k2KT1:terms:last_changed"

1594726813.640300 [0] "SET" "stringZ1k2KT1:terms:last_changed" "0.63991900 1594726813"

1594726813.640625 [0] "GET" "stringZ1k2KT1:terms:get_terms-3dea143495e302bc1ab70ea89d560d6f-0.63991900 1594726813"

1594726813.641713 [0] "SET" "stringZ1k2KT1:terms:1" "O:8:\"stdClass\":9:{s:7:\"term_id\";s:1:\"1\";s:4 :\"name\";s:13:\"Uncategorized\";s:4:\"slug\";s:13 :\"uncategorized\";s:10:\"term_group\";s:1:\"0\";s :16:\"term_taxonomy_id\";s:1:\"1\";s:8:\"taxonomy\ ";s:8:\"category\";s:11:\"description\";s:0:\"\";s :6:\"parent\";s:1:\"0\";s:5:\"count\";s:1:\"1\";}" "nx"

1594726813.642172 [0] "GET" "stringZ1k2KT1:term_meta:1"

1594726813.642849 [0] "SET" "stringZ1k2KT1:term_meta:1" "a:0:{}" "nx"

1594726813.643212 [0] "SET" "stringZ1k2KT1:terms:get_terms-3dea143495e302bc1ab70ea89d560d6f-0.63991900 1594726813" "a:1:{i:0;O:8:\"stdClass\":9:{s:7:\"term_id\";s:1: \"1\";s:4:\"name\";s:13:\"Uncategorized\";s:4:\"sl ug\";s:13:\"uncategorized\";s:10:\"term_group\";s: 1:\"0\";s:16:\"term_taxonomy_id\";s:1:\"1\";s:8:\" taxonomy\";s:8:\"category\";s:11:\"description\";s :0:\"\";s:6:\"parent\";s:1:\"0\";s:5:\"count\";s:1 :\"1\";}}" "ex" "86400" "nx"

1594726813.645692 [0] "ZADD" "stringZ1k2KT1:redis-cache:metrics" "1594726813" "i=9d9d985;h=553;m=12;r=97.9;b=23910;t=0.00756;c=2 1"



This concludes a normal install of Redis Cache. Let me know your thoughts in the comment box. Hope you enjoyed this blog article. We will hopefully come up with a new blog article soon.

Tham khảo:

  Trả lời ngay kèm theo trích dẫn này
Gửi trả lời

Công Cụ
Xếp Bài

Quyền Hạn Của Bạn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Hình Cảm xúc đang Mở
[IMG] đang Mở
Mã HTML đang Tắt

Bây giờ là 10:25 AM. Giờ GMT +7

Diễn đàn tin học QuantriNet |
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.