关于Debian的Django

时间:2014-02-18 08:54:19

标签: django apache debian wsgi

所以我使用Debian 6.0.9(挤压)。 我有我在本地编码的项目,我在/ home / project /上载到我的服务器上 现在我已经拥有了mysql,apache2.2.16和许多不同的PHP网站托管。

这是一个典型的网站启用/ *我使用:

<VirtualHost *:80>
    ServerName project.com
    ServerAlias www.project.com

    DocumentRoot /var/www/project.com/htdocs/
</VirtualHost>

我安装了wsgi mod并尝试按照这里所说的https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/

没有任何作用。我不知道它是如何工作的,因为我不准确我想用于我的项目的URL。文档真的不清楚......任何人都知道我应该做什么?

编辑:我忘了写文件的样子:

<VirtualHost *:80>
ServerName project.com
ServerAlias project.com

DocumentRoot /var/www/project.com/htdocs

 WSGIScriptAlias / /home/project/project/wsgi.py
   <Directory /home/project/project>
      Order allow,deny
      Allow from all
   </Directory>

   Alias /robots.txt /var/www/project.com/htdocs/robots.txt
   Alias /favicon.ico /var/www/project.com/htdocs/favicon.ico
   Alias /images /var/www/project.com/htdocs/images
   Alias /static /var/www/project.com/htdocs/static

   ErrorLog /var/www/project.com/logs/error.log
   CustomLog /var/www/project.com/logs/access.log combined
</VirtualHost>

1 个答案:

答案 0 :(得分:1)

在您的VirtualHost def中: 确保配置:

  • DocumentRoot,WSGIScriptAlias - 正确配置是必须的
  • ErrorLog,CustomLog - 它有助于调试
  • WSGIDaemonProcess和WSGIProcessGroup - 是一种很好的安全措施

例如:

WSGIPythonHome PATH_TO_YOUR_PYTHON
<VirtualHost *:80>
    ServerName project.com
    ServerAlias www.project.com, *.project.*

    ErrorLog "/var/log/httpd/vhost_test_error.log"
    CustomLog "/var/log/httpd/vhost_test_access.log" combined

    WSGIDaemonProcess project processes=2 threads=15 display-name=%{GROUP}  python-path=PATH_TO_YOUR_VIRTUAL_ENV
    WSGIProcessGroup project

    #DocumentRoot /var/www/project.com/htdocs/
    DocumentRoot "/var/www/project.com/PATH_TO_DJANGO_PROJECT"
    WSGIScriptAlias / /var/www/project.com/PATH_TO_DJANGO_PROJECT/wsgi.py
</VirtualHost>