根据我的错误日志,我的目标WSGI脚本无法作为Python模块加载,但是在我的日志末尾,我还收到一个 ImportError:No module
named foodshop.settings
。我可以验证该模块是否存在。
这是我的错误日志:
[Tue Sep 15 03:49:04.828560 2015] [mpm_event:notice] [pid 7384:tid 140261847136128] AH00491: caught SIGTERM, shutting down
[Tue Sep 15 03:49:05.880294 2015] [mpm_event:notice] [pid 7539:tid 139824273098624] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Tue Sep 15 03:49:05.880314 2015] [core:notice] [pid 7539:tid 139824273098624] AH00094: Command line: '/usr/sbin/apache2'
[Tue Sep 15 03:49:34.435217 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] mod_wsgi (pid=7543): Target WSGI script '/home/ubuntu/gather/src/foodshop/wsgi.py' cannot be loaded as Python module.
[Tue Sep 15 03:49:34.435250 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] mod_wsgi (pid=7543): Exception occurred processing WSGI script '/home/ubuntu/gather/src/foodshop/wsgi.py'.
[Tue Sep 15 03:49:34.435290 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] Traceback (most recent call last):
[Tue Sep 15 03:49:34.435307 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/home/ubuntu/gather/src/foodshop/wsgi.py", line 16, in <module>
[Tue Sep 15 03:49:34.435360 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] application = get_wsgi_application()
[Tue Sep 15 03:49:34.435372 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Tue Sep 15 03:49:34.435406 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] django.setup()
[Tue Sep 15 03:49:34.435417 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 17, in setup
[Tue Sep 15 03:49:34.435449 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Tue Sep 15 03:49:34.435460 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in __getattr__
[Tue Sep 15 03:49:34.435521 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] self._setup(name)
[Tue Sep 15 03:49:34.435532 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 44, in _setup
[Tue Sep 15 03:49:34.435545 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] self._wrapped = Settings(settings_module)
[Tue Sep 15 03:49:34.435552 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 92, in __init__
[Tue Sep 15 03:49:34.435562 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] mod = importlib.import_module(self.SETTINGS_MODULE)
[Tue Sep 15 03:49:34.435570 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Tue Sep 15 03:49:34.435604 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] __import__(name)
[Tue Sep 15 03:49:34.435619 2015] [:error] [pid 7543:tid 139824089818880] [remote 104.156.102.54:7776] ImportError: No module named foodshop.settings
另外,这是我的apache2.conf文件:
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIScriptAlias / /home/ubuntu/gather/src/foodshop/wsgi.py
<Directory /home/ubuntu/gather/src/foodshop/>
WSGIProcessGroup gather
WSGIApplicationGroup %{GLOBAL}
Options All
AllowOverride All
Require all granted
</Directory>
Alias /media/ /home/ubuntu/gather/src/foodshop/media/
<Directory /home/ubuntu/gather/src/foodshop/media/>
Options FollowSymLinks MultiViews
Order deny,allow
Allow from all
</Directory>
Alias /static/ /home/ubuntu/gather/src/foodshop/static/
<Directory /home/ubuntu/gather/src/foodshop/static/>
Options FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
和我的000-default.conf文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/ubuntu/gather/static
<Directory /home/ubuntu/gather/static>
Require all granted
</Directory>
<Directory /home/ubuntu/gather/src/foodshop>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess gather processes=2 threads=15
WSGIProcessGroup gather
WSGIScriptAlias / /home/ubuntu/gather/src/foodshop/wsgi.py
</VirtualHost>
最后,这是我的wsgi.py文件:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "foodshop.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
我已连接到EC2实例(Ubuntu 14.04),并且在该实例上仅运行1个应用程序。当我在本地主机上运行它时,它可以完美运行。
您无需做任何事情即可将您的应用程序及其设置文件放置在Python路径上。
如果您不使用virtualenv(尽管应该使用),那么最简单的方法是在wsgi文件中执行以下操作:
import os, sys
sys.path.append('/home/ubuntu/gather/src')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "foodshop.settings")
问题内容: 我正在尝试用apache部署mod_wsgi来运行django应用程序,但出现了错误500内部服务器错误apache日志显示: 我的apache虚拟主机如下: 并在我的应用程序目录中具有0777权限的引用的wsgi文件: 我听说这可能是因为apache用户没有正确的权限。但是我不知道如何解决此问题。我还尝试了与www-data用户一起启动守护进程,但这并不能解决问题。 编辑: 通过将虚
我试图通过mod_wsgi WSGIDaemon方法将虚拟主机django项目部署到apache2中,我使用的是ubuntu 16.04,我遇到了以下错误。 从apache2错误日志: [2018年12月11日星期二11:55:31.748517][wsgi:error][pid 14231:tid 139821891782400][remote::1:44748]mod_wsgi(pid=142
问题内容: 我正在尝试为这个工作中的项目学习AJAX。我有一个网站加载病人正在服用的药物。 我递归调用此AJAX函数,以便它将附加一个包含单种药物和7天历史记录的新表。我在使代码在FF和IE中执行时遇到问题。在chrome中效果很好。我有显示xmlhttp.status的警报,这是我得到的: xmlhttp.status == 500(内部服务器错误)。 我注释掉了所有递归,因此将其范围缩小到了这
我收到以下错误 内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请联系服务器管理员,webmaster@strivemedicare.in并告知他们错误发生的时间,以及可能导致错误的任何行为。 有关此错误的详细信息,请参阅服务器错误日志。 此外,尝试使用错误文档处理请求时遇到 500 内部服务器错误错误。
我一直试图在nginx上安装CakePHP,但我遇到了一个死胡同。尝试访问web根目录时,我收到一个500内部服务器错误。我在我的错误中得到了这个错误。日志: PHP消息:PHP致命错误:require():无法打开required'/var/www/html/test/vendor/autoload。php'(include_path='。:/usr/share/php:/usr/share/p
我想用ajax向laravel中的控制器发送post请求。ajax请求发送两个输入参数,我希望controller在数据库中找到包含第一个参数的列,然后使用第二个输入参数设置name属性。但是我在控制台500中有这个错误消息(内部服务器错误)。 Ajax功能: 路线: 控制器功能: 而且我导入csrf无处不在,因为上次当我做AJAX调用我有这个csrf的问题,下面的代码已经修复了我的问题,但现在不