iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Django1.8 CentOS7 N
  • 194
分享到

Django1.8 CentOS7 N

2023-01-31 08:01:16 194人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

The deployment set for a long time, at first i met the environment problem which is my code based on python3.4. python2

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

django-admin.py startproject xxc

start app

python manage.py startapp xxc_student

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

import pymysql

pymysql.install_as_MySQLdb()

after all, synchronous database

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.

uwsgi --http-Socket :8000 --chdir /opt/AnJiBei_Python_Project/anjibei/ --module django_wsgi

You can make uwsgi become a deamon with log.

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.

netstat -apn | grep 8000

Or, you can user the process name directly.

netstat -apn | grep uwsgi

Later, use kill to stop the uwsgi deamon.

kill -9 3532

git pull

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

--结束END--

本文标题: Django1.8 CentOS7 N

本文链接: https://www.lsjlt.com/news/193284.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Django1.8 CentOS7 N
    The deployment set for a long time, at first i met the environment problem which is my code based on Python3.4. Python2...
    99+
    2023-01-31
  • c++中n的n次方怎么写
    在 c++ 中计算 n 的 n 次方:使用 pow() 函数,位于 头文件中。pow(base, exponent),其中 base 是要计算其幂的数,exponent 是幂次。例如,...
    99+
    2024-05-08
    c++
  • Celery ValueError: n
    最近因项目需要,在使用任务队列Celery的时候,出现如题错误,最终在github上里找到解决办法,记录一下。 运行环境环境:win10 + python3 + redis 2.10.6 + celery 4.2.1 win10上运行c...
    99+
    2023-01-30
    Celery ValueError
  • Centos7下怎么实现用户登录失败N次后锁定用户禁止登陆
    这篇文章主要介绍了Centos7下怎么实现用户登录失败N次后锁定用户禁止登陆的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Centos7下怎么实现用户登录失败N次后锁定用户禁止登陆文章都会有所收获,下面我们一起...
    99+
    2023-06-30
  • python中时间的加n和减n运算
       好多朋友都遇到过python推算时间的问题,有些把时间转换成整数做推算,这样遇到特殊的时间和日期就会出现错误,在python中时间的推算很简单,主要就是用到datetime.timedelta方法,进行时间的加n减n运算:>&...
    99+
    2023-01-31
    时间 python
  • fabric+supervisor+n
    以ubuntu为例: #!/bin/bash #初始化用户 sudo useradd -rm -s /bin/bash demo sudo adduser demo sudo sudo passwd demo sudo apt-ge...
    99+
    2023-01-31
    fabric supervisor
  • c++中int a(n)和int a[n]的区别
    非常抱歉,由于您没有提供文章标题,我无法为您生成一篇高质量的文章。请您提供文章标题,我将尽快为您生成一篇优质的文章。...
    99+
    2024-05-14
  • Python如何生成n行n列的矩阵
    要生成n行n列的矩阵,可以使用嵌套的列表推导式。下面是一个示例代码:```pythonn = 3 # 矩阵的大小,这里为3x3# ...
    99+
    2023-09-26
    python
  • c++中n的n次方怎么表示
    c++ 中有两种表示 n 的 n 次方的方法:使用 pow 函数,如 pow(5, 3) 表示 5 的 3 次方,结果为 125。使用运算符重载,如 power(5) ^ 3 表示 5 ...
    99+
    2024-05-08
    c++
  • golang 替换 r n
    Golang是一种开源编程语言,被许多程序员和企业广泛使用。在编写Golang代码时,常常需要使用字符串操作,其中一个常见的操作是替换字符串中的特定字符,例如替换和。本文将介绍如何使用Golang实现替换和的方法。Golang字符串在Gol...
    99+
    2023-05-14
  • MySQL如何查找第N高或第N低的值
    要查找第N高或第N低的值,可以使用MySQL的子查询和ORDER BY语句。 要查找第N高的值,可以使用以下查询语句: SELEC&...
    99+
    2024-03-06
    MySQL
  • 如何利用Python实现n*n螺旋矩阵
    目录实现代码:运行结果:附:python 简单实现螺旋矩阵总结3*3螺旋矩阵: 1 2 3 8 9 4 7 6  5 实现代码: def spiral(n): ma...
    99+
    2024-04-02
  • 在python中使用[[v]*n]*n遇到的坑及解决
    目录使用[[v]*n]*n遇到的坑遇到的问题通过一番研究使用[[v]*n]*m遇到的问题需求:想通过python生成m行n列的矩阵使用[[v]*n]*n遇到的坑 今天通过[[v]*n...
    99+
    2024-04-02
  • Windows Server TP3之N
    其实之前在TP2的时候,写过一篇如何去制作NanoServer,最近TP3发布出来,我们就简单看一下跟TP2的一些改进。下载TP3之后,我挂载ISO,发现NanoServer文件夹内置两个脚本了。convert-windowsp_w_pic...
    99+
    2023-01-31
    Windows Server
  • python 求n次幂
    k,b=5,2 print(pow(k,b),pow(10**10,0.1)) k,b=5,2 print(pow(k,b),pow(10**10,0.1)) 25 10.000000000000002 ...
    99+
    2023-01-31
    python
  • c++中\n的作用
    c++ 中的 \n 表示换行符,它使编译器将输出光标移动到下一行的开头,从而形成新行。其作用包括:创建新行、格式化输出、控制输出流。 C++ 中 \n 的作用 在 C++ 语言中,转义...
    99+
    2024-05-06
    c++ 格式化输出
  • 如何发送 N 个获取请求,其中 N > 10 个 URL
    今天编程网给大家带来了《如何发送 N 个获取请求,其中 N > 10 个 URL》,其中涉及到的知识点包括等等,无论你是小白还是老手,都适合看一看哦~有好的建议也欢迎大家在评论留言,若是看完有所收获...
    99+
    2024-04-04
  • python3报错No module n
    问题:在python使用过程中,发现报错No module named _ssl,但是系统已经安装opensll,于是开始了解决问题之旅原因:python3支持openssl版本最低为1.0.2,而系统比较老,自带的openssl版本为1....
    99+
    2023-01-31
    报错 module
  • c++中\n是什么
    c++ 中,\n 是换行符,将输出位置移动到下一行。用途:1. 在字符串中创建换行,将文本移到下一行。2. 用于输出、文件操作和字符串操作。与 endl 相比,endl 不仅换行,还刷新...
    99+
    2024-05-06
    c++
  • python错误:No module n
    MySQL-python是Python访问MySQL数据库的第三方模块库;在安装过程中出现如下错误:[root@localhost MySQL-python-1.2.5]# python setup.py installTraceback ...
    99+
    2023-01-31
    错误 python module
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作