Compile and install Redis tutorial on Ubuntu 20.04 system.

The following is a brief tutorial on compiling and installing Redis on the Ubuntu 20.04 system:

  1. Update system packages:

    sudo apt update
    sudo apt upgrade
    
  2. Install dependencies required for compilation:

    sudo apt install build-essential tcl
    
  3. Download the Redis source code:

    wget http://download.redis.io/releases/redis-6.2.4.tar.gz
    tar xzf redis-6.2.4.tar.gz
    cd redis-6.2.4
    
  4. Compile and install Redis:

    make
    sudo make install
    
  5. Configure Redis:

    sudo mkdir /etc/redis
    sudo cp redis.conf /etc/redis
    
  6. Modify the Redis configuration file:

    sudo nano /etc/redis/redis.conf
    

    In the file, you can make some configuration changes according to your needs, such as bind address, port, etc.

  7. Create a Redis systemd service unit:

    sudo nano /etc/systemd/system/redis.service
    

    Paste the following into the file:

    [Unit]
    Description=Redis In-Memory Data Store
    After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
    ExecStop=/usr/local/bin/redis-cli shutdown
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  8. Start the Redis service:

    sudo systemctl start redis
    
  9. Verify installation:

    redis-cli ping
    

    If you get a "PONG" response, Redis is successfully installed and running.

Note that the above is a basic example of compiling and installing Redis, you may need to further configure and adjust it according to your specific needs.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/131126314