Skip to content

Instantly share code, notes, and snippets.

@nghuuphuoc
Last active September 4, 2023 09:29
Show Gist options
  • Save nghuuphuoc/7801123 to your computer and use it in GitHub Desktop.
Save nghuuphuoc/7801123 to your computer and use it in GitHub Desktop.
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ yum --enablerepo=remi,remi-test install redis
$ sudo nano /etc/sysctl.conf
vm.overcommit_memory=1
$ sysctl vm.overcommit_memory=1
$ sysctl -w fs.file-max=100000
$ chkconfig --add redis
$ chkconfig --level 345 redis on
$ service redis start/stop/restart
// Install php-redis extension
$ yum --enablerepo=remi,remi-test install php-redis
// If it does not work, try the following steps:
$ wget https://github.com/nicolasff/phpredis/zipball/master -O phpredis.zip
$ unzip phpredis.zip
$ cd nicolasff-phpredis-*
$ phpize
$ ./configure
$ make
$ make install
Installing shared extensions: /usr/lib64/php/modules/
@JelleGe
Copy link

JelleGe commented Aug 10, 2015

What is missing by the Install of the PHP redis extension, is that you should add "extension=redis.so" to your php.ini file.

@nsssim
Copy link

nsssim commented Sep 11, 2015

I donnow how , but , it worked like magic using yu; , (the make. make install didn't work)

@v6
Copy link

v6 commented Nov 6, 2015

// , Unless you want to update all of your packages to the Remi versions the next time you do a $ sudo yum update, I recommend disabling the `/etc/yum.repos.d/remi.repo``.

sudo sed -i -e s%enabled=1%enabled=0%g /etc/yum.repos.d/remi.repo

@v6
Copy link

v6 commented Nov 8, 2015

// , Also, would anyone like some recommendations on setting up Redis Clusters on CEntOS 6 machines?

@ChrisGuest
Copy link

I am trying this on Centos 6.7 .
redis-server starts, but my install seems to have missed something.

# chkconfig --add redis
error reading information on service redis: No such file or directory

What is chkconfig not finding?

@laike9m
Copy link

laike9m commented Feb 3, 2016

@ChrisGuest I met the same problem. Reinstall using rpm solved it.

@vortexau
Copy link

vortexau commented Jun 3, 2016

If building from source, the init.d scripts are not installed by default. To install them:

[root@centos utils]# cd utils
[root@centos utils]# ./install_server.sh 
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] 
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] 
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] 
Selected default - /var/lib/redis/6379
Please select the redis executable path [] /usr/local/bin/redis-server
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

@abrawat16
Copy link

Hi,
I want to install Redis into my server, I have gone through the instruction mention here, but still I am not able to configure redis into my server. Please find below command which help you to understand what I am doing wrong ?

Thanks

COMMANDS :-
bash-4.1# service redis_6379 restart

/var/run/redis_6379.pid does not exist, process is not running
Starting Redis server...

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 55

'tcp-backlog 511'
Bad directive or wrong number of arguments


bash-4.1# redis-server

[27218] 20 Jun 01:42:13.166 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[27218] 20 Jun 01:42:13.167 * Max number of open files set to 10032
[27218] 20 Jun 01:42:13.167 # Creating Server TCP listening socket *:6379: bind: Address already in use


bash-4.1# redis-cli

127.0.0.1:6379> ping

NOTE : Here after entering "ping", redis goes stuck and doesnt display any output.

@andkirby
Copy link

andkirby commented Sep 6, 2016

The command yum --enablerepo=remi,remi-test install php-redis doesn't work for PHP 5.5.
This works:

yum -y install php55w-pecl-redis

@AirOnSkin
Copy link

An info for everyone using these guidelines to install Redis. The IUS repository has more uptodate redis packages. I would recommend using these when installing Redis on CentOS 6. The package redis32u installs the server, an init script and a standard config at /etc/redis.conf. The only thing you need to do after installing the package is activate the service with: chkconfig redis on

@biskandar
Copy link

$ sudo pecl install redis
pecl/redis requires PHP (version >= 7.0.0, version <= 7.1.0, excluded versions: 6.0.0), installed version is 5.6.27
No valid packages found
install failed

@mean-cj
Copy link

mean-cj commented Feb 24, 2017

Your phpRedis installation doesn't work with php 5.6

This work.
Install Redis 2.2.8 for PHP 5.6

Using Centos 7.0 and EasyApache 4, you can’t install Redis 2.2.8 for PHP 5.6
Easiest workaround is to use shell and following command:
pecl install channel://pecl.php.net/redis-2.2.8

Once it finishes installation, you should see the following lines:
Build process completed successfully
Installing '/opt/cpanel/ea-php56/root/usr/lib64/php/modules/redis.so'
install ok: channel://pecl.php.net/redis-2.2.8
configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini

ref: http://www.techsoar.com/install-redis-2-2-8-for-php-5-6/

Command for test phpredis is work

php -r "if (new Redis() == true){ echo \"OK \r\n\"; }"

ref: https://anton.logvinenko.name/en/blog/how-to-install-redis-and-redis-php-client.html

=============================
Thank your for your document.

@JavituRec
Copy link

thanks I have been able to install but How can I upgrade version redis?

@AliN11
Copy link

AliN11 commented Apr 13, 2017

I couldn't complete setup.

when i run this command:
$ chkconfig --add redis

I get this error:
error reading information on service redis: No such file or directory

Copy link

ghost commented Apr 18, 2017

Oh man. 46 forks. Which one to choose? Of the forks. 15 modified. 1 with 9 stars and 19 updates, with a tutorial for CentOS 7 linked by a user who was active on GitHub in the last day. Followed those instructions, which had a number of manual steps automated with comment from @vortexau on using the install utility script shipped with the release I built (redis-3.0.4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment