## Environment:
Python: 3.6
Django: 2.1
OS: CentOS 7 x86_64
uwsgi: 2.0.17
## installation Python3.6
* Do not remove the built-in python2.7, otherwise there will be problems, because many centos need to rely on the system comes with software Python
* install the install OpenSSL-dependent tools devel bzip2 yum devel expat-devel-gdbm-devel the readline-devel-devel MySQL SQLite devel-GCC-GCC-devel devel Python
* Download wget https://www.python.org/ftp/ Python / 3.6.5 / 3.6.5.tgz the Python-
* -zxvf the Python-3.6.5.tgz extracting the tar
Music Videos the Python-3.6.5 / usr / local directory * to move the discharge software specification
* installation:
* CD /usr/local/Python-3.6.5/
* ./configure
* the make
* the make install
* verify
* Python -V
* Source /home/cosmic/py3.6env/bin/activate enter the virtual environment
## installation uWSGI
* Installation PIP the install to uwsgi
* verification
`` `
DEF file application (the env, The start_response):
The start_response ( '200 is the OK', [( 'the Content-the Type', 'text / HTML')])
return [B" the Hello the Django "]
` ``
`` `
uwsgi --http: 8001 --wsgi-File test.py
` ``
browser to access the web page can be displayed Hello Django then there is no problem
* If the installation fails
* deactivate exit the virtual environment
* yum install -y python -devel
* the easy_install to uwsgi
## mounting the Nginx
* configuration source
vi /etc/yum.repos.d/nginx.repo added the following content
`` `
[Nginx]
name = Nginx the repo
BaseURL = HTTP: //nginx.org/packages/ Mainline / CentOS /. 7 / the x86_64 /
gpgcheck = 0
Enabled. 1 =
`` `
gpkcheck = 0 represents the source of this package is not downloaded rpm for verification;
enable. 1 = enable this represents a source.
Yum the install Nginx *
* start Nginx:
systemctl Start Nginx
* modify the default port number (the default is 80)
`` `
Vim /etc/nginx/conf.d/default.conf
Server {
the listen 8089;
the listen [::]: 8089;
...
...
}
`` `
* systemctl restart nginx restart nginx, direct access http: // ip: 8089 could see nginx welcome screen can be.
## Configuration
Configuration parameters django uwsgi start of
`` `
Vim django_uwsgi.ini
[uwsgi]
# django uwsgi access must be configured by HTTP
# uwsgi by nginx request to access must be configured to django Socket
# 9000 is the port number django
socket =: 9000
# Web project root
chdir = / Home / root / pydj / django_one
# Module specified item comes with a configuration file location wsgi
Module = django_one.wsgi
# allowed the main process
Master to true =
# Number of open processes
Processes = 3
# server exits automatic cleaning environment
Vacuum to true =
`` `
## arranged Nginx
` ``
VI /etc/nginx/conf.d/default.conf
# end of the file, add a new Server
Server {
the listen 8089;
the listen [::]: 8089;
server_name 127.0.0.1 192.168.10.114;
LOCATION / {
the include / etc / Nginx / uwsgi_params;
uwsgi_pass 127.0.0.1:9000;
}
LOCATION / index / {
the root / index /;
}
LOCATION / static {
Alias / Home / the root / pydj / django_one / Sign / static;
}
}
`` `
* 8089 is the external port number
* server_name nginx agent uwsgi external IP
* 8089 127.0.0.1:9000 i.e. when received nginx request port directly to forward the request to 127.0.0.1:9000
## uwsgi start Django
`` `
# into the project root directory
/ Home / root / pydj / django_one
# start
uwsgi --ini django_uwsgi.ini
` ``
## restart the Nginx
systemctl the restart Nginx
secrtcrt
filiza
Xshell
mounted
PIP Freeze> requirements.txt
the Django == 2.1.2
Django-== 2.8.1 of haystack
the mysqlclient == 1.3.13
the pytz == 2018.5
uWSGI == 2.0.17.1
Whoosh == 2.7. 4
Port -l the semanage | grep http_port_t
# MySQL may be a local area network to access any host
MySQL> MySQL use;
MySQL> Update User SET Host = '%' WHERE User = 'the root';
MySQL> SELECT Host, User from User;
MySQL> the flush privileges ;
* after modifying the setting file
* python manage.py collectstatic collect admin static files
* modify uwsgi.ini
* start
* uwsgi --ini django_uwsgi.ini --buffer-size 32768
* add nginx configuration file
* restart nginx
*
Centos 7 next deployment Django + uWSGI + Nginx
Copyright: bloggers without consent, is prohibited reprint. Thank you! https://blog.csdn.net/cp_123321/article/details/87373048
Guess you like
Origin blog.csdn.net/cp_123321/article/details/87373048
Recommended
Ranking