我正在使用AWS RHEL服务器。 每次访问网页时都会出现此错误(显示500的网页)。
error.log中:
[Sat Jul 09 02:51:12.736533 2016] [:error] [pid 2179] mod_wsgi (pid=2179): Target WSGI script '/opt/graphite/conf/graphite.wsgi' cannot be loaded as Python module.
[Sat Jul 09 02:51:12.736572 2016] [:error] [pid 2179] mod_wsgi (pid=2179): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi.
[Sat Jul 09 02:51:12.736593 2016] [:error] [pid 2179] Traceback (most recent call last):
[Sat Jul 09 02:51:12.736612 2016] [:error] [pid 2179] File "/opt/graphite/conf/graphite.wsgi", line 14, in <module>
[Sat Jul 09 02:51:12.736675 2016] [:error] [pid 2179] from graphite.logger import log
[Sat Jul 09 02:51:12.736685 2016] [:error] [pid 2179] File "/opt/graphite/webapp/graphite/logger.py", line 84, in <module>
[Sat Jul 09 02:51:12.736737 2016] [:error] [pid 2179] log = GraphiteLogger() # import-shared logger instance
[Sat Jul 09 02:51:12.736747 2016] [:error] [pid 2179] File "/opt/graphite/webapp/graphite/logger.py", line 40, in __init__
[Sat Jul 09 02:51:12.736762 2016] [:error] [pid 2179] self.infoHandler = Rotater(self.infoLogFile,when="midnight",backupCount=1)
[Sat Jul 09 02:51:12.736769 2016] [:error] [pid 2179] File "/usr/lib64/python2.7/logging/handlers.py", line 169, in __init__
[Sat Jul 09 02:51:12.737041 2016] [:error] [pid 2179] BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
[Sat Jul 09 02:51:12.737056 2016] [:error] [pid 2179] File "/usr/lib64/python2.7/logging/handlers.py", line 64, in __init__
[Sat Jul 09 02:51:12.737073 2016] [:error] [pid 2179] logging.FileHandler.__init__(self, filename, mode, encoding, delay)
[Sat Jul 09 02:51:12.737081 2016] [:error] [pid 2179] File "/usr/lib64/python2.7/logging/__init__.py", line 902, in __init__
[Sat Jul 09 02:51:12.737390 2016] [:error] [pid 2179] StreamHandler.__init__(self, self._open())
[Sat Jul 09 02:51:12.737401 2016] [:error] [pid 2179] File "/usr/lib64/python2.7/logging/__init__.py", line 925, in _open
[Sat Jul 09 02:51:12.737431 2016] [:error] [pid 2179] stream = open(self.baseFilename, self.mode)
[Sat Jul 09 02:51:12.737449 2016] [:error] [pid 2179] IOError: [Errno 13] Permission denied: '/opt/graphite/storage/log/webapp/info.log'
graphite.wsgi:
import os
import sys
sys.path.append('/opt/graphite/webapp')
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'graphite.settings') # noqa
from django.conf import settings
from django.core.wsgi import get_wsgi_application
from graphite.logger import log
application = get_wsgi_application()
try:
import whitenoise
except ImportError:
whitenoise = False
else:
# WhiteNoise < 2.0.1 does not support Python 2.6
if sys.version_info[:2] < (2, 7):
whitenoise_version = tuple(map(
int, getattr(whitenoise, '__version__', '0').split('.')))
if whitenoise_version < (2, 0, 1):
whitenoise = False
if whitenoise:
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)
prefix = "/".join((settings.URL_PREFIX.strip('/'), 'static'))
for directory in settings.STATICFILES_DIRS:
application.add_files(directory, prefix=prefix)
for app_path in settings.INSTALLED_APPS:
module = import_module(app_path)
directory = os.path.join(os.path.dirname(module.__file__), 'static')
if os.path.isdir(directory):
application.add_files(directory, prefix=prefix)
# Initializing the search index can be very expensive. The import below
# ensures the index is preloaded before any requests are handed to the
# process.
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search # noqa
graphite-vhost.conf(在端口8080上托管它):
# This line also needs to be in your server's config.
LoadModule wsgi_module modules/mod_wsgi.so
# You need to manually edit this file to fit your needs.
# This configuration assumes the default installation prefix
# of /opt/graphite/, if you installed graphite somewhere else
# you will need to change all the occurances of /opt/graphite/
# in this file to your chosen install location.
<IfModule !wsgi_module.c>
LoadModule wsgi_module modules/mod_wsgi.so
</IfModule>
# XXX You need to set this up!
# Read http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGISocketPrefix
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:8080>
ServerName localhost
DocumentRoot "/opt/graphite/webapp"
ErrorLog /var/log/httpd/graphite_error.log
#/opt/graphite/storage/log/webapp/error.log
CustomLog /var/log/httpd/graphite_access.log combined
#/opt/graphite/storage/log/webapp/access.log common
# I've found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=3 threads=5 display name='%{GROUP}' inactivity-timeout=120
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
# XXX You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely use, just copy it to graphite.wgsi
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
# XXX To serve static files, either:
# django-admin.py collectstatic --noinput --settings=graphite.settings
# * Install the whitenoise Python package (pip install whitenoise)
# or
# * Collect static files in a directory by running:
# django-admin.py collectstatic --noinput --settings=graphite.settings
# And set an alias to serve static files with Apache:
Alias /content/ /opt/graphite/webapp/content/
<Location "/content/">
SetHandler None
</Location>
# XXX In order for the django admin site media to work you
# must change @DJANGO_ROOT@ to be the path to your django
# installation, which is probably something like:
# /usr/lib/python2.6/site-packages/django
Alias /media/ "/usr/lib/python2.7/site-packages/django/contrib/admin/media/"
<Location "/media/">
SetHandler None
</Location>
# The graphite.wsgi file has to be accessible by apache. It won't
# be visible to clients because of the DocumentRoot though.
<Directory /opt/graphite/conf/>
Options All
AllowOverride All
Require all granted
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
我已经知道/ opt / graphite到apache了。仍然得到这个错误。请帮帮我。
答案 0 :(得分:0)
我通过更改SELinux设置来运行它。编辑文件/ etc / selinux / config:
SELINUX=disabled