nidHi
nidHi

Reputation: 833

Deploying django project on apache

My django project mysite is located at path: /web/mysite

My virtualenv testEnv is located at path: /web/testEnv

All files and directories in in the above mentioned two paths are owned by www-data : www-data

All directories have permission drwxr-xr-x, files have permission -rw-r--r-- and db.sqlite3 has permission -rw-rw-r--.

I have added the following configuratiom in the apache default configuration file.

 <VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /web/mysite
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /web/mysite>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ... Some more config here ...

    Alias /static /web/mysite/mysite/static
    <Directory /web/mysite/mysite/static>
        Order allow,deny
        Allow from all
    </Directory>

    <Directory /web/mysite/mysite>
        <Files wsgi.py>
            Order allow,deny
            Allow from all
        </Files>
    </Directory>

    WSGIDaemonProcess mysite python-path=/web/testEnv/lib/python2.7/site-packages
    WSGIProcessGroup mysite
    WSGIScriptAlias / /web/mysite/mysite/wsgi.py

</VirtualHost>

When I restart the apache server I get the following error,

ImportError: No module named mysite.settings

I have checked multiple tutorials with still no luck and would need some guidance on the same.

[EDIT] Have added wsgi.py:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

Upvotes: 1

Views: 39

Answers (1)

RemcoGerlich
RemcoGerlich

Reputation: 31250

You already have the path to the virtualenv in python-path, but you also need to add the path to your project. Change the line to

WSGIDaemonProcess mysite python-path=/web/testEnv/lib/python2.7/site-packages:/web/mysite

Upvotes: 2

Related Questions