2012-07-04 91 views
0

我有一台运行peppermint os 2(基本上是ubuntu)的虚拟机。在虚拟机上设置django

我一直努力遵循下面的教程:http://jeffbaier.com/articles/installing-django-on-an-ubuntu-linux-server/

,到目前为止,一切都已经制定出的教程说明。我的Apache的httpd.conf文件看起来像如下:

ServerName localhost 

MaxRequestsPerChild 1 

    SetHandler python-program 
    PythonHandler django.core.handlers.modpython 
    SetEnv DJANGO_SETTINGS_MODULE myproject.settings 
    PythonPath "['/home/<my_user_name>/django_projects'] + sys.path" 

    SetHandler None 

    SetHandler None 

    SetHandler None 

    SetHandler None 

每当我尝试和并进入“本地主机/”,它让我在/ var/WWW /文件夹(index.html文件,说:“这工作!“),而不是应该出现的django首页。我的/ var/www的内容是“admin_media”和“media”

我需要做什么? 谢谢。

回答

1

尝试mod_wsgiuwsgi,它更容易配置,强大,更快。

你也可以为你使用Ubuntu的,安装的mod_wsgi的获得在django doc - use django with mod_wsgi

帮助很简单:

sudo apt-get install libapache2-mod-wsgi 

如果没有启用MOD-WSGI,请执行下列操作:

cd /etc/apache2/mod_available 
cp mod_wsgi.* ../mod_enable 
sudo service apache2 restart 

使用mod_python的,Apache的配置是:

ameVirtualHost *:80 
NameVirtualHost *:8000 
Listen 80 
Listen 8000 

WSGIDaemonProcess xxxx display-name=%{GROUP} 
WSGIProcessGroup xxxx 
<VirtualHost *:80> 
    ServerName xxxx 
    WSGIScriptAlias//home/xxx/xxxx/xxxx.wsgi 

    Alias /js "/home/xxx/xxxx/xxxx/public/js" 
    <Location "/js"> 
     SetHandler None 
    </Location> 
    <Directory "/home/xxx/xxxx/xxxx/public/js"> 
     Order Deny,Allow 
     Allow from all 
    </Directory> 
</VirtualHost> 

NameVirtualHost *:8080 
<VirtualHost *:8080> 
     WSGIScriptAlias//home/xxxx/xxxx/wsgi_handler.py 
     #WSGIDaemonProcess xxxx_com22 user=xxxx processes=1 threads=10 
     #WSGIProcessGroup xxxx_com1 

     Alias /upload/ "/home/xxxx/xxxx/upload/" 
     <Directory /home/xxxx/xxxx/upload/> 
       Options Indexes FollowSymLinks MultiViews 
       AllowOverride None 
       Order allow,deny 
       Allow from all 
     </Directory> 
</VirtualHost> 
Listen 8080 

为了使用uwsgi,我推荐使用nginx + uwsgi,如果你有兴趣,我会发布教程和配置。