CentOS6.9 source code compilation and installation of redis and php-redis extension

藏色散人
Release: 2023-04-06 14:54:02
forward
2720 people have browsed it

This article will introduce you to the process of compiling and installing redis from source code in CentOS6.9, starting it, and compiling and installing the php-redis extension from source code

1. Create and enter the source code saving directory , download the source code package, unzip

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
Copy after login

2. Compile and install

#安装依赖
yum -y install gcc gcc-c++
make MALLOC=libc
make PREFIX=/usr/local/redis install
Copy after login

3. Configure

#创建配置文件目录
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
Copy after login

4. Set up startup

#将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
Copy after login

5. Start 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
Copy after login

6. Install php-redis extension

#Enter the source code saving directory, download and unzip

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
Copy after login

#Generate configure file

/usr/local/php72/bin/phpize     #这是我的phpize的位置
Copy after login

#Configure, compile, install

./configure --with-php-config=/usr/local/php72/bin/php-config
make -j4
make install
Copy after login

#Add the redis extension to php.ini

echo "extension=redis.so" >> /usr/local/php72/etc/php.ini
Copy after login

#Restart php and check phpinfo();

CentOS6.9 source code compilation and installation of redis and php-redis extension

The above is the detailed content of CentOS6.9 source code compilation and installation of redis and php-redis extension. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jmsite.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!