After deploying the code UWSGI need to reboot, shut down the system firewall or open port
- System version: CentOS7.0
- Python version: Python3.6.3
- Django Version: 2.0.5
- Uwsgi version: 2.0.17
- Nginx version 1.4.41. Install the required dependencies ' shell
Yum install wget openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
Yum Install libxml*
Yum-y install gcc automake autoconf libtool make gcc-c++ glibc libxslt-devel libjpeg libjpeg-devel libpng libpng-devel fr Eetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses Ncurses-devel Curl Curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel OpenSSL openssl-devel pcre pcre-de Vel libmcrypt libmcrypt-devel cmake
```
The Libxml module was installed to allow UWSIG support to use the "-X" option to start the project through an XML file
2. Compile and install Python3
Go to the directory and execute the following command in turn:
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz#下载完成后,执行解压命令:tar -zxvf Python-3.6.3.tar.gzcd Python-3.6.3#将python3安装到/usr/local/python3/路径下./configure --prefix=/usr/local/python3make && make install#创建软连接ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
3. Installing the Django and Uwsgi configuration Startup Project XML file
pip3 install djangopip3 install uwsgi
To create a uwsgi soft connection:
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi3
Put your Django project under the path you want, and create a new django_study.xml in the project, with the following:
<uwsgi> <!-- 内部端口,自定义 --> <socket>127.0.0.1:8000</socket> <!-- 项目路径 --> <chdir>项目的路径</chdir> <module>django_study.wsgi</module> <!-- 进程数 --> <processes>4</processes> <!-- 日志文件 --> <daemonize>uwsgi.log</daemonize></uwsgi>
4. Installing nginx and configuration nginx.conf files
-
Install nginx
wget HTTP://NGINX.ORG/DOWNLOAD/NGINX-1.4.4.TAR.GZ/USR/LOCAL/SRCCD/ Usr/local/srctar XF nginx-1.4.4.tar.gzcd nginx-1.4.4 Create user www and user group wwwgroupadd wwwuseradd-g www www./configure--user=www --group=www--prefix=/usr/local/nginx--with-http_stub_status_module--without-http-cache--with-http_ssl_module-- With-http_gzip_static_module--with-ipv6make && make install
Configure Nginx
server {#暴露给外部访问的端口listen 80; server_name localhost;charset utf-8;location / { include uwsgi_params; #外部访问80就转发到内部8000 uwsgi_pass 127.0.0.1:8000; }}#检查配置文件是否有误/usr/local/nginx/sbin/nginx -t
Tip nginx:the Configuration file/usr/local/nginx/conf/nginx.conf syntax is OK
Nginx:configuration file/usr/local/nginx/conf/nginx.conf test is successful description of the correct configuration file, start Nginx
/usr/local/nginx/sbin/nginx
5. Visit the project pageGo to the Django project path and execute the following command:
uwsgi3 -x django_study.xml
CENTOS7 deployment of Django (Nginx+uwsgi+python3+django)