deploy django application with pipenv on apache

  • Last Update :
  • Techknowledgy :

If your virtualenv path is /home/user/.local/share/virtualenvs/app.application.com-IuTkL8w_ then try this:

sudo - u www - data cat / home / user / .local / share / virtualenvs / app.application.com - IuTkL8w_ / bin / activate_this.py`

Suggestion : 2

Date: 08 Jul 2018

Django
distribute
dj - database - url
psycopg2
wsgiref
packageC >= 1.0, <= 2.0
packageA
packageB
$ pip install pipenv
python - m pip install--user pipenv
pip install pipenv
$ pipenv shell--three

Suggestion : 3

Django + pipenv + Apache + mod_wsgi deployment on ubuntu not loading modules,Deployment Django using Apache and mod_wsgi on Remote Ubuntu Server,Django + Apache deployment on Ubuntu,Apache ImportError: No module named _socket in wsgi deployment on Django

Also, the addition in wsgi.py is unnecessary and didn't help solve the problem:

python_home = '/srv/project/.venv'

activate_this = python_home + '/bin/activate_this.py'
exec(open(activate_this).read(), dict(__file__ = activate_this))

Suggestion : 4

mod_wsgi is an Apache module which can host any Python WSGI application, including Django. Django will work with any version of Apache which supports mod_wsgi.,Deploying Django with Apache and mod_wsgi is a tried and tested way to get Django into production.,If, however, you have no option but to serve media files on the same Apache VirtualHost as Django, you can set up Apache to serve some URLs as static media, and others using the mod_wsgi interface to Django.,If multiple Django sites are run in a single mod_wsgi process, all of them will use the settings of whichever one happens to run first. This can be solved by changing:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonHome /path/to/venv
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
   <Files wsgi.py>
      Require all granted
   </Files>
</Directory>
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
os.environ["DJANGO_SETTINGS_MODULE"] = "{{ project_name }}.settings"
export LANG = 'en_US.UTF-8'
export LC_ALL = 'en_US.UTF-8'
WSGIDaemonProcess example.com lang = 'en_US.UTF-8'
locale = 'en_US.UTF-8'
WSGIDaemonProcess example.com python - home = /path/to / venv python - path = /path/to / mysite.com
WSGIProcessGroup example.com