繁体   English   中英

Django和apache2重新启动

[英]Django and apache2 restart

我尝试使用apache设置Django时遇到以下问题:

$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2
[Wed Mar 07 03:21:17 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
 ... waiting [Wed Mar 07 03:21:18 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
   ...done.

有什么想法会导致这种情况吗?

这是sites-available文件的内容:

NameVirtualHost *:80

              <VirtualHost *:80>
              ServerAdmin admin@website.com
              ServerName www.website.com
              ServerAlias website.com

              Alias /static /home/website/store/static

              DocumentRoot /home/website/store
              WSGIScriptAlias / /home/website/store/apache/django.wsgi

              ErrorLog /var/log/apache2/error.log

              LogLevel warn
              CustomLog /var/log/apache2/access.log combined
              </VirtualHost>

这也是wsgi文件:

import os, sys

#path to directory of the .wsgi file ('apache/')
wsgi_dir= os.path.abspath(os.path.dirname(__file__))

#path to project root directory (parent of 'apache/')
project_dir=os.path.dirname(wsgi_dir)

#add project directory to system's PATH
sys.path.append(project_dir)

project_settings=os.path.join(project_dir,'settings')
os.envision['DJANGO_SETTINGS_MODULE']='store.settings'

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

此错误与Apache有关,与django无关。

如果您正在进行开发,则不需要apache。 使用内置的开发服务器来满足您的需求。

由于您使用的是基于debian的系统,请参阅本文 ,其中说明了在debian上设置多个主机的正确方法(如果您使用的是其他基于debian的系统(如各种ubuntu风味),则正确。 如果您想了解有关虚拟主机的更多信息(无论如何都应该阅读), 虚拟主机文档中有许多示例。

从内存中这是由于NameVirtualHost在Apache配置中的多个位置具有相同的值而引起的。 通常,在站点可用目录中的站点文件中不会包含该指令,因为Apache配置的单独部分中的端口80已经存在该指令。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM