In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to install redis extension in php under linux". In daily operation, I believe many people have doubts about how to install redis extension in php under linux. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to install redis extension in php under linux". Next, please follow the editor to study!
The method of installing redis extension in php under linux: 1, download phpredis extension; 2, decompress through "tar zxvf"; 3, execute phpize;4, specify php configuration path; 5, add extension to php configuration file php.ini; 6, restart php.
This article operating environment: linux5.9.8 system, phpredis2.2.4 version, DELL G3 computer
How to install redis extension for php under linux?
Install Redis+PHP on Linux 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 (change address if invalid)
Decompress: [root@localhost redis] # tar xzf redis-4.0.8.tar.gz
Rename
[root@localhost redis] # mv redis-4.0.8 redis
Enter the directory cd redis
two。 Install redis
Installation: using 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 needs 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 to 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 it.
And then start.
[root@localhost redis] # src/redis-server. / redis/conf
At this time, our redis service segment is already running in the background.
Then start the client:
Src/redis-cli
Testing: set test changyiyi setting key value
Get: get test
This is the simple installation and configuration of redis on linux. To use more syntax about using redis, please refer to redis's official website: https://redis.io/
4.php installs the redis extension
Download the phpredis extension
Download address: https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
Execute the command:
[root@localhost local] # wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
Decompress: tar zxvf
[root@localhost local] # tar zxvf 2.2.4.tar.gz
Execute phpize
[root@localhost phpredis] # / usr/local/php5/bin/phpize this is based on 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 install
Execute the 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 to your own environment
[root@localhost phpredis] # vim / etc/php/php.ini
Add a line to it: / usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/redis.so
Then save and restart php
Ps-ef | grep php-fpm
Kill-quit process number
Start php:
/ usr/local/php5/sbin/php-fpm
Then look at the redis extension in phpinfo ():
Check that php successfully installed the redis extension for php and is able to use it.
Create a test php file, redis.php
Vim redis.php
Type:
Execute the php file.
Php redis.php
Output: Server is running: + PONG.
Success! You can start using redis happily in php.
At this point, the study on "how to install the redis extension in php under linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.