403 django + gunicorn + systemd + apache에 금지되어 있습니까?

403 django + gunicorn + systemd + apache에 금지되어 있습니까?

나는 팔로우했다이것안내하고이것guniconrn 및 apache를 사용하여 django를 배포합니다.

하지만 난 잘 모르겠어이것가이드는 다음과 같이 말합니다.

(위 항목 외에도 정적 및 미디어 파일에 대해 별칭을 지정해야 합니다.)

하지만 어쨌든 이것들은 모두 내 구성입니다. 내 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

아파치를 다시 시작하면 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

어떤 아이디어가 있나요?

나는 우분투 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가 문제를 해결했을 수도 있지만 내가 볼 수 있는 한 포트 8000에서 Gunicorn을 시작했고 아파치에게 동일한 포트를 듣도록 지시했습니다. 두 응용 프로그램이 동일한 포트를 수신하고 있으므로 충돌이 발생할 수 있습니다. 프로세스의 출력으로 판단하면 gunicorn이 이미 실행 중입니다. Listen 8000Apache 구성 파일에서 제거하고 Apache를 다시 시작하면 충분합니다 . 이렇게 하면 문제가 해결됩니다.

관련 정보