Gcc must be installed before building redis
Redis installation method one
1. Install gcc command: yum install -y gcc
#Install gcc
[[email protected] src] # yum install -y gcc
#The following message appears and the installation is successful
Installed:
gcc.x86_64 0: 4.4.7-17.el6
Dependency Installed:
cloog-ppl.x86_64 0: 0.15.7-1.2.el6 cpp.x86_64 0: 4.4.7-17.el6 mpfr.x86_64 0: 2.4.1-6.el6 ppl.x86_64 0: 0.10.2-11.el6
Complete
#View gcc way 1
[[email protected] src] # gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix = / usr --mandir = / usr / share / man --infodir = / usr / share / info ...
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
#View gcc way 2
[[email protected] src] # rpm -q gcc
gcc-4.4.7-17.el6.x86_64
2. Download URL
Redis official website address: http://www.redis.io/
redis: http://download.redis.io/releases/
3.Take the centos6.5 system and redis3.2.4 version as an example, pass the downloaded redis compressed package to the linxu system, and decompress it.
[[email protected] redis] # tar zxvf redis-3.2.4.tar.gz
4. Compile and install, execute the command make
#Excuting an order
[[email protected] redis-3.2.4] # make
#The following message appears to indicate that the installation is complete
Hint: It ‘s a good idea to run ‘make test’;)
make [1]: Leaving directory `/usr/redis/redis-3.2.4/src’
5. Start redis
[[email protected] redis-3.2.4] # src / redis-server
6. Errors during installation
(1) When the following error occurs when executing the make command, gcc is not installed, install gcc according to the above installation method
[[email protected] redis] # cd redis-3.2.4 /
[[email protected] redis-3.2.4] # make
cd src && make all
sh: ./mkreleasehdr.sh: Permission denied
make [1]: Entering directory `/usr/redis/redis-3.2.4/src’
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof * .o * .gcda * .gcno * .gcov redis.info lcov-html
(cd ../deps && make distclean)
make [2]: Entering directory `/usr/redis/redis-3.2.4/deps’
(cd hiredis && make clean)> / dev / null || true
(cd linenoise && make clean)> / dev / null || true
(cd lua && make clean)> / dev / null || true
(cd geohash-int && make clean)> / dev / null || true
(cd jemalloc && [-f Makefile] && make distclean)> / dev / null || true
(rm -f .make- *)
make [2]: Leaving directory `/usr/redis/redis-3.2.4/deps’
(rm -f .make- *)
echo STD = -std = c99 -pedantic -DREDIS_STATIC = ‘‘ >> .make-settings
echo WARN = -Wall -W >> .make-settings
echo OPT = -O2 >> .make-settings
echo MALLOC = jemalloc >> .make-settings
echo CFLAGS = >> .make-settings
echo LDFLAGS = >> .make-settings
echo REDIS_CFLAGS = >> .make-settings
echo REDIS_LDFLAGS = >> .make-settings
echo PREV_FINAL_CFLAGS = -std = c99 -pedantic -DREDIS_STATIC = '' -Wall -W -O2 -g -ggdb -I ... -I ../ deps / lua / src -DUSE_JEMALLOC -I ../ deps / jemalloc / include >> .make-settings
echo PREV_FINAL_LDFLAGS = -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua geohash-int jemalloc)
make [2]: Entering directory `/usr/redis/redis-3.2.4/deps’
(cd hiredis && make clean)> / dev / null || true
(cd linenoise && make clean)> / dev / null || true
(cd lua && make clean)> / dev / null || true
(cd geohash-int && make clean)> / dev / null || true
(cd jemalloc && [-f Makefile] && make distclean)> / dev / null || true
(rm -f .make- *)
(echo ""> .make-ldflags)
(echo ""> .make-cflags)
MAKE hiredis
cd hiredis && make static
make [3]: Entering directory `/usr/redis/redis-3.2.4/deps/hiredis’
gcc -std = c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make [3]: gcc: Command not found
make [3]: *** [net.o] Error 127
make [3]: Leaving directory `/usr/redis/redis-3.2.4/deps/hiredis‘
make [2]: *** [hiredis] Error 2
make [2]: Leaving directory `/usr/redis/redis-3.2.4/deps’
make [1]: [persist-settings] Error 2 (ignored)
CC adlist.o
/ bin / sh: cc: command not found
make [1]: *** [adlist.o] Error 127
make [1]: Leaving directory `/usr/redis/redis-3.2.4/src’
make: *** [all] Error 2
(2) If the following error occurs during execution of the maker, there is no permission to execute the command, and the authorization command must be executed in the / src directory: chmod 777 mkreleasehdr.sh
# 1. If make reports an error, there is no permission to execute the command
[[email protected] redis-3.2.4] # make
cd src && make all
sh: ./mkreleasehdr.sh: Permission denied
make [1]: Entering directory `/usr/redis/redis-3.2.4/src’
CC adlist.o
In file included from adlist.c: 34:
zmalloc.h: 50: 31: error: jemalloc / jemalloc.h: No such file or directory
zmalloc.h: 55: 2: error: #error "Newer version of jemalloc required"
make [1]: *** [adlist.o] Error 1
make [1]: Leaving directory `/usr/redis/redis-3.2.4/src’
make: *** [all] Error 2
# 2. Authorization
[[email protected] src] # chmod 777 mkreleasehdr.sh
(3) If the following error occurs during the execution of make, you must configure variables
# 1. Error message
make [1]: Entering directory `/usr/redis/redis-3.2.4/src’
CC adlist.o
In file included from adlist.c: 34:
zmalloc.h: 50: 31: error: jemalloc / jemalloc.h: No such file or directory
zmalloc.h: 55: 2: error: #error "Newer version of jemalloc required"
make [1]: *** [adlist.o] Error 1
make [1]: Leaving directory `/usr/redis/redis-3.2.4/src’
make: *** [all] Error 2
# 2. Add variables
[[email protected] src] # make MALLOC = libc
(4) Execute make MALLOC = libc command to report an error or other errors, it is recommended to delete all redis files and reinstall, or install in the following way.
Redis installation method two
1. Download redis online (default download / root file)
[[email protected] ~] # wget http://download.redis.io/releases/redis-3.2.4.tar.gz
#If the following error occurs, the Linux environment variables are not configured
#bash: command not found
2. Move to the specified folder and unzip
#Moving files
[[email protected] ~] # mv /root/redis-3.2.4.tar.gz / usr / redis
#unzip files
[[email protected] ~] # tar -xz
vf redis-3.2.4.tar.gz
3. Perform make compilation
[[email protected] redis-3.2.4] # make
#Installation is complete when the following message appears
Hint: It ‘s a good idea to run ‘make test’;)
make [1]: Leaving directory `/usr/redis/redis-3.2.4/src’
4. Start redis
#After starting, it will not run in the background, press Ctrl + C to stop
[[email protected] redis-3.2.4] # src / redis-server
# Plus & symbol runs in the background after startup
[[email protected] redis] # src / redis-server &
5. Successful startup
6. View the redis version number
Enter the redis installation directory src
#Method 1
[[email protected] -zk src] # redis-cli -v
redis-cli 3.2.4
#Method 2
[[email protected] -zk src] # redis-cli --version
redis-cli 3.2.4
#Method 3
[[email protected] -zk src] # redis-server -v
Redis server v = 3.2.4 sha = 00000000: 0 malloc = jemalloc-4.0.3 bits = 64 build = 54077ebb4b018819
Install a single Redis under Linux system