微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 apache

如何解决使用 apache

我正在尝试使用 apache 在亚马逊 Lightsail 中部署我的 django 项目。

我现在收到 500 内部服务器错误,日志文件说我缺少 django。 这是错误日志:

[Fri Jun 18 09:17:21.185206 2021] [mpm_event:notice] [pid 18855:tid 139805003744384] AH00491: caught SIGTERM,shutting down
[Fri Jun 18 09:17:21.234245 2021] [mpm_event:notice] [pid 32187:tid 139822253159552] AH00489: Apache/2.4.38 (Debian) mod_wsgi/4.6.5 Python/3.7 configured -- resuming norma
l operations
[Fri Jun 18 09:17:21.234333 2021] [core:notice] [pid 32187:tid 139822253159552] AH00094: Command line: '/usr/sbin/apache2'
[Fri Jun 18 09:17:58.402513 2021] [wsgi:error] [pid 32188:tid 139822222972672] [remote 93.43.210.55:49401] mod_wsgi (pid=32188): Failed to exec Python script file '/var/ww
w/sito_fotografo/sito_fotografo/sito/wsgi.py'.
[Fri Jun 18 09:17:58.402562 2021] [wsgi:error] [pid 32188:tid 139822222972672] [remote 93.43.210.55:49401] mod_wsgi (pid=32188): Exception occurred processing Wsgi script 
'/var/www/sito_fotografo/sito_fotografo/sito/wsgi.py'.
[Fri Jun 18 09:17:58.402710 2021] [wsgi:error] [pid 32188:tid 139822222972672] [remote 93.43.210.55:49401] Traceback (most recent call last):
[Fri Jun 18 09:17:58.402734 2021] [wsgi:error] [pid 32188:tid 139822222972672] [remote 93.43.210.55:49401]   File "/var/www/sito_fotografo/sito_fotografo/sito/wsgi.py",li
ne 12,in <module>
[Fri Jun 18 09:17:58.402777 2021] [wsgi:error] [pid 32188:tid 139822222972672] [remote 93.43.210.55:49401]     from django.core.wsgi import get_wsgi_application
[Fri Jun 18 09:17:58.402796 2021] [wsgi:error] [pid 32188:tid 139822222972672] [remote 93.43.210.55:49401] ModuleNotFoundError: No module named 'django'
[Fri Jun 18 09:23:28.841563 2021] [wsgi:error] [pid 32188:tid 139822105474816] [remote 93.43.210.55:49231] mod_wsgi (pid=32188): Failed to exec Python script file '/var/ww
w/sito_fotografo/sito_fotografo/sito/wsgi.py'.
[Fri Jun 18 09:23:28.841622 2021] [wsgi:error] [pid 32188:tid 139822105474816] [remote 93.43.210.55:49231] mod_wsgi (pid=32188): Exception occurred processing Wsgi script 
'/var/www/sito_fotografo/sito_fotografo/sito/wsgi.py'.
[Fri Jun 18 09:23:28.841707 2021] [wsgi:error] [pid 32188:tid 139822105474816] [remote 93.43.210.55:49231] Traceback (most recent call last):
[Fri Jun 18 09:23:28.841750 2021] [wsgi:error] [pid 32188:tid 139822105474816] [remote 93.43.210.55:49231]   File "/var/www/sito_fotografo/sito_fotografo/sito/wsgi.py",in <module>
[Fri Jun 18 09:23:28.841758 2021] [wsgi:error] [pid 32188:tid 139822105474816] [remote 93.43.210.55:49231]     from django.core.wsgi import get_wsgi_application
[Fri Jun 18 09:23:28.841775 2021] [wsgi:error] [pid 32188:tid 139822105474816] [remote 93.43.210.55:49231] ModuleNotFoundError: No module named 'django'

如果我尝试打电话:

which python3

我明白

/opt/bitnami/python/bin/python3

我真的不知道如何使用这些信息。我在重新安装 apache 后将我的项目放在 /var/www 中,我在创建实例后在服务器中找到的版本有一些我不喜欢的非常奇怪的文件配置。在 var/www/myproject 中有一个虚拟环境,我在其中安装了项目所需的模块

这是我在项目中的 wsgi.py 文件的相关部分

Alias /static /var/www/sito_fotografo/sito_fotografo/static
<Directory /var/www/sito_fotografo/sito_fotografo/static>
Require all granted
</Directory>

Alias /media /var/www/sito_fotografo/sito_fotografo/media
<Directory /var/www/sito_fotografo/sito_fotografo/media>
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

<Directory /usr/share/>
AllowOverride None
Require all granted
</Directory>

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

WsgiDaemonProcess sito_fotografo python-path=/var/www/sito_fotografo/sito-fotografo/sito python-home=/var/www/sito_fotografo/env
WsgiProcessGroup sito_fotografo
WsgiScriptAlias / /var/www/sito_fotografo/sito_fotografo/sito/wsgi.py

这是我的 wsgi 文件

"""
Wsgi config for sito project.

It exposes the Wsgi callable as a module-level variable named ``application``.

For more information on this file,see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
sys.path.append('var/www/sito_fotografo/sito_fotografo/sito')
os.environ.setdefault('DJANGO_SETTINGS_MODULE','sito.settings')

application = get_wsgi_application()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?