This article describes how to install and configure Redis and phpredis extensions on Ubuntu 18.04. Share with you for your reference, the details are as follows: 1. InstallationInstall $ sudo apt-get update $ sudo apt-get install redis-server start up $ sudo /etc/init.d/redis-server start Note: If you cannot start systemctl status redis-server.service redis-server.service: Can't open PID file /var/run/redis/redis-server
cat /var/log/redis/redis-server.log Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
vim /etc/redis/redis.conf bind 127.0.0.1 ::1
sudo redis-server /etc/redis/redis.conf &
systemctl status redis-server netstat -ntpl | grep 6379 2. Check if Redis is running$ redis-cli This command will open the following Redis prompt: 127.0.0.1:6379> Type ping 127.0.0.1:6379> ping PONG Description Successful installation 3. Configure remote login By default, redis does not allow remote login, so we need to configure it. sudo vi /etc/redis/redis.conf Comment out the following line, you can search for it #bind 127.0.0.1 Note: redis-cli -h (ip address) -p (port number defaults to 6379) Note that the parameter should be separated from the specific command by a space. 4. Configure password loginEditing the Configuration File sudo vi /etc/redis/redis.conf Find the following line and remove the comment (you can search for requirepass) #Before modification #requirepass foobared #After modification requirepass 123456 5. Restart redissudo service redis-server restart Or you can force kill and then manually open sudo killall redis-server sudo redis-server /etc/redis/redis.conf & It is best to add the configuration file here, otherwise the configuration may not take effect. 6. Install the redis extension for PHP
apt install git git clone https://github.com/phpredis/phpredis.git
mv phpredis /etc/phpredis
cd /etc/phpredis phpize
./configure make make install
vim /etc/php/7.2/apache2/php.ini Find and add the following command at the end of the php.ini file extension=redis.so
/etc/init.d/apache2 restart
<?php phpinfo(); ?> I hope this article will help you configure your Ubuntu environment. You may also be interested in:
|
<<: Solution to forgetting the root password of MySQL 5.7 and 8.0 database
>>: Lambda expression principles and examples
Table of contents 1. Customize plan tasks 2. Sync...
I encountered a problem when modifying the defaul...
Table of contents Background Description Creating...
This article shares the specific code of JavaScri...
Preface: When using MySQL, you may encounter time...
clip-path CSS properties use clipping to create t...
<br />Yesterday I saw at W3C that the new HT...
Today, when I was building a redis environment in...
My97DatePicker is a very flexible and easy-to-use...
This article mainly records the problems and solu...
Introducing vue and vue-router <script src=&qu...
This is an article written a long time ago. Now it...
In fact many people will say “I’ve seen that table...
<br />In the previous article, I introduced ...
Optimizing large amounts of database data is a hu...