"Ubuntu, Apache2, python3, django, mod wsgi"-ны өөр хувилбарууд

Дусал нэвтэрхий толь-с
43-р мөр: 43-р мөр:
  
 
== Configure Apache ==
 
== Configure Apache ==
 +
 +
<pre>
 +
deactivate
 +
vim /etc/apache2/sites-enabled/firstproject.conf
 +
a2ensite firstproject
 +
</pre>
  
 
<pre>
 
<pre>
65-р мөр: 71-р мөр:
  
 
<pre>
 
<pre>
sudo chown -R :www-data ~/Django1.9
+
sudo chown -R :www-data /path/to/firstproject
 
</pre>
 
</pre>
  

18:01, 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

deactivate
vim /etc/apache2/sites-enabled/firstproject.conf
a2ensite firstproject
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 /path/to/firstproject


Apache restart

sudo service apache2 restart


Зарим хэрэгтэй хаяг

  1. Django Docs
  2. [1]
  3. [2]