试图在内部自我托管readthedocs,并且对Django的经验很少。
我已经完成了readthedocs上的所有步骤(在/ usr / share /由我拥有的virtualenv,拥有组所有权www-data)的开发网络服务器,并且工作正常。
已采取以下额外步骤将wsgi和apache设置为selfhost:
安装了其他依赖项
配置redis以侦听套接字并放宽对777
apache配置为vhost:
<VirtualHost *:80>
ServerName docs.vagrant
WSGIScriptAlias / /usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/wsgi.py
WSGIProcessGroup www-data
WSGIDaemonProcess www-data \
python-path=/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/:/usr/share/readthedocs/lib/python2.7/site-packages/:/usr/share/readthedocs/:/usr/share/readthedocs/checkouts/readthedocs.org/:/usr/share/readthedocs/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/
<Directory /usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
并且流量似乎正确地进入了后端。然而,RTD抱怨缺少属性REDIS。 Apache错误日志输出:
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Starting process 'www-data' with uid=33, gid=33 and threads=15.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Initializing Python.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Attach interpreter ''.
[wsgi:info] [pid 19596] mod_wsgi (pid=19596): Attach interpreter ''.
[wsgi:info] [pid 19597] mod_wsgi (pid=19597): Attach interpreter ''.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/lib/python2.7/site-packages/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/checkouts/readthedocs.org/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Create interpreter 'docs.vagrant:3380|'.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/lib/python2.7/site-packages/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/checkouts/readthedocs.org/' to path.
[wsgi:info] [pid 19595] mod_wsgi (pid=19595): Adding '/usr/share/readthedocs/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/' to path.
[wsgi:info] [pid 19595] [remote 10.0.2.2:512] mod_wsgi (pid=19595, process='www-data', application='docs.vagrant:3380|'): Loading WSGI script '/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/wsgi.py'.
[wsgi:info] [pid 19624] mod_wsgi (pid=19624): Initializing Python.
[wsgi:info] [pid 19624] mod_wsgi (pid=19624): Attach interpreter ''.
[wsgi:error] [pid 19595] [09/Sep/2015 10:30:01] WARNING [readthedocs.api.client:16] SLUMBER_USERNAME/PASSWORD settings are not set
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] mod_wsgi (pid=19595): Exception occurred processing WSGI script '/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/wsgi.py'.
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] Traceback (most recent call last):
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] self.load_middleware()
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/handlers/base.py", line 52, in load_middleware
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] mw_instance = mw_class()
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] for url_pattern in get_resolver(None).url_patterns:
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] self._urlconf_module = import_module(self.urlconf_name)
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] __import__(name)
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/urls.py", line 8, in <module>
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] from readthedocs.api.base import (ProjectResource, UserResource,
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/api/base.py", line 28, in <module>
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] redis_client = redis.Redis(**settings.REDIS)
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in __getattr__
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] return getattr(self._wrapped, name)
[wsgi:error] [pid 19595] [remote 10.0.2.2:512] AttributeError: 'Settings' object has no attribute 'REDIS'
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] mod_wsgi (pid=19595): Exception occurred processing WSGI script '/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/wsgi.py'.
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] Traceback (most recent call last):
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] self.load_middleware()
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/handlers/base.py", line 52, in load_middleware
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] mw_instance = mw_class()
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] for url_pattern in get_resolver(None).url_patterns:
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] self._urlconf_module = import_module(self.urlconf_name)
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] __import__(name)
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/urls.py", line 8, in <module>
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] from readthedocs.api.base import (ProjectResource, UserResource,
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/api/base.py", line 28, in <module>
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] redis_client = redis.Redis(**settings.REDIS)
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] File "/usr/share/readthedocs/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in __getattr__
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] return getattr(self._wrapped, name)
[wsgi:error] [pid 19595] [remote 10.0.2.2:51327] AttributeError: 'Settings' object has no attribute 'REDIS'
我意识到我还需要弹性搜索和正确配置,但是当我走到那么远的时候我会越过那座桥。
更新:
发出命令grep -i redis /usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/settings/*
返回
__init__.py: 'BACKEND': 'redis_cache.RedisCache',
__init__.py: 'PARSER_CLASS': 'redis.connection.HiredisParser'
onebox.py:REDIS = {
onebox.py:BROKER_URL = 'redis://localhost:6379/0'
onebox.py:CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
onebox.py: 'BACKEND': 'redis_cache.cache.RedisCache',
onebox.py: 'CLIENT_CLASS': 'redis_cache.client.DefaultClient',
postgres.py: 'BACKEND': 'redis_cache.RedisCache',
postgres.py: 'PARSER_CLASS': 'redis.connection.HiredisParser'
sqlite.py:REDIS = {
sqlite.py:BROKER_URL = 'redis://localhost:6379/0'
sqlite.py:CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
所以我已经重新配置redis以不再使用套接字并返回绑定/端口但问题仍然存在(使用相同的堆栈跟踪)。
答案 0 :(得分:0)
好的,现在已经过了这个问题。不得不补充:
/usr/share/readthedocs/checkouts/readthedocs.org/readthedocs/settings/
到apache python-path
。
和
REDIS = {
'host': 'localhost',
'port': 6379,
'db': 0,
}
到设置中的postgres.py(来自 init .py的符号链接)
现在对其余的缺失依赖项错误进行排序。