django+apache配置
来源:互联网 发布:淘宝卖家怎么设置折扣 编辑:程序博客网 时间:2024/05/24 22:45
1. 准备工作
l 安装apache
l 安装mod_wsgi.so
l 安装django
l 新建一个django工程
(这里就不详细介绍安装了)
2. 配置wsgi.py
import osimport sysfrom os.path import join,dirname,abspathfrom django.core.wsgi import get_wsgi_application#PROJECT_DIR = dirname(dirname(dirname(abspath(__file__))))PROJECT_DIR = dirname(dirname(abspath(__file__)))sys.path.insert(0, PROJECT_DIR)os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")application = get_wsgi_application()
3. 配置settings.py
"""Django settings for hello project.Generated by 'django-admin startproject' using Django 1.8.2.For more information on this file, seehttps://docs.djangoproject.com/en/1.8/topics/settings/For the full list of settings and their values, seehttps://docs.djangoproject.com/en/1.8/ref/settings/"""# Build paths inside the project like this: os.path.join(BASE_DIR, ...)import osimport sysBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.insert(0, os.path.join(BASE_DIR, 'app'))# Quick-start development settings - unsuitable for production# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!SECRET_KEY = 'tk#=1l+)k6qwrg3n0+qb1(j9^c^7_zgnr69g-cjw1c2j6#do_*'# SECURITY WARNING: don't run with debug turned on in production!DEBUG = TrueALLOWED_HOSTS = []# Application definitionINSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app',)MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware',)ROOT_URLCONF = 'hello.urls'# List of finder classes that know how to find static files in# various locations.STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',)STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'app'),)# List of callables that know how to import templates from various sources.TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader',)TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'app'),)WSGI_APPLICATION = 'hello.wsgi.application'# Database# https://docs.djangoproject.com/en/1.8/ref/settings/#databasesDATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }}# Internationalization# https://docs.djangoproject.com/en/1.8/topics/i18n/LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True# Static files (CSS, JavaScript, Images)# https://docs.djangoproject.com/en/1.8/howto/static-files/STATIC_ROOT = os.path.join(BASE_DIR, 'static')STATIC_URL = '/WebApi/'
4. 收集静态文件
python manage.py collectstatic
5. 配置http.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / "/home/zhubao/Code/django_code/hello/hello/wsgi.py"<Directory "/home/zhubao/Code/django_code/hello/hello"> Order Deny,Allow Allow from all</Directory>Alias /WebApi "/home/zhubao/Code/django_code/hello/static"<Directory "/home/zhubao/Code/django_code/hello/static"> Order Allow,Deny Allow from all IndexOptions FancyIndexing</Directory>
基本上算是配置结束了。
0 0
- django配置apache model_python
- django配置apache model_python
- linux+apache+django配置
- django apache mod_wsgi配置
- apache django 配置
- django+apache配置
- Windows apache django 配置指南
- python+Django+apache的配置
- Apache+modwsgi+django的配置
- Linux MySQL Apache Django配置
- ubuntu16下django+apache配置
- Django在apache中的配置
- Apache 2.4+Django 1.11配置
- Windows下Apache+mod_python+Django配置
- apache+wsgi+django配置的存档
- Linux下配置Apache+Mod_Wsgi+Django环境
- windows+apache+mod_python配置django运行环境
- Ubuntu配置Django和apache+mod_pyth
- 企鹅TV OTT
- ZOJ1221(uva567)
- 总结一下自己在Android开发中遇到的时间处理
- LeetCode 79. Word Search
- python 中__name__ = '__main__' 的作用
- django+apache配置
- 贝叶斯线性回归(Bayesian Linear Regression)
- 量化策略方法分享之数据挖掘工具——决策树算法
- react native与Android混合开发
- linux(ubuntu15)安装angle opengles开发工具
- 科锐课堂笔记:2017/3/23 共用体与枚举类型
- es及插件安装
- c# 打开外部可执行文件exe。
- Hibernate延迟加载和即时加载