[访问 网站时Django内部服务器错误

问题描述 投票:0回答:1

我已经在Linux机器上托管了Django网站。我还向我的项目目录授予了所有必需的权限。但是,当我尝试从浏览器访问网站时,出现错误

    Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.29 (Ubuntu) Server at li1988-26.members.linode.com Port 80

在页面上。

这是我的项目结构

/var/www/Intranet/

├── db.sqlite3
├── Intranet
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-36.pyc
│   │   ├── settings.cpython-36.pyc
│   │   ├── urls.cpython-36.pyc
│   │   └── wsgi.cpython-36.pyc
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── mainapp
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       └── __init__.cpython-36.pyc
│   ├── models.py
│   ├── __pycache__
│   │   ├── admin.cpython-36.pyc
│   │   ├── __init__.cpython-36.pyc
│   │   ├── models.cpython-36.pyc
│   │   ├── urls.cpython-36.pyc
│   │   └── views.cpython-36.pyc
│   ├── static
│   │   └── mainapp
│   │       ├── css
│   │       │   └── base.css
│   │       └── js
│   │           └── base.js
│   ├── templates
│   │   └── mainapp
│   │       ├── base.html
│   │       └── homepage.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
├── media
│   └── users
│       └── images
│           └── default.jpg
├── static
│   ├── admin
│   └── mainapp
│       ├── css
│       │   └── base.css
│       └── js
│           └── base.js
└── users
    ├── admin.py
    ├── apps.py
    ├── __init__.py
    ├── migrations
    │   ├── 0001_initial.py
    │   ├── __init__.py
    │   └── __pycache__
    │       ├── 0001_initial.cpython-36.pyc
    │       └── __init__.cpython-36.pyc
    ├── models.py
    ├── __pycache__
    │   ├── admin.cpython-36.pyc
    │   ├── __init__.cpython-36.pyc
    │   ├── models.cpython-36.pyc
    │   └── views.cpython-36.pyc
    ├── static
    ├── templates
    │   └── users
    │       ├── change_password.html
    │       ├── login.html
    │       ├── logout.html
    │       ├── password_change_done.html
    │       ├── password_reset_complete.html
    │       ├── password_reset_confirm.html
    │       ├── password_reset_done.html
    │       └── password_reset.html
    ├── tests.py
    └── views.py

这是我的/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
ServerName li1988-26.members.linode.com

ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined

WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/Intranet
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/Intranet/Intranet/wsgi.py

Alias /robots.txt /var/www/Intranet/static/robots.txt
Alias /favicon.ico /var/www/Intranet/static/favicon.ico
Alias /static/ /var/www/Intranet/static/
Alias /static/ /var/www/Intranet/media/

<Directory /var/www/Intranet/Intranet>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

<Directory /var/www/Intranet/static>
    Require all granted
</Directory>

<Directory /var/www/Intranet/media>
    Require all granted
</Directory>

然后我发出了命令

a2ensite 000-default.conf
sudo service apache2 restart

错误日志nano /var/log/apache2/error.log

[Fri Oct 25 09:12:51.993097 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Oct 25 09:12:51.993178 2019] [core:notice] [pid 16523:tid 140088200727488] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 25 09:18:42.041782 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Fri Oct 25 09:18:42.063081 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Oct 25 09:18:42.063104 2019] [core:notice] [pid 16523:tid 140088200727488] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 25 09:22:13.165844 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Fri Oct 25 09:22:13.359270 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Fri Oct 25 09:22:13.359309 2019] [core:notice] [pid 16523:tid 140088200727488] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 25 09:22:48.864610 2019] [mpm_event:notice] [pid 16523:tid 140088200727488] AH00493: SIGUSR1 received.  Doing graceful restart

我已经尝试过将所有解决方案作为对此问题的建议,但没有一个对我有用。

编辑2:更新Apache错误日志

   [Sat Oct 26 06:25:02.373002 2019] [mpm_event:notice] [pid 22161:tid 139856591948736] AH00489: Apache/2.4.29 (Ubuntu) mo$[Sat Oct 26 06:25:02.373042 2019] [core:notice] [pid 22161:tid 139856591948736] AH00094: Command line: '/usr/sbin/apach$
   [Sat Oct 26 19:46:25.042037 2019] [mpm_event:notice] [pid 22161:tid 139856591948736] AH00491: caught SIGTERM, shutting $
   [Sat Oct 26 19:46:25.116742 2019] [mpm_event:notice] [pid 25602:tid 140008539728832] AH00489: Apache/2.4.29 (Ubuntu) mo$
   [Sat Oct 26 19:46:25.116818 2019] [core:notice] [pid 25602:tid 140008539728832] AH00094: Command line: '/usr/sbin/apach$
python django apache apache2 wsgi
1个回答
0
投票

一起解决问题后,就是未正确安装mod_wsgi。仅供将来参考

© www.soinside.com 2019 - 2024. All rights reserved.