Ubuntu, Apache2, python3, django, mod wsgi
Дусал нэвтэрхий толь-с
18:03, 31 Арванхоёрдугаар сар 2018-ий байдлаарх Almas (Яриа | оруулсан хувь нэмэр) хэрэглэгчийн хийсэн залруулга
[Ubuntu18.04 + Apache2.4 + Django2.1 + Python3.6 + wsgi + virtualenv]
Гарчиг
Requirement package install
sudo apt-get update sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3 sudo pip3 install virtualenv virtualenvwrapper sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev pip3 install setuptools --upgrade
Configure a Python virtual enviroiment
cd /var/www/domain.com/web python3 manage.py startproject firstproject cd firstproject python3 -m venv firstprojenv source firstprojenv/bin/activate pip3 install django cd firstproject # optional: python3 ./manage.py migrate python3 ./manage.py createsuperuser python3 ./manage.py collectstatic
configure wsgi.py
import os import site import sys
site.addsitedir('/path/to/firstprojenv/lib/python3.6/site-packages') sys.path.append('/path/to/firstproject') sys.path.append('/path/to/firstproject/firstproject')
Configure Apache
deactivate vim /etc/apache2/sites-enabled/firstproject.conf a2ensite firstproject
Alias /static /path/to/firstprocject/static <Directory /path/to/fistproject/static> Require all granted </Directory> <Directory /path/to/firstproject/> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess test python-path=/path/to/firstproject:/path/to/firstprojenv/lib/python3.6/site-packages WSGIProcessGroup test WSGIScriptAlias / /path/to/firstproject/firstproject/wsgi.py
Change Owner
sudo chown -R :www-data /path/to/firstproject
Apache restart
sudo service apache2 restart