apache - how to host django project in ubuntu using wsgi_mod -


i created sample django project in /var/www/firstproject, configured using this link

firstproject.conf in etc/apache2/sites-available 

but got forbidden error. how can solve error, , host project?

you not given proper explanation error.

required packages:

  • apache2
  • libapache2-mod-wsgi
  • django

create empty project

  • cd /var/www
  • sudo virtualenv foldername
  • cd foldername
  • sudo django-admin.py startproject projectname
  • cd projectname
  • sudo nano projectname.wsgi

projectname.wsgi file

 import os   import sys   sys.path.append('/var/www/foldername/projectname')   os.environ['django_settings_module'] = 'projectname.settings'   django.core.wsgi import get_wsgi_application   application = get_wsgi_application()   
  • cd /etc/apache2/sites-available
  • sudo nano projectname.conf

projectname.conf file

<virtualhost *:80>      servername www.example.com        serveralias  www.example.com        serveradmin webmaster@localhost      documentroot /var/www/foldername/projectname      wsgiscriptalias / /var/www/foldername/projectname/projectname.wsgi      alias /static /var/www/foldername/static/static_only      errorlog ${apache_log_dir}/error.log      customlog ${apache_log_dir}/access.log combined   </virtualhost>  

sudo nano /etc/hosts

you need add following line hosts file

your_ip www.example.com 

goto project location , run python manage.py collectstatic local files copies inside static_only folder

may getting "attempt write readonly database " error ,this permission issue need run following command .

chown www-data:www-data /var/www/foldername chown www-data:www-data /var/www/foldername/projectname/db.sqlite3 

now type www.example.com on browser


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -