Python server environment setup (2) -- install related software and python related software

Source: Internet
Author: User
Tags tmp folder ssh secure shell install redis

Python server environment setup (2) -- install related software and python related software

After installing CentOS7 on the local virtual server in the previous article, our python web service, custom python service, or python script must be run on the server, you also need to install various related software on the server. Generally, to achieve automatic deployment, you also need to install nginx, svn, uwsgi, and python3.0 (the system comes with python2.7.5), supervisor, postgresql, pgbouncer, and redis (nosql cache depends on the needs of your code ).

PS: I am not a professional O & M engineer. I can only use my own research to create a single-host python web server, for the deployment of multi-server automated synchronization, server monitoring, Linux server security, and server optimization (many services are not the focus of installation, it is difficult to apply various parameters to the benefits of configuration. You are advised to contact professional O & M engineers. Once again, I would like to thank Mr. Dai for his full-hearted help. I learned a lot about server O & M before using this article. (Here we help Xiao Dai make advertisements: good character, good technical skills, low outsourcing costs, our company outsourced server maintenance to him, and the configuration of various servers is very fast, anyone who wants to learn python and automated O & M can go to his blog http://www.linuxyw.com /)

 

1. Install nginx

First, log on to the official website to download the installation package:

Http://nginx.org/en/download.html

  

Replication: http://nginx.org/download/nginx-1.10.3.tar.gz

 

Open SSH Secure Shell Client and log on to the service

  

For nginx installation, you need to install the pcre Development Kit, openssl, tools required for gcc to compile source code, zlib library, and network download tools.

You can directly enter the following command one by one for installation (if y/n/d is selected, enter y and press Enter)

Yum install-y pcre-devel

Yum install-y openssl-devel

Yum install gcc-c ++ ncurses-devel perl

Yum-y install zlib-devel

Yum install wget

 

To facilitate the management of the downloaded content, rather than messing up the files on the server, we 'd better download the files to the tmp folder or the folder you specified.

Enter cd/tmp/to enter the tmp folder.

Then input again: wget http://nginx.org/download/nginx-1.10.3.tar.gz to see nginx download soon

  

  

Then We decompress nginx-1.10.3.tar.gz.

Input command: tar-zxvf nginx-1.10.3.tar.gz

After decompression, enter the command: ll will see an additional nginx-1.10.3 folder in the folder

  

Then go to this folder to install it. If no path is specified during installation, it will be installed under/usr/local/nginx/by default.

Enter the command: cd nginx-1.10.3

Enter the nginx installation command:./configure & make install

  

After nginx is installed, check whether nginx can be started normally.

Enter the nginx Initial Startup command:/usr/local/nginx/sbin/nginx

Check whether nginx is in the process: ps-ef | grep nginx (you can see that nginx is running properly on the server)

Check the port used after nginx is started: netstat-antup | grep nginx

  

In this case, you need to disable the firewall first if you want to access it through a browser.

Run systemctl stop firewalld.

Open the browser and enter the address http: // 192.168.0.128/to view the following page. (For details about how to set up the ip address, refer to the previous article "setting up the python server environment (1) -- prepare the local server, you can also enter the ifconfig command to query)

  

 

 

Ii. Install supervisor (Python Process Manager)

The supervisor currently only supports python2, so you have to install it before upgrade to 3. Otherwise, it will be troublesome (The following is a description of how to call python2 installation after upgrade to python3)

Install python pip before installation (the program automatically installs the Program)

Enter the command: curl https://bootstrap.pypa.io/get-pip.py | python (pip is automatically downloaded and installed after you press Enter)

Check pip version: pip-V.

Install supervisor: pip install supervisor

 

3. Install postgresql

Log on to the postgresql court network and obtain the address installed with yum.

Log in to: https://yum.postgresql.org/

You can see the list of postgresql installations that can be installed using yum.

  

Click the version link you want to install, find the version address you want to install, and copy it out.

Https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

  

Install postgresql: yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

Install the postgresql service and extension package: yum install postgresql96-server postgresql96-contrib (if it is another version, you only need to modify the corresponding version numbers in the middle)

  

4. Install pgbouncer (postgresql connection pool tool)

Select the version you want to install and download the installation package: https://pgbouncer.github.io/downloads/

  

First install the dependency package: yum install-y libevent-devel

Enter the tmp Folder: cd/tmp/

Then input again: wget https://pgbouncer.github.io/downloads/files/1.7.2/pgbouncer-1.7.2.tar.gz

Unzip installation package: tar-zxvf nginx-1.10.3.tar.gz

Go to the installation package Folder: cd pgbouncer-1.7.2

Execute the installation command:./configure & make install

 

5. Install redis

Log on to the http://download.redis.io/releases/ and select the version you want to install

Enter the tmp Folder: cd/tmp/

Then input again: wget http://download.redis.io/releases/redis-3.2.8.tar.gz

Unzip installation package: tar-zxvf redis-3.2.8.tar.gz

Go to the installation package Folder: cd redis-3.2.8

Execute the installation command: make & make install

 

6. Install Python 3.5.2 (python2.7.5 can still be used)

PS: After the upgrade to python3, some software (only part of the software) may still be installed using python2, which may lead to the failure of yum installation, so it is best to install the relevant content before upgrading.

First, log on to the official website and find the corresponding download link.

Https://www.python.org/downloads/

  

Click to enter the download page

  

Will replicate: https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz

Enter cd/tmp/to enter the tmp folder.

Then enter the command to download the source file: wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz

  

Enter the command to decompress: tar-zxvf Python-3.5.2.tgz

Go to the decompressed Folder: cd Python-3.5.2

  

Install Python3.5.2:./configure & make install

After completing the installation of python3.5.2, it will exist in the system at the same time as python2.7.5. Now, you can directly operate python to access the old version (you can enter the command: python-V to view the current python version), the following configuration is required.

Enter the command to rename the python soft link: mv/usr/bin/python/usr/bin/python2.7.5

Create a new link to the newly installed python3.5.2: ln-s/usr/local/bin/python3.5/usr/bin/python

Then enter the command: python-V. The current python version is 3.5.2.

  

After the upgrade, the yum installation command cannot be used because of different python versions. Therefore, we need to modify the yum configuration.

Enter the command: vi/usr/bin/yum

After entering the vi Editor, click "keyboard I" to enter the editing mode and modify the content.

Set the #! Of the first line #! /Usr/bin/python #! /Usr/bin/python2.7.5

After the modification, press the Esc key on the keyboard to exit the editing. Then press Shift +: To enter the command mode of the vi editor. Enter the wq + enter key to save and exit, in this way, the yum command can be used again normally.

Upgrade pip to the latest version (the latest version of pip is required for installation of some Python 3 modules, so upgrade pip to the latest version)

Run pip install -- upgrade pip.

 

7. Install uwsgi

Run pip install uwsgi.

Run uwsgi -- version to query the installed version.

 

  8. Install the svn Service

Because you have upgraded to python3, an error occurs when you directly use yum for installation. Therefore, you need to perform the operation and change it back to python2.

Delete the previously created python3 link: rm/usr/bin/python

Copy the previously backed up python2.7.5 to python: cp/usr/bin/python2.7.5/usr/bin/python

Enter the installation command: yum install subversion

View the version of svn installation: svnserve -- version

 

In addition, after upgrade to python3, if you need to use pip to install some modules of python2, you can run the following command to install pip:

Pip command:/usr/bin/pip2 install xxx

PS: You must point the python link to python2. Otherwise, the python 3 command will be executed.

 

Redirect the python link to python3.5.2

Delete the copied python link: rm/usr/bin/python

Create a new link to the newly installed python3.5.2: ln-s/usr/local/bin/python3.5/usr/bin/python

 

The related software required by the python server is basically installed. (Of course, redis and postgresql are not necessary software for running the python server, which is required by my own framework, next article

 

 

Copyright:

This article is original and published by AllEmpty in the blog Park. Copyright is jointly owned by the blog Park. You are welcome to reprint this article. You must keep this statement without your consent and provide the original article link clearly on the article page,Otherwise, the right to pursue legal liability is reserved.. If you have any questions, you can use1654937@qq.comThank you very much for contacting me.

 

Publish the content of this series,MasterYesIt is to learn and make progress together with everyone. If you are interested, you can add Q group: 327360708. Let's discuss it together.

 

For more information, please refer to blog: http://www.cnblogs.com/EmptyFS/

 

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.