热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

用WSGI和apache设置django-SetupdjangowithWSGIandapache

Ihavebeensoldonmod_wsgiandapacheratherthanmod_python.Ihaveallthepartsinstalled(djan

I have been sold on mod_wsgi and apache rather than mod_python. I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying.

我已经在mod_wsgi和apache而不是mod_python上出售了。我安装了所有部件(django,apache,mod_wsgi)但是遇到了部署问题。

I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3

我在osx 10.5上使用apache 2.2和django 1.0b2,mod_wsgi-2.3

My application is called tred.

我的应用程序叫做tred。

Here are the relevant files: httpd-vhosts (included in httpd-conf)

以下是相关文件:httpd-vhosts(包含在httpd-conf中)

NameVirtualHost tred:80



  ServerName tred

  Alias /admin_media /usr/lib/python2.5/site-packages/django/contrib/admin/media

  
    Order allow,deny
    Allow from all
  

  Alias /media /Users/dmg/Sites/tred/media

  
    Order allow,deny
    Allow from all
  

  Alias / /Users/dmg/Sites/tred/

  
        Order allow,deny
        Allow from all
    

  WSGIScriptAlias / /Users/dmg/Sites/tred/mod_wsgi-handler.wsgi

  WSGIDaemonProcess tred user=dmg group=staff processes=1 threads=10
  WSGIProcessGroup tred


mod_wsgi-handle.wsgi

mod_wsgi的-handle.wsgi

import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'tred.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

When I go to http://tred I get a directory listing rather than the rendered website. I think I have followed the tutorials correctly but it is obviously not right. What can I do to make this work?

当我去http:// tred时,我得到一个目录列表而不是渲染的网站。我想我已经正确地遵循了教程,但显然不对。我能做些什么来完成这项工作?

4 个解决方案

#1


6  

What happens if you remove the Alias / directive?

如果删除Alias /指令会发生什么?

#2


7  

Note that Alias and WSGIScriptAlias directives do not have the same precedence. Thus, they will not be processed in file order as written. Instead, all Alias directives get precedence over WSGIScriptAlias directives. Thus, it wouldn't have mattered if the Alias for '/' appeared after WSGIScriptAlias, it would still have taken precedence.

请注意,Alias和WSGIScriptAlias指令不具有相同的优先级。因此,它们不会按文件顺序处理。相反,所有Alias指令都优先于WSGIScriptAlias指令。因此,如果在WSGIScriptAlias之后出现'/'的别名,它将不再重要,它仍然优先。

#3


5  

It works. I have no idea why, but it does.

有用。我不知道为什么,但确实如此。

For future reference:

备查:

It works because Apache processes alias directives in order, and uses the first match. It was always hitting Alias /, which will match anything, before WSGIScriptAlias.

它的工作原理是因为Apache按顺序处理别名指令,并使用第一个匹配。在WSGIScriptAlias之前,它始终击中Alias /,它将匹配任何东西。

From the mod_alias documentation:

从mod_alias文档:

First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.

首先,在处理别名之前处理所有重定向,因此与Redirect或RedirectMatch匹配的请求永远不会应用别名。其次,别名和重定向按照它们在配置文件中出现的顺序进行处理,第一次匹配优先。

#4


2  

try following this tutorial - http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/

尝试按照本教程 - http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/

you are trying to host apache /var/www/ folder and the Django app both at root (/). Since Alias directive takes precedence over WSGIScriptAlias, it is rendering apache directory.

你试图在root(/)上托管apache / var / www /文件夹和Django应用程序。由于Alias指令优先于WSGIScriptAlias,因此它正在呈现apache目录。

you can try to host the django app at /app. Alternatively host the /var/www/ folder at a different location like /public

你可以尝试在/ app上托管django应用程序。或者将/ var / www /文件夹托管在/ public之类的其他位置


推荐阅读
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的详细步骤
    本文详细介绍了搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的步骤,包括环境说明、相关软件下载的地址以及所需的插件下载地址。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 在重复造轮子的情况下用ProxyServlet反向代理来减少工作量
    像不少公司内部不同团队都会自己研发自己工具产品,当各个产品逐渐成熟,到达了一定的发展瓶颈,同时每个产品都有着自己的入口,用户 ... [详细]
  • 本文介绍了在Windows环境下如何配置php+apache环境,包括下载php7和apache2.4、安装vc2015运行时环境、启动php7和apache2.4等步骤。希望对需要搭建php7环境的读者有一定的参考价值。摘要长度为169字。 ... [详细]
  • flowable工作流 流程变量_信也科技工作流平台的技术实践
    1背景随着公司业务发展及内部业务流程诉求的增长,目前信息化系统不能够很好满足期望,主要体现如下:目前OA流程引擎无法满足企业特定业务流程需求,且移动端体 ... [详细]
  • web.py开发web 第八章 Formalchemy 服务端验证方法
    本文介绍了在web.py开发中使用Formalchemy进行服务端表单数据验证的方法。以User表单为例,详细说明了对各字段的验证要求,包括必填、长度限制、唯一性等。同时介绍了如何自定义验证方法来实现验证唯一性和两个密码是否相等的功能。该文提供了相关代码示例。 ... [详细]
  • t-io 2.0.0发布-法网天眼第一版的回顾和更新说明
    本文回顾了t-io 1.x版本的工程结构和性能数据,并介绍了t-io在码云上的成绩和用户反馈。同时,还提到了@openSeLi同学发布的t-io 30W长连接并发压力测试报告。最后,详细介绍了t-io 2.0.0版本的更新内容,包括更简洁的使用方式和内置的httpsession功能。 ... [详细]
  • 本文介绍了通过ABAP开发往外网发邮件的需求,并提供了配置和代码整理的资料。其中包括了配置SAP邮件服务器的步骤和ABAP写发送邮件代码的过程。通过RZ10配置参数和icm/server_port_1的设定,可以实现向Sap User和外部邮件发送邮件的功能。希望对需要的开发人员有帮助。摘要长度:184字。 ... [详细]
  • HDFS2.x新特性
    一、集群间数据拷贝scp实现两个远程主机之间的文件复制scp-rhello.txtroothadoop103:useratguiguhello.txt推pushscp-rr ... [详细]
  • 本文介绍了在mac环境下使用nginx配置nodejs代理服务器的步骤,包括安装nginx、创建目录和文件、配置代理的域名和日志记录等。 ... [详细]
  • WebSocket与Socket.io的理解
    WebSocketprotocol是HTML5一种新的协议。它的最大特点就是,服务器可以主动向客户端推送信息,客户端也可以主动向服务器发送信息,是真正的双向平等对话,属于服务器推送 ... [详细]
author-avatar
手机用户2602931985
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有