I wrote earlier about installing Windows using Redis, here is Linux. I found that I have been configuring the environment recently, and I haven’t involved any advanced technology applications yet. Having a good development environment is also important. (Because the foundation is not good, my friend gave a title of “environmental stupid batch”……)

Some basic knowledge of Linux before installation and use

1, wget command

Refer to the article: www.cnblogs.com/sx66/p/1188…

Wget is a tool for downloading files in Linux. Wget is an open source software developed under Linux by Hrvoje Niksic and later ported to various platforms including Windows. It is used on the command line. This is an essential tool for Linux users, especially network administrators, who often need to download some software or restore backup from a remote server to a local server. If we use a virtual host, we can only download this transaction from the remote server to our computer disk, and then upload it to the server using FTP tool. It’s a waste of time and energy. It can’t be helped. With Linux VPS, it can be downloaded directly to the server without having to upload. The wGET tool is small but functional. It supports breakpoint download function, FTP and HTTP download mode, supports proxy server and easy to set up. Here’s an example of how to use wGET. Linux does not have wGET itself, it needs to be installed: [root@network test]# yum install -y wget # yum install -y wget #wget -p ~/download file.name

2. Yum command

Refer to the article: www.cnblogs.com/sui77626523…

Yum (full Yellow Dog Updater, Modified) is a Shell front-end package manager in Fedora and RedHat as well as SUSE. Based on RPM package management, RPM packages can be automatically downloaded and installed from a specified server, and dependencies can be automatically handled. In addition, all dependent software packages can be installed at one time without tedious downloading and installation. Yum provides concise and easy to remember commands for finding, installing, and removing one, a group, or even all packages. The inux yum download file is stored in /var/cache/yum by default. You can also specify the directory in /etc/yum.conf.

3. Tar compression and decompression commands

GCC dependencies

5, compile,

Turn source code into machine-executable code files. Installation: The executable file can be used only after it is installed into the operating system.

Second, the installation

www.cnblogs.com/zuidongfeng…

1. Download the installation package (version 4.0.6 here)

Wget download. Redis. IO/releases/re…

2. Decompress the installation package

The tar – ZXVF redis – 4.0.6. Tar. Gz

Install GCC dependencies

yum install gcc

4. Go to the decompression directory of Redis

CD redis – 4.0.6

5. Compile and install

make MALLOC=libc

Add /usr/local/redis-4.0.6/src to /usr/local/bin CD SRC && make install -bash:redis-server: Command Not found Installation complete!

Start Redis

At first, I didn’t know how to enter and start Redis, so I wanted to directly start the service and connect to use it. /redis-server is indeed started, but once the window is closed, the service is shut down. But typing commands in this open window doesn’t work (at least not yet). Also thought that it is better not to use this way into the service directly, but think about it, if the beginning of such a service directly used, it is easy to forget the principle has been the original way to use! Desperately looking for a way to start Redis. After trying a lot of commands are invalid, the original is not the online tutorial has a problem, is his poor foundation problem! First of all, the working principle of Redis (basic) is that there is a server and a client. I just started the server before, and did not link the service on the client, which led to the failure of access. According to this idea, you need to get a client, but there is only one Linux, so put redis service in the way of maintenance process in the background, and then redis- CLI to link the service.

1. Run as a maintenance process

The redis. Conf file needs to be modified. The following problems occur when vi enters conf file for the second time:

A file with the same name already exists. Redis.conf. SWP (hidden file), follow the prompt to overwrite the old file, and then delete the file. Run ls -al to delete all files in the current directory, including hidden files: rm.redis.conf. SWP Rm -f.redis.conf. SWP: ok, now you can go to XFTP and modify the configuration file, but you can find the file in XFTP and change the daemonize no to daemonize yes /redis-server /usr/local/redis-4.0.6/redis.conf can also be started with an installation file: After the CD to the SRC, type the command redis – closed redis process server The first to use ps – aux | grep redis kill process to check the redis process using the kill command

2. Check & open ports

The default port used by redis is 6379 PS: the firewall command used by Centos7 is firewall, not iptabls. First, run CD /etc/sysconfig to check the firewall status: service Firewalld status

This just found last month bought back the Original Linux firewall has been closed ah… Start systemctl start Firewalld

Firewall -cmd–zone=public–list-ports Firewall -cmd–zone=public–list-ports Firewall-cmd –zone=public–add-port=6379/ TCP –permanent Restart firewall: firewall-cmd–reload check again, we found that 6379 was enabled

3. Client connection service

Enter command: redis-cli will connect into the server, both can use! Try typing!

set name ‘test’ get name

PHP uses Redis

Before you start using Redis in PHP, you need to make sure that you have the Redis service and PHP Redis driver installed, and that PHP works on your machine. Next let’s install the PHP Redis driver: download it from github.com/phpredis/ph…

1, PHP install redis extension

The following operations need to be done in the downloaded phpredis directory:

$$CD phpredis wget https://github.com/phpredis/phpredis/archive/3.1.4.tar.gz - 3.1.4 # $into phpredis directory / usr/local/php5 / bin/phpize # PHP installation path after $. / configure -- with PHP - config = / usr/local/php5 / bin/PHP - config $make && make installCopy the code

Add the following content to the php.ini file:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
Copy the code

Restart phP-FPM or Apache after the installation is complete. Check phpInfo to see the Redis extension.

To complete! Write a PHP connection to Redis.