centos7.2 PIP3 + python3.5 + Django + nginx + Uwsgi

Source: Internet
Author: User
Tags virtual environment virtualenv install redis

Centos7.2 installing Python 3.5 and PIP installation

NOTICE: 1. CentOS comes with python2.7

2. This tutorial is suitable for most Linux systems, this article takes centos7.2 as an example

Installing Python 3.51.centos7.2 Install Python's dependency package

Yum Groupinstall "Development tools"
Yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel Libpcap-devel Xz-devel

2, download the Python3.5 source package and compile

wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
Tar XF python-3.5.0.tgz
CD Python-3.5.0
Make install

# Create Python3 Soft Links

3. You need to configure the library before running Python:

Echo/usr/local/lib >>/etc/ld.so.conf.d/local.conf

4. Operation:

Python 3.5.0

Python 3.5.0 installed successfully!

How to install Easy_install, pip 1.CentOS Install Easy_install method:

Wget-q http://peak.telecommunity.com/dist/ez_setup.py
Python ez_setup.py

2., CentOS install Python package Management Installation Tool Pip method is as follows:

wget--no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz

Tar zvxf 1.5.5

CD pip-1.5.5/

Python3 setup.py Install

OK, so it's ready to install PIP.

Building a virtual Environment 1. Install the virtual environment

sudo pip install virtualenv

  1. Installing the Virtual Environment Expansion pack

    Pip Install Virtualenvwrapper

  2. sudo modifies the home directory under configuration files. BASHRC:

    CD # Home Directory

    VI. BASHRC #打开文件, add the following:

    Export Workon_home= $HOME/.virtualenvs


  3. Use the source. BASHRC command to make the configuration file effective.

    source. BASHRC

  4. To create a PYTHON3 virtual environment:

    Mkvirtualenv-p Python3 Py_django

  5. Enter the virtual environment you created, install the corresponding project all the packages that need to be installed

    Workon Py_django

    Pip install ...

    Install Redis, MySQL data set library, and start (use to Redis in this project)

    Install UWSGI1, enter virtual environment installation UWSGI

    Pip Install Uwsgi

    2. Configure Uwsgi, create the Uwsgi.ini file under the project directory, configured as follows:





    # http=



    #项目中wsgi the directory of the. py file, relative to the project directory







    # Virtual Environment Address


  6. 启动uwsgi

    Uwsgi--ini Uwsgi.ini

    FTP Upload Code

    Place the code under the SRV file in the root directory and not in the root directory

    Install Nginx execute the following command to install


    wget http://nginx.org/download/nginx-1.5.6.tar.gz Tar XF nginx-1.5.6.tar.gz

    CD nginx-1.5.6


    Make && make install

    Now the User/local directory has a more Nginx file

    Modifying the nginx.conf configuration

    VI usr/local/nginx/conf/nginx.conf

    Start Nginx


    Access public IP with a browser

    You can display the HTML file of the Web page.

    Static file display

    Create the following directory on the server.

    sudo mkdir-vp/var/www/dailyfresh/static/

    Modify directory permissions.

    sudo chmod 777 /var/www/dailyfresh/static/


    python manage.py collectstatic

    Stop and then start the Nginx service.

    Personal CentOS deployment, some different, please friends to modify their own

centos7.2 PIP3 + python3.5 + Django + nginx + Uwsgi

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.