403 запрещен для django + gunicorn + systemd + apache?

403 запрещен для django + gunicorn + systemd + apache?

Я следовалэтотруководство иэтотдля развертывания моего django с помощью guniconrn и apache.

Но я не совсем понимаю, чтоэтотв руководстве говорится:

(Вам все еще необходимо указать псевдоним и для статических и медиа-файлов, в дополнение к вышесказанному.)

Но в любом случае это все мои настройки. Мое приложение django находится на/var/www/html/django-project/helloapp

/etc/systemd/system/gunicorn.service:

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
PIDFile=/run/gunicorn/pid
User=lau
Group=lau
RuntimeDirectory=gunicorn
WorkingDirectory=/var/www/html/django-project/helloapp
ExecStart=/usr/bin/gunicorn --pid /run/gunicorn/pid   \
          --bind unix:/run/gunicorn/socket helloapp.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

/etc/systemd/system/gunicorn.socket:

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn/socket

[Install]
WantedBy=sockets.target

/etc/tmpfiles.d/gunicorn.conf:

d /run/gunicorn 0755 lau www-data -

/etc/apache2/apache2.conf:

<Directory /var/www/html/django-project/helloapp>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
</Directory>

/etc/apache2/sites-available/000-default.conf:

<VirtualHost *:80>
ProxyPass /static/ !
ProxyPass /media/ !
ProxyPass / http://localhost:8000/

</VirtualHost>

/etc/apache2/ports.conf:

Listen 80
Listen 8000

После перезапуска Apache я получаю 403 наhttp://127.0.0.1/илиhttp://127.0.0.1:8000

Forbidden

You don't have permission to access / on this server.
Apache/2.4.25 (Ubuntu) Server at localhost Port 8000

Есть идеи?

Я использую Ubuntu 17.04

РЕДАКТИРОВАТЬ:

Я вижу, что некоторые процессы Python запущены, но не уверен, правильно это или нет:

$ ps -wef | grep python
root      2418     1  0 06:16 ?        00:00:00 /usr/bin/python3 /usr/share/apt-xapian-index/update-apt-xapian-index-dbus
lau      25488 28678  0 23:49 pts/2    00:00:00 grep --color=auto python
lau      30605     1  0 18:30 ?        00:00:02 /var/www/html/django-project/helloapp/env/bin/python /var/www/html/django-project/helloapp/env/bin/gunicorn --workers 3 --bind unix:/var/www/html/django-project/helloapp.sock helloapp.wsgi:application
lau      30609 30605  0 18:30 ?        00:00:00 /var/www/html/django-project/helloapp/env/bin/python /var/www/html/django-project/helloapp/env/bin/gunicorn --workers 3 --bind unix:/var/www/html/django-project/helloapp.sock helloapp.wsgi:application
lau      30610 30605  0 18:30 ?        00:00:00 /var/www/html/django-project/helloapp/env/bin/python /var/www/html/django-project/helloapp/env/bin/gunicorn --workers 3 --bind unix:/var/www/html/django-project/helloapp.sock helloapp.wsgi:application
lau      30612 30605  0 18:30 ?        00:00:00 /var/www/html/django-project/helloapp/env/bin/python /var/www/html/django-project/helloapp/env/bin/gunicorn --workers 3 --bind unix:/var/www/html/django-project/helloapp.sock helloapp.wsgi:application

решение1

Я знаю, что это старый вопрос, и OP, возможно, решил проблему, но насколько я могу судить, вы запустили Gunicorn на порту 8000 и сказали apache прослушивать тот же порт. Поскольку два приложения прослушивают один и тот же порт, это, вероятно, создает конфликт. Судя по выходу ваших процессов, gunicorn уже запущен. Достаточно будет удалить Listen 8000из файла конфигурации apache и перезапустить apache снова. Это должно решить проблему.

Связанный контент