Django project not working with Apache and mod-wsgi
Question: I created a droplet(cloud server) on DigitalOcean and with no-ip.com I gave it
the hostname - project.ddns.net.By ssh(ing) into the droplet I installed pip
and virtualenv.

Inside /var/www/ I created a virtualenv and cloned the repository from github
of my project.The directory struture is -

    
    
    project_revamped  (root of the project)
    ->requirements
      ->base.txt
      ->dev.txt
    ->project (django project)
       ->static
       ->media
       ->apps (folder which contains apps)
       ->manage.py
       ->project
          ->urls.py
          ->settings
              ->base.py
              ->dev.py
    

I installed apache2 and mod_wsgi using -

    
    
    sudo apt-get install apache2
    sudo apt-get install libapache2-mod-wsgi
    

I then installed mysql,created a database and installed all requirements

    
    
    pip install -r base.txt
    

I created a virtualhost project.conf on the path -

    
    
    /etc/apache2/sites-available/project.conf
    

the content of file is this -

    
    
    <VirtualHost *:80>
    ServerAdmin example@gmail.com
    ServerName project.ddns.net
    ServerName www.project.ddns.net
    WSGIScriptAlias / /var/www/project_revamped/project/project/wsgi.py
    <Directory /var/www/project_revamped/project/project>
    Order deny,allow
    Allow from all
    </Directory>
    </VirtualHost>
    

Then I gave this command to activate this conf file -

    
    
    a2ensite project.conf
    

The content of my wsgi.py in my django project is -

    
    
    import os
    import sys
    import site
    #Add the site-packages of the chosen virtualenv to work with
       site.addsitedir('/var/www/.virtualenvs/projectenv/local/lib/python2.7/site-packages')
    #Add the app's directory to the python path
    sys.path.append('/var/www/project_revamped/project')
    sys.path.append('/var/www/project_revamped/project/project')
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings.dev'
    
    #Activate your virtualenv
    activate_env =         os.path.expanduser('/var/www/.virtualenvs/projectenv/bin/activate_this.py'    )
    execfile(activate_env, dict(__file__=activate_env))
    
    from django.core.wsgi import get_wsgi_application
    
    application = get_wsgi_application()
    

After changing the files I finally gave the commands -

    
    
    service apache2 reload
    service apache2 restart
    

However after doing these things right the corresponding ip says there is some
problem the server and sends 500 error.I guess the problem is somewhere in my
configuration because apache server was responding working fine.After I
include django project with it the problem starts.

Can anybody please help me here in the configuration? I am stuck in this for
past 2 days and every different article on the internet tells the different
story.


Answer: Have a look at [the official
documentation](https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/).
I think you're missing the `WSGIPythonPath`-directive.

As @BurhanKhalid stated, this linked tutorial is complete and tested and
should nearly exactly match your setup.

