前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >Django1.8 CentOS7 N

Django1.8 CentOS7 N

作者头像
py3study
发布于 2020-01-02 08:47:05
发布于 2020-01-02 08:47:05
36000
代码可运行
举报
文章被收录于专栏:python3python3
运行总次数:0
代码可运行

The deployment set for a long time, at first i met the environment problem which is my code based on Python3.4. Python2.7 and python3.4 conflict. So, i try to use virtualenv to make it success, and i have to do many works again.

Django

I used it in august 2015, later i found Flask with Gunicorn is better way to finish a small project.

Install django

This is needless to say, it is ok to use pip. Recommend a source image: https://pypi.doubanio.com/simple/

Start django

start project

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
django-admin.py startproject xxc

start app

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
python manage.py startapp xxc_student

if you want to user pymysql, you should change __init.py__ as follow:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
import pymysql

pymysql.install_as_MySQLdb()

after all, synchronous database

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
python3 manage.py syncdb

uwsgi

Install uwsgi

These were some error you may encounter:

  • uwsgi: option '--http' is ambiguous

The problems associated with the environment of python,it is recommented to use pip install uwsgi to install uwsgi

  • ImportError: No module named 'wsgi'

Wsgi configuration file with the manage.py in the same directory,there are many kinds of format wsgi configuration file,such as.wsgi and .py, you can use both of them in the same way.

Start uwsgi

start command, this command is a test way to run the Django.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
uwsgi --http-socket :8000 --chdir /opt/AnJiBei_Python_Project/anjibei/ --module django_wsgi

You can make uwsgi become a deamon with log.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
uwsgi --http-socket :8000 --chdir /opt/AnJiBei_Python_Project/anjibei/ --module django_wsgi --daemonize /opt/AnJiBei_Python_Project/anjibei/log/uwsgi.log

Also important is that django_wsgi is the configuration file which should be in the same directory with manage.py.Don't write an absolute path, otherwise, may lead to the import error.

These were some error you may encounter:

  • Static resource access failure

Run python manage.py collectstatic,and static files will be copied to the STATIC_ROOT specified static folder.

This command feels a bit strange, my static files distribution under different startapp, now, all of them... hum... be synchronized.The location of the static files were affected by the position where you execute the uwsgi command. So, you can find the static files were in the same directory with manage.py. Here is a picture of original, but... you know...

Stop uwsgi

Just we specify th 8000 port, so we can use it to find the process no.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
netstat -apn | grep 8000

Or, you can user the process name directly.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
netstat -apn | grep uwsgi

Later, use kill to stop the uwsgi deamon.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
kill -9 3532

Git pull

