Install Python and Redis on Linux
Linux installation Python3
1. Download python
Enter the following command on the terminal:
cd /home
wget ```http://cdn.npm.taobao.org/dist/python/3.72./Python3.72..tgz
Copy the code
Note: This sentence is mainly used to download files from a specified URL using wget software. The format is:
Wget Space URL address. The download directory is the current directory, so you need to put the CD where you want to put the downloaded files.
2. Decompress the Python3 installation file
Enter the following command on the terminal:
tar -zxvf Python3.6. 5.tgz
Copy the code
The tar command is used to decompress the file to the folder where the file is located. On Saturn, you can unzip files as you would on Windows. You can also download Python source files and place them in the specified folder as you would on Windows.
3. Install the compilation environment required to compile the Python3 source file
yum install -y gcc
yum install -y zlib*
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
Copy the code
Here the function is very simple, to say is yum command. Although Linux can also download software from the official website of specified software as on Win, some common and common software is placed in a specific remote repository and can be installed using the yum command. Moreover, yum commands can proactively help users resolve software dependencies. So learning about YUM is a must if you want to learn Linux well. Anaconda is similar.
4. Go to the Python3 source file folder
cd Python3.6. 5/
Copy the code
5. Specify an installation directory
./configure --prefix=/usr/local/python3 --with-ssl
Copy the code
Instructions: Don’t forget the first “.
6. Compile the source file
make
Copy the code
7. Installation
make install
Copy the code
8. Establish a soft connection
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
Copy the code
Explanation: Many tutorials have a final step, but few sites will tell you why. The so-called soft connection is equivalent to shortcut in Windows. You can use a shortcut to open the software you want to use. But why put the shortcut in /usr/bin/? This is where the environment variables come in. You can of course add /usr/local/python3/bin to the environment variables without using the last soft link, if you like. But in this case /usr/bin/is already in the environment variable by default. Putting the shortcut into this folder is equivalent to adding Python3 to the environment variable indirectly, so that you can open Python directly at the terminal by typing “Python3”. Why not put the soft connection on the desktop? I think there are two reasons: first, Python3 cannot be manipulated from a terminal command line. Second, not all Linux systems are graphical interface, there may be no desktop ah, pro! The last sentence is to set up the software connection for PIP. Pip3 is a software built in to Python3. Used to install Python packages. For example, the NUMpy package to install Python3. Run the following command on the terminal:
pip3 install requests
Copy the code
If piP3 is not found
Install the PIP environment.
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py # (Note: Python3 must be used, otherwise other Python versions of PIP may be overwritten)
/usr/local/python3/bin /usr/local/python3/bin /usr/local/python3/bin
If you also want to set a soft link for PIP, use:
ln -n /usr/local/python3/bin/pip /usr/bin/pip3
Copy the code
Workon couldn’t find a solution
Bashrc if virtualenvwrapper.sh cannot be found, copy it to /usr/local/bin/
export WORKON_HOME=$HOME/.virtualenvs # where the virtual environment is created
export VIRTUALENVWRAPPER_PYTHON=/usr/local/python36/bin/python3 # specify the python interpreter path to use for the virtual
source /usr/local/bin/virtualenvwrapper.sh # automatically execute the script every time the user logs in.
Copy the code
New Workon solution
In ~ /. Bashrc in export WORKON_HOME = ~ /. Environments source/usr/local/python3 / bin/virtualenvwrapper. Sh VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3Copy the code
Install Redis on Linux
1. Basic knowledge
Redis is an open source high performance key-value database developed in C language. It ADAPTS to storage requirements in different scenarios by providing a variety of key data types. So far redis supports the following key data types: strings, Lists, sets, ordered sets and Hashs.
2. Application scenarios of Redis
Caching (data queries, short links, news content, product content, and so on). (most used) Session separation in distributed cluster architectures. A chat room’s list of online friends. Task queues. (Seckill, Snap, 12306, etc.) Website visit statistics. Data expiration processing (to the millisecond)
3. Install redis
The following describes the installation and deployment of Redis in a Linux environment, using the RedIS-3.0 stable version, because Redis has added clustering functionality since 3.0. I will also share the Redis cluster later. 1. Can through the website to download address: download. Redis. IO/releases/re… 2. Run the Linux wget command
wget http://download.redis.io/releases/redis3.0. 0.tar.gz
Copy the code
Copy redis-3.0.0.tar.gz to /usr/local
cp redis3.0. 0.rar.gz /usr/local
Copy the code
Unpack the source code
tar -zxvf redis3.0. 0.tar.gz
Copy the code
Go to the decompressed directory to compile the file
cd /usr/local/redis3.0. 0
Copy the code
Install to the specified directory, such as /usr/local/redis
make PREFIX=/usr/local/redis install
Copy the code
Conf is the redis configuration file. Redis. Copy the configuration file to the installation directory, go to the source directory, which contains the configuration file redis.conf, and copy it to the installation directory
cd /usr/local/redis
cp /usr/local/redis3.0. 0/redis.conf /usr/local/redis/bin
Copy the code
Go to the installation directory bin
cd /usr/local/redis/bin
Copy the code
Ll can see the directory structure
Redis -benchmark Redis performance test tool redis-check-aof File repair tool redis-check-rdb RDB file repair tool redis-cli redis command line client redis Redis configuration file Redis-Sentinal Redis Cluster management tool redis-server Process of the Redis serviceCopy the code
1. In front-end mode, run bin/redis-server to start the front-end mode. The disadvantage of the front-end mode is that the redis-server program ends when the SSH command window is closed
./redis-server
Copy the code
2. Start in back-end mode Modify the redis.conf configuration file and daemonize yes Start in back-end mode
vim /usr/local/redis/bin/redis.conf
Copy the code
Run the following command to start Redis:
cd /usr/local/redis
./bin/redis-server ./redis.conf
Copy the code
Connect the redis
/usr/local/redis/bin/redis-cli
Copy the code
5. Close Redis Forcibly terminating the Redis process may cause redis persistent data loss. The correct way to stop Redis is to send the SHUTDOWN command to Redis:
cd /usr/local/redis
./bin/redis-cli shutdown
Copy the code
Forcibly terminate Redis
pkill redis-server
Copy the code
Make Redis boot up
vim /etc/rc.local
Copy the code
/ / add
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis-conf
Copy the code
Install Redis on Linux
1 installation
1 installation
$ wget http://download.redis.io/releases/redis5.0. 5.tar.gz
$ tar xzf redis5.0. 5.tar.gz
$ cd redis5.0. 5
$ make
Copy the code
2 Establish a soft connection
ln -s /home/installtion_package/redis5.0. 5/src/redis-server /usr/bin/redis-server
ln -s /home/installtion_package/redis5.0. 5/src/redis-cli /usr/bin/redis-cli
Copy the code
3 The background process starts
vim /home/installtion_package/redis5.0. 5/redis.conf
# change daemonize no to yes
Copy the code
4 Specify the configuration file to run
cd /home/installtion_package/redis5.0. 5/src ./redis-server .. /redis.confCopy the code
5 connection redis
./redis-cli
Copy the code
6 Enable and disable the Redis service
redis-server # Enable service
redis-cli # stop service
ps -aux |grep redis Check whether Redis is started
firewall-cmd --zone=public --add-port=6379/tcp --permanent Open a port
Copy the code
7 If the connection fails, restart the server
ps auxf|grep redis |grep -v grep|xargs kill 9 -./redis-server .. /redis.confCopy the code
2 Password Change
1 Initialize the Redis password
vim /home/installtion_package/redis5.0. 5/redis-conf
requirepass test123 # requirePass followed by password
Copy the code
2 Set the password without restarting Redis:
Configure the requirepass password in the configuration file (the password will remain valid when Redis restarts).
redis 127.0. 01.:6379> config set requirepass test123
# query password:
redis 127.0. 01.:6379> config get requirepass
(error) ERR operation not permitted
Password verification:
redis 127.0. 01.:6379> auth test123
# OK
# query:
redis 127.0. 01.:6379> config get requirepass
1) "requirepass"
2) "test123"PS: If no password is added to the configuration file, the password becomes invalid after redis restarts.Copy the code
3 Login to Redis with password:
When logging in, enter the password redis-cli -p6379-a test123 Login before verification: redis-cli -p6379
redis 127.0. 01.:6379> auth test123 OK auth, like other redis commands, is unencrypted; Can't prevent attackers from stealing your password on the network; The goal of the authentication layer is to provide an additional layer of protection. If the firewall or system used to protect Redis from external attacks fails, external users will not be able to access Redis without password authentication.Copy the code