如今項目中運用到緩存愈來愈多了,筆者也常常用 yum 命令安裝,可是今天在 AWS 下安裝,yum下沒有包。最終採用編譯安裝,一下將此次安裝過程。php
1、安裝redisredis
先查找 yum 包:緩存
yum list |grep redis
這邊是沒有找到包,因而乎開始了下面的編譯安裝過程。bash
這個能夠從 redis官網 下載,app
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
解壓並進入目錄:.net
tar xzf redis-4.0.11.tar.gz cd xzf redis-4.0.11
安裝:插件
make
這邊會涉及一個redis 的服務端模式,客戶端模式:code
#服務端 redis-server #客戶端 redis-cli
咱們是須要redis 在後臺運行的,因此這邊須要配置文件,將redis.conf修改:orm
daemonize no 改成: daemonize yes
後臺啓動redis服務:server
redis-server redis.conf
第2、安裝插件 (能夠參照文檔)
在 PHP PECL 查找插件 ,找個穩定的版本,而後下載解壓:
wget http://pecl.php.net/get/redis-4.1.1.tgz tar xzf redis-4.1.1.tgz
這邊兩個名字很像啊,能夠重命名爲:
cp redis-4.1.1 redis-php-4.1.1 rm redis-4.1.1 cd redis-php-4.1.1
phpize
$ /usr/bin/phpize 或者 phpize $ ./configure $ make $ make install /bin/sh /home/ec2-user/redis-4.1.1/libtool --mode=install cp ./redis.la /home/ec2-user/redis-4.1.1/modules libtool: install: cp ./.libs/redis.so /home/ec2-user/redis-4.1.1/modules/redis.so libtool: install: cp ./.libs/redis.lai /home/ec2-user/redis-4.1.1/modules/redis.la libtool: finish: PATH="/sbin:/bin:/usr/sbin:/usr/bin:/sbin" ldconfig -n /home/ec2-user/redis-4.1.1/modules ---------------------------------------------------------------------- Libraries have been installed in: /home/ec2-user/redis-4.1.1/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Installing shared extensions: /usr/lib64/php/modules/
從上面能夠看出,已經生成的redis.so,最後在php.ini添加
extension=redis.so
經過 phpinfo 探針看出,安裝成功。
大功告成!