V
V
Vitaly Khvan2018-06-07 14:41:01
Django
Vitaly Khvan, 2018-06-07 14:41:01

Deploy django project to virtual server, how to do it right??

In general, the server has python 2.6 python 3.5 and python 3.6
, there is also apache 2.2 version of
mod_wsgi-py35
and additional packages.
Apache config

<VirtualHost XXX.XXX.XXX.XXX:80>

ServerName sub.sample.com
ServerAlias www.sub.sample.com
ServerAlias webmail.sub.sample.com
ServerAlias admin.sub.sample.com
DocumentRoot /home/sample/public_html
ErrorLog /var/log/virtualmin/sub.sample.com_error_log
CustomLog /var/log/virtualmin/sub.sample.com_access_log combined

WSGIDaemonProcess voud python-home=/home/sample/public_html/projects_py/env/ python-path=/home/sample/public_html/ processes=1 maximum-requests=1 threads=1
WSGIProcessGroup %{GLOBAL}
WSGIScriptAlias / /home/sample/public_html/projects_py/sample/sample/wsgi.py process-group=%{GLOBAL}

<Directory /home/sample/public_html/projects_py/sample/sample>
<Files wsgi.py>
allow from all
</Files>
</Directory>
</VirtualHost>

WSGISocketPrefix /run/wsgi

wsgi.py code
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample.settings")

application = get_wsgi_application()

What I did, I uploaded a project with a virtual environment that I assembled on a local machine (under windows), installed a couple of packages like ckeditor and others there, then registered the config in apache
After uploading the project to the server in the projects_py project folder, I wrote the python -m command venv "env" (this is my virtual environment with windows)
When I try to go to sample.sample.com, I get a 500 error
in the server logs
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 943, in _find_and_load_unlocked
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
[Thu Jun 07 17:30:58 2018] [error]  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Thu Jun 07 17:30:58 2018] [error]  ImportError: No module named 'sample'

Actually, the question is, why does Apache not see my sample module if I indicated in the paths in the config where my env is located?
how can this situation be corrected?
When deleting a line, as expected, it swears at another error, respectively, wsgi daemon works, but it is not clear why it does not want to find my application module

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Kazantsev, 2018-06-07
@saintbyte

Stop toiling and make a bunch of ginucorn + nginx .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question