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 focuses on "how to use redis in PHP". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use redis in PHP.
Install redis on Mac OS
The first is installation, which will be installed under / usr/local/bin by default
The copy code is as follows:
Cd / tmp
Wget http://redis.googlecode.com/files/redis-2.6.9.tar.gz
Tar-zxf redis-2.6.9.tar.gz
Cd redis-2.6.9
Make
Sudo make install
Then download some configuration files (mainly open deamon and so on, no difference from the default configuration)
The copy code is as follows:
Wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
Sudo mv redis.conf / etc/redis.conf
Sudo / usr/local/bin/redis-server redis.conf
Speaking of which, if there is no directory permission, it cannot be established.
/ var/log/redis/redis.log
/ var/lib/redis/
Causes redis to fail to start
Ok, now that you're done, your redis is up and running.
Give it a try!
The copy code is as follows:
/ opt/redis/redis-cli
# you will see the prompt redis 127.0.0.1, which indicates that the service has been connected.
Set anythink helloworld
Get anythink
Exit
Good sees helloworld, which means everything is fine.
What if I need to stop redis or reboot?
The copy code is as follows:
Cat / opt/redis/redis.pid
# cat will get a pid, mine is 44277
Sudo kill 44277
# the startup method is the same as before.
Set to boot and run in the background
Then do the following as root:
Create a new com.redis.plist under / Library/LaunchDaemons, as follows:
The copy code is as follows:
Label
Com.redis
RunAtLoad
ProgramArguments
/ usr/local/bin/redis-server
/ etc/redis.conf
Run after
The copy code is as follows:
Sudo launchtcl load / Library/LaunchDaemons/com.redis.plist
Sudo launchtcl start com.redis
Check the situation:
The copy code is as follows:
$cat / var/run/redis.pid
If the number of pid comes out, it will run ~
Install the php-redis extension
If you need to use redis in PHP, please read on
The copy code is as follows:
Curl-O https://nodeload.github.com/nicolasff/phpredis/zip/master
Tar-zxf master
Cd phpredis-master/
Phpize
. / configure
Make
Sudo make install
# A path will be prompted at this time
# / usr/lib/php/extensions/no-debug-non-zts-20090626/
# indicates that the extension has been placed in this location
Vim / etc/php.ini
# add the following
Extension=redis.so
# restart apache
Sudo httpd-k restart
# check the installation of extensions
Php-m | grep redis
# redis indicates that the installation is successful.
If you execute phpize, you will get the following error
Cannot find autoconf. Please check your autoconf installation
And the $PHP_AUTOCONF environment variable.
Then, rerun this script.
Please download the compilation and installation of M4 autoconf separately.
The copy code is as follows:
Curl-O http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
Curl-O http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
Note that the apache and php used above are included with MacOS. If you install phpize yourself, please specify an absolute path.
Graphics management tool
In addition: redis also has a WEB-based graphical interface management tool called phpRedisAdmin. If you just start the service, there will be some Undefined index, which will be fine after a while. If you want to try it, you can install it with the following command (SourceTree is recommended by git). The management tool supports String, Hash, List, Set, Zset.
The copy code is as follows:
Git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
Cd phpRedisAdmin/
Git clone https://github.com/nrk/predis.git
At this point, I believe you have a deeper understanding of "how to use redis in PHP". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.