1.建立並進入原始碼儲存目錄,下載原始碼包,解壓
mkdir -p /usr/local/src cd /usr/local/src wget -c http://download.redis.io/releases/redis-4.0.10.tar.gz tar -zxvf redis-4.0.10.tar.gz cd redis-4.0.10
2.編譯,安裝
#安裝依賴 yum -y install gcc gcc-c++ make MALLOC=libc make PREFIX=/usr/local/redis install
3.設定
#建立組態檔目錄 mkdir -p /usr/local/redis/etc/ #將原始碼目錄下的redis.conf複製到etc cp /usr/local/src/redis-4.0.10/redis.conf /usr/local/redis/etc/ #修改redis.conf vim /usr/local/redis/etc/redis.conf daemonize yes #redis以守護行程的方式執行 #設定環境變數 vim /etc/profile PATH=$PATH:/usr/local/redis/bin export PATH #立即生效 source /etc/profile
4.設定開機啟動
#將redis的啟動指令碼複製一份放到/etc/init.d目錄下 cp /usr/local/src/redis-4.0.10/utils/redis_init_script /etc/init.d/redisd #建立/etc/redis目錄,複製redis.conf mkdir -p /etc/redis cp /usr/local/redis/etc/redis.conf /etc/redis/6379.conf #進入/etc/init.d cd /etc/init.d #修改啟動指令碼 vim redisd #修改服務的位置 EXEC=/usr/local/redis/bin/redis-server #修改命令列工具的位置 CLIEXEC=/usr/local/redis/bin/redis-cli #開機啟動 chkconfig redisd on
5.啟動redisd
[[email protected] init.d]# service redisd start Starting Redis server... 118991:C 21 Dec 08:39:46.508 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 118991:C 21 Dec 08:39:46.509 # Redis version=4.0.10, bits=64, commit=00000000, modified=0, pid=118991, just started 118991:C 21 Dec 08:39:46.509 # Configuration loaded
6.安裝php-redis擴充套件
#進入原始碼儲存目錄,下載,解壓
cd /usr/local/src wget -c http://pecl.php.net/get/redis-4.2.0.tgz tar -zxvf redis-4.2.0.tgz cd redis-4.2.0
#生成configure檔案
/usr/local/php72/bin/phpize #這是我的phpize的位置
#設定,編譯,安裝
./configure --with-php-config=/usr/local/php72/bin/php-config make -j4 make install
#將redis擴充套件加入php.ini
echo "extension=redis.so" >> /usr/local/php72/etc/php.ini
#重新啟動php,檢視phpinfo();
以上就是CentOS6.9原始碼編譯安裝redis和php-redis擴充套件的詳細內容,更多請關注TW511.COM其它相關文章!