如何使用apache解析django的默认apache页面

如何使用apache解析django的默认apache页面,django,apache,mod-wsgi,Django,Apache,Mod Wsgi,我刚开始部署django应用,我一直在尝试部署我的django应用,我似乎只能得到默认设置:“它可以工作”页面才能工作。我听了几篇教程,结果都不走运。 my'/etc/apache2/sites available/37.*.22.*'虚拟主机: `<VirtualHost *:80> ServerAdmin webmaster@37.***.22.** ServerName 37.***.22.** Docu

我刚开始部署django应用,我一直在尝试部署我的django应用,我似乎只能得到默认设置:
“它可以工作”
页面才能工作。我听了几篇教程,结果都不走运。 my
'/etc/apache2/sites available/37.*.22.*'
虚拟主机:

 `<VirtualHost *:80>
            ServerAdmin webmaster@37.***.22.**
            ServerName 37.***.22.**
            DocumentRoot /var/www/37.***.22.**/public_html
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/37.***.22.**/public_html>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny


 allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn CustomLog  ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
我已经将我的djagno应用程序的文件保存到服务器上的MyProject目录中。 我还运行了
a2ensite 37.**.22.25并重新启动了apache,但即使如此,我仍然得到了“it works”默认页面。我如何解决这个问题?
我还安装了Postfgress。我真的很想尽快部署这个应用程序,一直在努力,同时也学到了很多!如有任何建议,将不胜感激。
提前感谢。

请确保已安装并启用Apache


您还需要确保已经为虚拟主机定义了WSGIProcessGroup和WSGIScriptAlias(用于mod_wsgi)

我看不出这是怎么回事。您没有任何设置mod_wsgi或引用您的wsgi脚本的内容。如果您看到的是Django页面,那一定是因为其他配置。我没有看到Django页面,它只是默认的apache页面。如何设置对wsgi脚本的引用或设置mod_wsgi?我在这里很新。你有没有阅读并遵循Django文档站点上完美的部署说明?是的,我给自己时间阅读它们只是为了避免与我找到的其他教程混淆。我跟随他们,所以它部分地起作用。我的应用程序在我转到时运行。我现在的问题是,我可以通过键入来移动到我的应用程序的各个页面,例如myIP/django书签/登录或myIP/django书签/注册……但是,当我单击选项卡本身时,它会将我带到myIP/register(不带“django书签”),然后说“此服务器上找不到URL”。试图找出我搞砸的upmod_wsgi安装在哪里。我按照这里的说明进行了操作:。我按照那里的说明完成了所有工作,但我似乎无法理解如何启动和运行我的应用程序。您链接到的博客文章只讨论了为Apache设置虚拟主机。如果我们假设Apache已正确配置到这一点,那么下一步就是为您的虚拟主机配置mod_wsgi(允许Apache和Django相互“对话”)。查看如何使用WSGIProcessGroup和WSGIScriptAlias…在您最初的帖子中,您的虚拟主机配置中缺少了这两个组件。谢谢,我给了自己时间,阅读了django部署说明,并添加了WSGIScriptAlias和WSGIProcessGroup,我的应用程序目前部分可用。虽然我的URL有一些问题。我可以通过键入移动到我的应用程序的各个页面,例如myIP/django bookmarks/login或myIP/django bookmarks/register…..但是,当我单击选项卡本身时,它会将我带到myIP/register(没有“django bookmarks”),然后说“此服务器上找不到URL”。试着找出我把事情搞砸的地方如果这解决了你最初的问题,那就继续检查这是正确的答案。然后,如果你仍然有与新问题相关的问题,如果你需要额外的支持,请打开一个新问题。我也有同样的问题。我正确地执行了所有步骤,但浏览器显示了默认的apache index.html页面。我只是在chrome中使用Ctl+Shift+R重新加载页面,它就工作了。它显示了缓存中的apache default index.html页面。
import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/myprojectenv/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('~/MyProject/django-bookmarks')
sys.path.append('~/MyProject/django-bookmarks/django_bookmarks')

os.environ['DJANGO_SETTINGS_MODULE'] = 'django_bookmarks.settings'

# Activate your virtual env
activate_env=os.path.expanduser("~/.virtualenvs/myprojectenv/bin/activate_this.$
execfile(activate_env, dict(__file__=activate_env))

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