Installation linux python ngix project release process

1. Install python

# 1. Python3.7 required installation dependencies
yum -Y groupinstall "Development Tools"
yum the install -Y-devel zlib bzip2-devel-devel OpenSSL the ncurses-devel SQLite the readline-devel devel-TK-gdbm-devel devel db4- the libpcap-devel an xz-devel devel-devel libffi
# python3.7 download source. 3
. 3 wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
# decompression. 4 compiled and installed python3.7
. 4 -xJvf the Python the tar-3.7.0.tar.xz
# 5.CD folder to the Python-3.7.0
. 5 Python-3.7.0 CD
#. 6, by performing configure ./ method, and specify the installation usr directory to
6 ./configure --prefix = / usr / local / python3 --enable-Shared
# 7. begin to compile and install
7 && the make the make install
# 8, configure the environment variables, create a soft link
8 ln -s / usr / local / to python3 / bin / to python3 / usr / bin / to python3
. 9 LN -s / usr / local / to python3 / bin / PIP3 / usr / bin / PIP3

# 10 Copy the files in the build directory libpython3.7m.so.1.0 to
10 cp /root/Python-3.7.0/libpython3.7m.so.1.0 /usr/lib64/libpython3.7m.so.1.0

 

 

2. Installation and create a virtual environment to install python library items needed in a virtual environment

# Install the virtual environment
11 PIP3 install virtualenv
# Create a soft link
12 ln -s / usr / local / python3 / bin / virtualenv / usr / bin / virtualenv
file # creation projects and virtual environments require clip
13 mkdir -p / data / env
14 mkdir -p / the Data / wwwroot
# into the folder
15 cd / the Data / env
# create a virtual environment
16 virtualenv - Python = / usr / bin / python3 py3_dj2
# enter the directory where the virtual environment of
17 cd / data / env / py3_dj2 / bin /
# to start the virtual environment
18 Source of an activate
# installation projects require python reported
19 PIP3 install Django
20 PIP3 install uwsgi
# create a soft link
21 ln -s / usr / local / python3 / bin / uwsgi / usr / bin / uwsgi
# exit virtual environment
22 deactivate

#cd to the root directory
23 cd ~

 

3. Install nginx

# Download nginx source
24-wget http://nginx.org/download/nginx-1.13.7.tar.gz
# decompression
25 tar -zxvf nginx-1.13.7.tar.gz
# enter nginx-1.13.7 file
cd nginx-1.13.7 26
27 ./configure
28 the make the make install &&
#nginx general default installed path is / usr / local / nginx nginx.conf backup of files in / usr / local / nginx / conf / in the first, to prevent accidents.
CD 29 / usr / local / Nginx / the conf /
30 nginx.conf nginx.conf.bak CP
# modified into the following directory configuration nginx.conf,
31 is CD / usr / local / Nginx / the conf /
the original delete all content into the following:
Events {
worker_connections 1024;
}
HTTP {
the include the mime.types;
default_type file application / OCTET-Stream;
the sendfile ON;
Server {
the listen 80;
server_name www.donghaiming.cn; # changed their domain name, the domain name is not changed to 127.0.0.1:80
charset UTF-8;
LOCATION / {
the include uwsgi_params;
uwsgi_pass 127.0.0.1:8000; # uwsgi port to and in the same configuration
uwsgi_param UWSGI_SCRIPT library.wsgi; # wsgi.py directory name where .wsgi +
uwsgi_param UWSGI_CHDIR / Data / wwwroot / Library /; path item #

}
lOCATION / static / {
Alias / Data / wwwroot / Library / static /; static resource # path
}
}
}

# Put their project into the next cd / data / wwwroot / directory
to add the project name and project .xml file in the same directory, as follows:
<xml Version = "1.0" encoding = "UTF-8"??>
< to uwsgi>
<Socket> 127.0.0.1:8000 </ Socket> <-! internal port, custom ->
<the chdir> / Data / wwwroot / Library / </ the chdir> <-! project path ->
< module> library.wsgi </ module> < -! wsgi.py directory name ->
<processes> 4 </ processes> <-! process number ->
<daemonize> uwsgi.log </ daemonize> < ! - log files ->
</ uwsgi>

 

4. Start project

# Enter the directory where the virtual environment of
34 cd / the Data / env / py3_dj2 / bin /
# to enter the virtual environment
35 Source of an activate
# enter the directory where the project is
36 cd / the Data / wwwroot / Library /
#uwsgi parsing the configuration files in the project
37 uwsgi Library.xml -x
# nginx enter the directory where the
38 cd / usr / local / nginx / sbin /
# start nginx, if you can not start too ./nginx
39 ./nginx -s reload
# test
40 curl 127.0.0.1: 80
# migration static file
41 is CD / Data / wwwroot / Library /
42 is to python3 manage.py collectstatic
# Check Procedure
43 history

 

Guess you like

Origin www.cnblogs.com/ln-xx/p/11647555.html