centos7下部署Django(nginx+uWSGI+Python3+Django),centos7django,部署代码后uWSGI
centos7下部署Django(nginx+uWSGI+Python3+Django),centos7django,部署代码后uWSGI
系统版本:CentOS7.0Python版本:Python3.6.3Django版本:2.0.5uWSGI版本:2.0.17部署代码后uWSGI需要重新启动,关闭系统防火墙或者开放端口
nginx版本1.4.4
1.安装需要的依赖
```shellyum 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 freetype 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-devel libmcrypt libmcrypt-devel cmake
```
安装libxml模块是为了让uwsig支持使用“-x"选项,能通过xml文件启动项目
2.编译安装python3
进入目录,依次执行以下命令:
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.安装Django和uWSGI配置启动项目xml文件
pip3 install djangopip3 install uwsgi
创建uWSGI软连接:
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi3
将你的Django项目放到你想放的路径下,并在项目里新建 django_study.xml,内容如下:
<uwsgi> <!-- 内部端口,自定义 --> <socket>127.0.0.1:8000</socket> <!-- 项目路径 --> <chdir>项目的路径</chdir> <module>django_study.wsgi</module> <!-- 进程数 --> <processes>4</processes> <!-- 日志文件 --> <daemonize>uwsgi.log</daemonize></uwsgi>
4.安装nginx和配置nginx.conf文件
安装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创建用户www和用户组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
配置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
提示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的话说明配置文件无误,启动nginx
/usr/local/nginx/sbin/nginx
5.访问项目页面
进入Django项目路径,执行以下命令:
uwsgi3 -x django_study.xml
centos7下部署Django(nginx+uWSGI+Python3+Django)
相关内容
- Python:GUI之tkinter学习笔记之messagebox、filedialog,tkinterf
- 如何用python爬取两个span之间的内容,pythonspan,Python用做
- python爬虫:使用Selenium模拟浏览器行为,pythonselenium,前几
- [Python Study Notes]批量将ppt转换为pdf,pythonnotes,脚本使用
- 用VSCode写python的正确姿势,vscodepython姿势,最近在学习
- Android+appium +python 点击坐标tap方法的封装,androidappi
- python 使用国内源安装软件,python国内,python lin
- python *和**,python,
- 随机生成双色球号码和商品管理python程序,双色球pyt
- python学习(二十八)URL编码和解码&签名规则需求
评论关闭