How to install the redis extension in php under Linux: 1. Download the phpredis extension; 2. Unzip it through "tar zxvf"; 3. Execute phpize; 4. Specify the php configuration path; 5. Add the extension to the php configuration file php.ini; 6. Restart php.
The operating environment of this article: linux5.9.8 system, phpredis2.2.4 version, DELL G3 computer
How to install redis in php under linux Extension?
Install Redis on Linux PHP Install Redis extension
1. Download
Download address: wget http://download. redis.io/releases/redis-4.0.8.tar.gz
[root@localhostredis]#wget http://download.redis.io/releases/redis-4.0.8.tar.gz ( If the address is invalid, please change it)
Extract: [root@localhost redis]# tar xzf redis-4.0.8.tar.gz
Rename
[root@localhost redis]# mv redis-4.0.8 redis
Enter Directory cd redis
2. Install redis
Installation: Use the make command
[root@localhost redis]# sudo make && sudo make install
Wait for the installation to complete.
3. Configuration
Run: [root@localhost redis]# src/redis-server You need to execute the command in the redis installation directory.
This does not run redis in the background, so when the command line interface is closed, the link will be lost, so for convenience, we need to configure it as Run in the background
Edit the configuration file: vim redis.conf redis.conf is in the current directory. Change daemonize=no to daemonize=yes and save.
Then start
[root@localhost redis]# src/redis-server ./redis/conf
At this time our The redis service segment is already running in the background.
Then start the client:
src/redis-cli
## Test: set test changyiyi Set key valueGet: get testThe above is the simple installation configuration of redis on Linux. For more syntax about using redis, please refer to the redis official website: https://redis.io/ 4.php Install redis extensionDownload phpredis extensionDownload address: https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gzExecution command: [root@localhost local] # wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz Unzip: tar zxvf[root @localhost local]# tar zxvf 2.2.4.tar.gz Execute phpize [root@localhost phpredis]# /usr/local/php5 /bin/phpize This is entered according to your actual path Specify the php configuration path: [root@localhost phpredis] # ./configure --with-php-config=/usr/local/php5/bin/php-config Compile and install: sudo make && sudo make installExecute command: [root@localhost phpredis]# sudo make && make install Add the extension to the php configuration file php.ini. The path to php.ini is The path of your own environment [root@localhost phpredis]# vim /etc/php/php.ini Add a line in it: /usr/local/php5/lib/php/extensions /no-debug-non-zts-20090626/redis.so Then save and restart phpps -ef | grep php-fpmKill -quit process numberStart php:/usr/local/php5/sbin/php-fpmThen check redis in phpinfo() Extension: #Check whether php has successfully installed the php redis extension and can use it.Create a test php file redis.php
vim redis.php
Type the content:
eaac23ebc097b045b65af565a1366092
?>
Execute the php file.
php redis.php
Output: Server is running: PONG.....
Success! You can start using redis happily in php.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install redis extension in php under linux. For more information, please follow other related articles on the PHP Chinese website!