Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of Ubuntu18.04 system installation, configuration, Redis and phpredis extension operation

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This paper gives an example to describe the installation, configuration of Redis and phpredis extension operation of Ubuntu18.04 system. Share with you for your reference, the details are as follows:

1. Installation

Installation

$sudo apt-get update$ sudo apt-get install redis-server

Start

$sudo / etc/init.d/redis-server start

Note: if unable to start

Systemctl status redis-server.serviceredis-server.service: Can't open PID file / var/run/redis/redis-server Ali CVM. Remember to add the port number of the service in the security group and security policy to allow access to all addresses, that is, all services on Ali CVM need to map ports. If you do not do this step, the above redis-cli command will be in a waiting state.

Check the log information cat / var/log/redis/redis-server.logCreating Server TCP listening socket:: 1 IPv6 is disabled on the IPv6: bind: Cannot assign requested address host, and Ubuntu's redis-server package comes with: bind 127.0.0.1:: 1 modify the bind address in the redis configuration file Note the bind address or change the bind address to 0.0.0.0vim / etc/redis/redis.confbind 127.0.0.1:: 1 start the redis service (add the configuration file or the configuration will not take effect) sudo redis-server / etc/redis/redis.conf & check the service and port systemctl status redis-servernetstat-ntpl | grep 63792. Check whether Redis is running $redis-cli

The command opens the following Redis prompt:

127.0.0.1purl 6379 >

Enter ping

127.0.0.1 purl 6379 > pingPONG

Description of successful installation

3. Configure remote login

The default redis does not allow remote login, so we need to configure it.

Edit redis profile

Sudo vi / etc/redis/redis.conf

Comment on the following line, you can search and find

# bind 127.0.0.1

Note: redis-cli-h (ip address)-p (the port number is 6379 by default) note that the parameter should be separated from the specific space.

4. Configure password login

Edit 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 1234565. Restart redissudo service redis-server restart

Or it can be forced to kill and then manually opened.

Sudo killall redis-serversudo redis-server / etc/redis/redis.conf &

You'd better add the configuration file here, or the configuration may not take effect.

6. Install redis extension for php download phpredis extension file apt install git git clone https://github.com/phpredis/phpredis.git Mobile phpredis folder mv phpredis / etc/phpredis installation (if execution fails, you need to execute sudo apt-get install php7.2-dev (you can change the dev installation according to the version of php) cd / etc/phpredisphpize execute the following three commands. / configuremakemake install modify the php.ini file vim / etc/php/7.2/apache2/php.ini

Find the following command to add to the end of the php.ini file

Extension=redis.so executes the apache2 restart command / etc/init.d/apache2 restart to see if the redis extension is installed in php

I hope what is described in this article will be helpful to the configuration of your Ubuntu environment.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report