[Answer]-Setting up django on a virtual machine

1👍

try mod_wsgi or uwsgi, it’s easier to config, robust, and much faster.

you could also get help at django doc – use django with mod_wsgi

as you are using ubuntu, the install of mod_wsgi is easy:

sudo apt-get install libapache2-mod-wsgi

if this does not have mod-wsgi enabled, do as following:

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

for using mod_python, the apache config is:

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

and for using uwsgi, my recommend is using nginx + uwsgi, if you are interesting, I’ll post the tutorial and configuration.

Leave a comment