"Ubuntu, Apache2, python3, django, mod wsgi"-ны өөр хувилбарууд
Дусал нэвтэрхий толь-с
(Хуудас үүсгэв: "[Ubuntu18.04 + Apache2.4 + Django2.1 + Python3.6 + wsgi + virtualenv] == Requirement package install == <pre> sudo apt-get update sudo apt-get install python3-pip...") |
|||
20-р мөр: | 20-р мөр: | ||
python3 manage.py startproject firstproject | python3 manage.py startproject firstproject | ||
cd firstproject | cd firstproject | ||
− | + | python3 -m venv firstprojenv | |
source firstprojenv/bin/activate | source firstprojenv/bin/activate | ||
pip3 install django | pip3 install django | ||
74-р мөр: | 74-р мөр: | ||
sudo service apache2 restart | sudo service apache2 restart | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | == Зарим хэрэгтэй хаяг == | ||
+ | |||
+ | # [https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/modwsgi/#daemon-mode Django Docs] | ||
+ | # [https://qiita.com/linux_22B/items/2bc90b1c309444a5da0c] | ||
+ | # [https://qiita.com/itisyuu/items/dafa535adc8197208af1] | ||
[[Ангилал:Сисадмин]][[Ангилал:Linux]] | [[Ангилал:Сисадмин]][[Ангилал:Linux]] |
17:59, 31 Арванхоёрдугаар сар 2018-ий байдлаарх засвар
[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('/home/user/Django1.9/py3.5/lib/python3.5/site-packages') sys.path.append('/home/user/Django1.9/firstproject') sys.path.append('/home/user/Django1.9/firstproject/firstproject')
Configure Apache
Alias /static /home/user/Django1.9/firstprocject/static <Directory /home/user/Django1.9/fistproject/static> Require all granted </Directory> <Directory /home/user/Django1.9/firstproject/> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess test python-path=/home/user/Django1.9/firstproject:/home/user/Django1.9/py3.5/lib/python3.5/site-packages WSGIProcessGroup test WSGIScriptAlias / /home/user/Django1.9/firstproject/firstproject/wsgi.py
Change Owner
sudo chown -R :www-data ~/Django1.9
Apache restart
sudo service apache2 restart