You have to restart the uwsgi to make you code to take effect.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/10/12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
CentOS下uWSGI+Django成功搭建记录
在 http://www.linuxidc.com/Linux/2017-03/141794.htm,我们已经实现了网页打开"good bye,logan"的效果,可见Web Client <===> uWSGI <===> Python是通畅的,现在我们要调整看看django与uwsgi是否是通畅的。
星哥玩云
2022/07/11
3200
CentOS下uWSGI+Django成功搭建记录
Django + Nginx + uWSGI 部署
英文原文请参照此文:Setting up Django and your web server with uWSGI and nginx。我只是稍微翻译并总结了一下。
Gaussic
2020/07/03
1.2K0
nginx+uWSGI+django+virtualenv+supervisor发布web服务器
大家都学过了django,用django写了各种功能,写了bbs项目,写了路飞学城。
超蛋lhy
2018/08/31
1.1K0
nginx+uWSGI+django+virtualenv+supervisor发布web服务器
ubuntu Django + Uwsgi + Nginx 的生产环境部署
使用runserver可以使我们的django项目很便捷的在本地运行起来,但这只能在局域网内访问,如果在生产环境部署django,就要多考虑一些问题了。比如静态文件处理,安全,效率等等,本篇文章总结归纳了一下基于uwsgi+Nginx下django项目生产环境的部署
py3study
2020/03/03
2.8K0
centos7 下通过nginx+uwsgi部署django应用
这里需要注意 一定是直接用nginx命令启动, 不要用systemctl启动nginx不然会有权限问题
零式的天空
2022/03/25
6480
Nginx+uWSGI部署Django网站的详细步骤,脱坑必备,值得收藏!
对于Django部署来说,选择nginx和uWSGI是一个不错的选择,此教程旨在将Django部署到生产环境的服务器中。当然你也可以使用Apache或者其他的服务器部署方式,不过笔者看来,用uWSGI还是相对简单的。 概念 Web Server是面向外界的。它可以提供文件服务,但并不能直接与Django应用通话;它需要一些东西来运行这个应用,将请求从客户端喂给它,并且返回响应。 Web Server Gateway Interface - WSGI - 就是用来做这件事的。WSGI是一种Python标准。
Python中文社区
2018/01/31
1.8K0
Location配置项及LNMP架构
首先Nginx服务是不能处理动态请求,那么当用户发起动态请求时, Nginx又是如何进行处理的。 1. 静态请求:请求的内容是静态文件就是静态请求 1)静态文件:文件上传到服务器,永远不会改变的文件就是静态文件 2)html就是一个标准的静态文件 1. 动态请求:请求的内容是动态的就是动态请求 1)不是真实存在服务器上的内容,是通过数据库或者其他服务拼凑成的数据
HammerZe
2022/03/25
6220
Location配置项及LNMP架构
Django 初始化配置
创建工程 $ django-admin startproject myblog 创建应用 分隔功能,一个功能对应一个应用 $ python3 manage.py startapp blog 在 settings.py 中添加应用 INSTALLED_APPS = [ ... 'blog', ] 启动服务 测试使用,后续使用 Nginx $ python3 manage.py runserver 模板 在应用目录下新建 Templates 文件夹存放 HTML 文件 生成数据表 $ python3 man
康怀帅
2018/02/28
1.2K0
CentOS + Python3.6+
用的系统是CentOS 6.4,其上python版本是2.6,而Django支持的版本是2.7+,又考虑到网页语言用UTF-8,而python3+默认字符已变为Unicode,所以选择python3版本,小菜理解,不知对错。
py3study
2020/01/06
1.6K0
CentOS + Python3.6+
Django部署到服务器
环境要求 Python >= 3.6 Djando >= 2.1 Nginx >= 1.2 安装 && 配置 若直接Git本源码,只需要修改数据的名称和密码即可 若非Git本源码,具体部署步骤如下,相比Nginx,Apache配置更简便,本部署基于Nginx 在工程目录下修改setting.py # Application definition INSTALLED_APPS = [ 'blog', ] # Database DATABASES = { 'default': {
嘉美伯爵
2021/01/18
1.4K0
CentOS 7+nginx+uwsgi部署Django项目
本文主要介绍服务器部署时Django需要的配置和uwsgi以及nginx的配置,不介绍Python的安装以及虚拟环境的安装创建,也不涉及Mysql数据库的安装以及配置,Python以及虚拟环境和Mysql的安装可以自行网上搜索,一般不会有坑,能顺利安装配置成功。
极简小课
2022/06/21
8080
Ubuntu上通过nginx部署Django笔记
目录[-] Django的部署可以有很多方式,采用nginx+uwsgi的方式是其中比较常见的一种方式。今天在Ubuntu上使用Nginx部署Django服务,虽然不是第一次搞这个了,但是发现还是跳进了好多坑,google了好久才搞定。想想还是把这个过程记录下来,免得下次再来踩同样的坑。 安装Nginx apt-get install nginx ubantu安装完Nginx后,文件结构大致为:   所有的配置文件都在 /etc/nginx下;   启动程序文件在 /usr/sbin/nginx下
jhao104
2018/03/20
1.5K0
linux 安装python djang
首先,我们来安装 MySQL ,这里我们使用的是 MySQL 的一个发行版 —— MariaDB 。
py3study
2020/01/10
5780
centos7.6部署django+nginx+uwsgi
首先你需要准备好一台已经安装好的centos7.6虚拟机,这个用vm很容易实现 首先约定好 $为系统用户 # 为系统管理员 *** 首先进入系统 执行 # yum update -y *** 然后安装软件管理包和可能使用到的系统依赖环境 执行 # yum -y groupinstall “Development tools” *** 接着执行 :# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-
kirin
2020/05/09
7010
通过nginx+uwsgi部署django应用在ubuntu
1.安装python3-pip -------------sudo apt-get install python3-pip 2.安装虚拟环境和虚拟环境管理包 sudo pip3 install virtualenv (报错的话需要把pip也安装一下) sudo pip3 virtualenvwrapper 在~/.bashrc 添加 export WORKON_HOME=~/Envs source /usr/local/bin/virtualenvwrapper.sh (如果没有virtualenvwrapper.sh就在这目录下创建这个文件) source .bashrc 创建虚拟环境:mkvirtualenv ShangOnline –p /usr/bin/python3 3.虚拟环境当中安装项目所依赖的包(mysqlclient会出一个问题,需要首先安装下面这个包) 我们可以通过 pip freeze > requirements.txt 将windows的虚拟环境安装包相应信息导出来移动到ubuntu pip3 install -r requirements.txt 在安装过程中mysqlclient会报错,按照下面两步走 sudo apt-get install libmysqlclient-dev pip install mysqlclient
用户2337871
2019/07/19
4940
Nginx+uwsgi部署Django应用
本文目的:在centos7.x服务器上利用nginx和uwsgi部署Django应用
Python中文社区
2018/07/26
1.5K0
centos7.4下配置django+uwsgi+nginx
centos7.4下配置django1.11+uwsgi2.0+nginx-1.5.6. 安装django 安装uwsgi 运行出现错误: You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run ‘python manage.py migrat
学到老
2018/03/16
8780
Python+Django+mysql+redis+wsgi+Nginx项目部署到服务器Centos6.5
进入/etc/profile.d/ 新建python3.sh文件,在python3.sh文件中添加export PATH="$PATH:/usr/local/python3/bin"
Autooooooo
2020/11/09
9180
Python+Django+mysql+redis+wsgi+Nginx项目部署到服务器Centos6.5
python3+django2 开发易语言网络验证(下)
第六步:网络验证服务器端项目上线部署  前提 项目名:netauth 系统:百度云服务器下的Ubuntu16.4 软件:xshell(无论如何想办法用这个跟服务器实例连上,不要用远程连接干敲,不然你会有砸电脑的冲动)    FileZille(通过这个软件,将项目的zip包传到服务器系统下)   apt install unzip unzip netauth.zip rm netauth.zip 步骤目录: 1.安装nginx 2.安装python3.6 3.安装mysql 4.配置虚拟环境 5.安装配置u
玩蛇的胖纸
2018/06/08
1.3K0
基于django的个人博客网站建立(六)
今天主要完成的是项目在腾讯云服务器上ubuntu16.04+django+mysql+uwsig+nginx的部署过程 目前可以通过此处点击访问
py3study
2020/01/15
1.3K0
相关推荐
CentOS下uWSGI+Django成功搭建记录
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验