【发布时间】:2012-01-26 15:08:29
【问题描述】:
我的 Apache Mod_WSGI 和 Django 在 http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/ 之后工作,但我的 000-default 站点包含内容
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/nipun/webdev/demo/demo
<Directory /home/nipun/webdev/demo/demo>
Order allow,deny
Allow from all
WSGIDaemonProcess demo.djangoserver processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup demo.djangoserver
WSGIScriptAlias / /home/nipun/webdev/demo/demo/apache/django.wsgi
</Directory>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
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>
</VirtualHost>
所以使用这个配置,我基本上可以为我的 Django 网站提供服务,比如
http://localhost/meta 例如 meta 调用相应视图的地方
但是现在当我尝试加载位于我的 /var/www 上的 index.html(其中包含一些 javascript 和 html 代码)时,它会尝试使用 URL 来匹配它 在我用 Apache 配置的 Django 项目的 urls.py 中指定。
如何修改设置,以便能够在 /var/www 下提供脚本以及在 localhost 上提供 Django 站点
尝试第一个答案中给出的方法后
所以我添加了这一行
Alias / /var/www
在包含
WSGIDaemon...
现在 django 站点和我在 /var/www 中的文件都不起作用
已解决
将 000-default 文件更改为:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
Alias /robots.txt /var/www/robots.txt
Alias /testing.php /var/www/testing.php
Alias /index.html /var/www/index.html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
DocumentRoot /home/nipun/webdev/demo/demo
WSGIDaemonProcess demo.djangoserver processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup demo.djangoserver
WSGIScriptAlias / /home/nipun/webdev/demo/demo/apache/django.wsgi
<Directory /home/nipun/webdev/demo/demo>
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
</VirtualHost>
为了让它更智能,别名匹配可以像这样完成
AliasMatch /([^/]+).html /home/nipun/webdev/application_layer/$1.html
【问题讨论】:
标签: python django apache mod-wsgi