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

标签 python django apache apache2 wsgi

我在 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$

最佳答案

经过一起排查问题,是mod_wsgi没有安装好。仅供以后引用

关于python - 访问网站时Django内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58551771/

相关文章:

python - 在 python 中解析文本

python - 汇总列表的对象

sql - 加入 Django 的高效分页

django - 恢复已删除的 Django 迁移

django - 如何以 markdown 或 html 格式呈现 .rst 文件?

apache - 添加Apache VirtualHost,localhost的DocumentRoot修改为VirtualHost的DocumentRoot

python - 如何链接涉及 'index' 操作的 pandas 管道操作?

python - 连接到 wsdl 时出错?

linux - 虚拟主机 Apache 2.2

linux - 如何让 "safely"允许其他人在我的服务器上工作?