|
|||||||||
|
|||||||||
|
![]() ![]() |
![]() |
|
Công Cụ | Xếp Bài | ![]() |
![]() |
#1 |
Guest
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" Introduction 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.
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]() 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 1 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 1 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 1 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 1 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 1 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 1 redis-cli 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 1 yum install epel-release 2 yum install redis -y 3 systemctl start redis.service 4 systemctl enable redis Now If you are having debian/Ubuntu server use below command. Normally it will install the Redis server. Copy to Clipboard 1 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 1 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 1 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 1 /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 1 yum install plesk-php74-devel http://autoinstall.plesk.com/PHP74_1...27.x86_64.rpm: [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 1 /opt/plesk/php/7.4/bin/php -m | grep redis 2 redis If its still not enabled try to issue below command Copy to Clipboard 1 yum install plesk-php74-redis Now if you still not succeeded with the yum install try the pecl install of Redis. Copy to Clipboard 1 yum install plesk-php74-devel 2 /opt/plesk/php/7.4/bin/phpize --version 3 /opt/plesk/php/7.4/bin/pecl install redis 4 echo "extension=redis.so" > /opt/plesk/php/7.4/etc/php.d/redis.ini 5 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 training.supporthost.in. 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. ![]()
![]()
![]()
![]() 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 1 # docker exec -it redis sh 2 # redis-cli monitor 3 OK 4 1594726813.585189 [0 172.17.0.1:59832] "PING" 5 1594726813.585552 [0 172.17.0.1:59832] "INFO" 6 1594726813.587372 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:default:is_blog_installed" 7 1594726813.601559 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:options:notoptions" 8 1594726813.602196 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:options:alloptions" 9 1594726813.603121 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:site-options:1-notoptions" 10 1594726813.609017 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:userlogins:brads_y48002f9" 11 1594726813.609488 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:users:1" 12 1594726813.609909 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:user_meta:1" 13 1594726813.619404 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:options:can_compress_scripts" 14 1594726813.620616 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:transient:doing_cron" 15 1594726813.623672 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:site-transient:update_plugins" 16 1594726813.624146 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:site-transient:update_themes" 17 1594726813.624503 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:site-transient:update_core" 18 1594726813.628105 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:posts:3" 19 1594726813.628549 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:post_meta:3" 20 1594726813.639773 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:terms:last_changed" 21 1594726813.640300 [0 172.17.0.1:59832] "SET" "stringZ1k2KT1:terms:last_changed" "0.63991900 1594726813" 22 1594726813.640625 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:terms:get_terms-3dea143495e302bc1ab70ea89d560d6f-0.63991900 1594726813" 23 1594726813.641713 [0 172.17.0.1:59832] "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" 24 1594726813.642172 [0 172.17.0.1:59832] "GET" "stringZ1k2KT1:term_meta:1" 25 1594726813.642849 [0 172.17.0.1:59832] "SET" "stringZ1k2KT1:term_meta:1" "a:0:{}" "nx" 26 1594726813.643212 [0 172.17.0.1:59832] "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" 27 1594726813.645692 [0 172.17.0.1:59832] "ZADD" "stringZ1k2KT1:redis-cache:metrics" "1594726813" "i=9d9d985;h=553;m=12;r=97.9;b=23910;t=0.00756;c=2 1" 28 ^C Conclusion 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: https://supporthost.in/install-redis-on-a-plesk-server/ https://community.hetzner.com/tutori...cker-via-plesk ![]() |
![]() |
![]() |
Công Cụ | |
Xếp Bài | |
|
|