1

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.

akg
  • 670
  • 10
  • 30
  • Please read [the documentation](https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/). – Burhan Khalid Jul 30 '15 at 09:38
  • @BurhanKhalid I read the documentation, but then I found great tutorial on the net so I followed that.The problem is in the video of the tutorial it works but in my case it is not working – akg Jul 30 '15 at 09:41
  • If you follow the documentation, you won't have issues as it is tested and verified by the community; and thus you'll get better support. – Burhan Khalid Jul 30 '15 at 10:16
  • @BurhanKhalid I have gone through the official documentation also but it is showing 500 error still.From my point of view documentation does not cover minnute details. – akg Jul 30 '15 at 10:26

1 Answers1

1

Have a look at the official documentation. 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.

Mischback
  • 843
  • 5
  • 18
  • take a look at this post I have added after following Django documentation -- http://stackoverflow.com/questions/31722465/error-while-uploading-django-project-to-a-apache-server-via-mod-wsgi – akg Jul 30 '15 at 17:06