B
B
Bisekenov2019-02-01 13:39:31
Django
Bisekenov, 2019-02-01 13:39:31

How to publish a django project using Apache on CentOS 7?

Wrote a simple django blog, learning django. Now I can't post it. The project wrote metanit.com
with this manual , that is, first, then I have a server on CentOS 7, Nginx is on the front as a proxy, on the Apach backend, I have different projects on php I wanted to publish a django project next to it, but I get an error 500.
django-admin startproject djangoblog
python manage.py startapp myblog

<VirtualHost *:8080>
    ServerName test.mydomian.ru
ErrorLog "/var/www/html/django/error_log" #логи временно сюда
CustomLog "/var/www/html/django/access_log" combined

  Alias /static /var/www/html/django/djangoblog
<Directory /var/www/html/django/djangoblog/static>
 Require all granted
</Directory>

<Directory /var/www/html/django/djangoblog/djangoblog>
   <Files wsgi.py>
       Require all granted
   </Files>
</Directory>

WSGIDaemonProcess djangoblogpython-path=/var/www/html/django:/var/www/html/virtualenv/djangoblog/lib/python2.7/site-packages
WSGIProcessGroup djangoblog
WSGIScriptAlias / /var/www/html/django/djangoblog/djangoblog/wsgi.py
</VirtualHost>

In the log:
[Fri Feb 01 15:40:46.703194 2019] [:error] [pid 16899] [remote 192.168.1.6:0] mod_wsgi (pid=16899): Target WSGI script '/var/www/html/django/djangoblog/djangoblog /wsgi.py' cannot be loaded as Python module.

If changed to:

WSGIDaemonProcess djangoblogpython-path=/var/www/html/django/djangoblog/\
python-home=/var/www/html/virtualenv

then the 500 error will disappear instead of it the Time Out error

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim Shatalov, 2019-02-01
@netpastor

[Fri Feb 01 15:40:46.703393 2019] [:error] [pid 16899] [remote 192.168.1.6:0] ImportError: No module named django.core.wsgi

Python environment not picked up - can't find django

A
Alexander, 2019-02-01
@NeiroNx

Probably a problem with the paths. See /var/www/html/django/error_log and whatever Python sends to stderr will be there.

B
Bisekenov, 2019-02-02
@Bisekenov

In general, I couldn’t do it on Apache) I
launched it on gunicorn + nginx on the front. works great

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question