ubuntu 配置 django
安装
- 安装Apache
sudo apt-get install apache2
安装Django
下载Django安装mod_wsgi
sudo apt-get install libapache2-mod-wsgi
配置
- 在/var/www/html下创建一个项目:
django-admin startproject testproject
- 在项目目录中创建apache目录,并创建django.wsgi文件
sudo mkdir apache
cd apache
sudo vim django.wsgi
- django.wsgi代码如下:
import os
import sys
path = '/var/www/html/testproject'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
- 在/etc/apache2/apache2.conf文件末尾加载wsgi模块
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
- 创建一个新的站点
sudo vim /etc/apache2/sites-available/testproject.conf
testproject.conf:
<VirtualHost *:80>
ServerName testproject.com
DocumentRoot /var/www/html/testproject
<Directory /var/www/html/testproject>
Order allow,deny
Allow from all
# 在新版Apache本中要改成 Require all granted
</Directory>
WSGIScriptAlias / /var/www/html/testproject/apache/django.wsgi
</VirtualHost>
- 在/etc/hosts中添加域名
127.0.0.1 testproject.com
后面的网址也可以是IP ,一个IP多个网站时,每个网站就用不同的域名
- 激活站点,重启apache
a2ensite testproject
sudo service apache2 reload
有时碰到apache2.service is not active, cannot reload.
则参考https://stackoverflow.com/questions/37464915/why-i-cant-reload-apache2-on-ubuntu
apachectl stop
/etc/init.d/apache2 start
/etc/init.d/apache2 reload
ubuntu 配置 django的更多相关文章
- Ubuntu配置Django+ Apache2+ mysql
# 我的Ubuntu上自带的python3.5,所以安装一下 python3.6sudo add-apt-repository ppa:jonathonf/python-3.6sudo apt-get ...
- ubuntu配置django
安装 安装Apache sudo apt-get install apache2 安装Django 下载Django 安装mod_wsgi sudo apt-get install libapache ...
- windows 访问 ubuntu虚拟机 django服务器 失败
配置ubuntu配置成桥接,在ubuntu虚拟机中运行django.py开发服务器.windows访问django失败. 虚拟机运行: python manage.py runserver 0.0.0 ...
- Python 关于在ubuntu部署Django项目
Django的部署可以有很多方式,采用nginx+uwsgi的方式是其中比较常见的一种方式. 在这种方式中,我们的通常做法是,将nginx作为服务器最前端,它将接收WEB的所有请求,统一管理请求.ng ...
- ubuntu部署django详细教程
教程使用的软件版本:Ubuntu 18.04.1 LTS,django2.0,Python 3.6.5.nginx-1.13.7.uWSGI (2.0.17.1),Ubuntu是纯净的,全新的.下面我 ...
- centos7 apache httpd安装和配置django项目
一.安装httpd服务 apache在centos7中是Apache HTTP server.如下对httpd的解释就是Apache HTTP Server.所以想安装apache其实是要安装http ...
- ubuntu配置NFS
ubuntu配置NFS: sudo apt-get install nfs-kernel-server 配置/etc/exports 例如:我们要将根目录下的 /opt/FriendlyARM/min ...
- ubuntu配置tftp服务
ubuntu配置TFTP服务: TFTP是用来下载远程文件的最简单的网络协议,基于UDP协议.xinetd是新一代的网络守护进程服务程序,经常用于管理多种轻量型internet服务. sudo apt ...
- 关于ubuntu配置静态IP 无法正常上网的解决方案
在ubuntu中配置静态IP后无法正常上网. 解决: 1.在终端执行 vim /etc/network/interfaces 在文件中加入如下内容,网关要写上,我开始一直无法上网就是因为没有配置网关 ...
随机推荐
- Python虚拟机函数机制之闭包和装饰器(七)
函数中局部变量的访问 在完成了对函数参数的剖析后,我们再来看看,在Python中,函数的局部变量时如何实现的.前面提到过,函数参数也是一种局部变量.所以,其实局部变量的实现机制与函数参数的实现机制是完 ...
- 洛谷P1085不高兴的津津
- 国内外移动端web适配屏幕方案总结
基础知识点 设备像素:设备像素又称物理像素(physical pixel),设备能控制显示的最小单位,我们可以把这些像素看作成显示器上一个个的点. iPhone5的物理像素是640X1136. PS: ...
- 顺序表ans链性表
#include<stdio.h>#include<malloc.h>#include<string.h>typedef int ElemType;typedef ...
- mycat 优化
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u014180504/article/details/76595247show @@datanode; ...
- 只用css3实现菜单的toggle效果
一.原理: 使用label与input来实现,label和复选框是有关联的,label的for属性对应的是input的id,所以点击label时,它就会勾选或取消复选框. 如果我们需要让菜单默认显示, ...
- 用meta标签让网页用360打开时默认为极速模式
最近做项目,用360浏览器访问自己的本地网页,发现都是默认在兼容模式下打开,做的淡入淡出轮播效果在兼容模式下看时,感觉切换很生硬.百度,发现360官网帮助里有说明用meta标签控制浏览器内核,网址为h ...
- NOI2016 区间 【线段树】
题目 在数轴上有 n个闭区间 [l1,r1],[l2,r2],...,[ln,rn].现在要从中选出 m 个区间,使得这 m个区间共同包含至少一个位置.换句话说,就是使得存在一个 x,使得对于每一个被 ...
- BZOJ2324 [ZJOI2011]营救皮卡丘 【费用流】
题目 皮卡丘被火箭队用邪恶的计谋抢走了!这三个坏家伙还给小智留下了赤果果的挑衅!为了皮卡丘,也为了正义,小智和他的朋友们义不容辞的踏上了营救皮卡丘的道路. 火箭队一共有N个据点,据点之间存在M条双向道 ...
- 学习 WebService 第二步:知识准备——SOAP vs REST(wsdl和wadl区别)(转)
原文地址:蓝精灵——默默争上游 笔记: SOAP和REST是两种实现WebService的主要方案(Web API部署REST貌似占了大半壁江山) REST Web Services 基于 HTTP ...