本篇文章將介紹在CentOS6.9中原始碼編譯安裝redis,開機啟動,和原始碼編譯安裝php-redis擴充的過程
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
[root@jmsite 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
/usr/local/php72/bin/phpize #这是我的phpize的位置
./configure --with-php-config=/usr/local/php72/bin/php-config make -j4 make install
echo "extension=redis.so" >> /usr/local/php72/etc/php.ini
以上是CentOS6.9原始碼編譯安裝redis和php-redis擴展的詳細內容。更多資訊請關注PHP中文網其他相關文章!