设置ReviewBoard站点

时间:2017-11-06 16:43:52

标签: python apache2 mod-wsgi

我正在尝试使用these instructions为软件审阅工具调用ReviewBoard设置服务器。我在Ubuntu 16.04.3上使用python 2.7,apacahe2和postgres。我使用安装脚本生成文档根目录和此配置。

<VirtualHost *:80>
    ServerName http://mywebsite-here.com
    DocumentRoot "/var/www/reviewboard/htdocs"

    # Error handlers
    ErrorDocument 500 /errordocs/500.html

    WSGIPassAuthorization On
    WSGIScriptAlias "/" "/var/www/reviewboard/htdocs/reviewboard.wsgi/"

    <Directory "/var/www/reviewboard/htdocs">
        AllowOverride All 
        Options -Indexes +FollowSymLinks
        Allow from all
    </Directory>

    # Prevent the server from processing or allowing the rendering of
    # certain file types.
    <Location "/media/uploaded">
        SetHandler None
        Options None

        AddType text/plain .html .htm .shtml .php .php3 .php4 .php5 .phps .asp
        AddType text/plain .pl .py .fcgi .cgi .phtml .phtm .pht .jsp .sh .rb 

        <IfModule mod_php5.c>
            php_flag engine off 
        </IfModule>

        # Force all uploaded media files to download.
        <IfModule mod_headers.c>
            Header set Content-Disposition "attachment"
        </IfModule>
    </Location>

    # Alias static media requests to filesystem
    Alias /media "/var/www/reviewboard/htdocs/media"
    Alias /static "/var/www/reviewboard/htdocs/static"
    Alias /errordocs "/var/www/reviewboard/htdocs/errordocs"
    Alias /favicon.ico "/var/www/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>

索引WSGI脚本是

import __main__
__main__.__requires__ = ['ReviewBoard']
import pkg_resources

import os
import sys 

os.environ['DJANGO_SETTINGS_MODULE'] = "reviewboard.settings"
os.environ['PYTHON_EGG_CACHE'] = "/var/www/reviewboard/tmp/egg_cache"
os.environ['HOME'] = "/var/www/reviewboard/data"
os.environ['PYTHONPATH'] = '/var/www/reviewboard/conf:' + os.environ.get('PYTHONPATH', '') 

sys.path = ['/var/www/reviewboard/conf'] + sys.path

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我在尝试加载主页时遇到500错误,并且日志包含这些错误

[Mon Nov 06 11:26:37.499681 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]     working_set = WorkingSet._build_master(), referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499699 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]   File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 664, in _build_master, referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499704 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]     ws.require(__requires__), referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499709 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]   File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 981, in require, referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499715 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]     needed = self.resolve(parse_requirements(requirements)), referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499719 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]   File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 867, in resolve, referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499725 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883]     raise DistributionNotFound(req, requirers), referer: http://mywebsite-here.com
[Mon Nov 06 11:26:37.499795 2017] [wsgi:error] [pid 4908:tid 140377516406528] [client <ip address>:64883] DistributionNotFound: The 'idna>=2.1' distribution was not found and is required by cryptography, referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.620929 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904] mod_wsgi (pid=4909): Target WSGI script '/var/www/reviewboard/htdocs/reviewboard.wsgi' cannot be loaded as Python module., referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.620989 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904] mod_wsgi (pid=4909): Exception occurred processing WSGI script '/var/www/reviewboard/htdocs/reviewboard.wsgi'., referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.621027 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904] Traceback (most recent call last):, referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.621144 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904]   File "/var/www/reviewboard/htdocs/reviewboard.wsgi", line 3, in <module>, referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.621202 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904]     import pkg_resources, referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.621237 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904]   File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 72, in <module>, referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.621270 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904]     from . import py31compat, referer: http://mywebsite-here.com
[Mon Nov 06 11:27:37.621305 2017] [wsgi:error] [pid 4909:tid 140377390515968] [client <ip address>:64904] ImportError: cannot import name py31compat, referer: http://mywebsite-here.com
[Mon Nov 06 11:28:41.695761 2017] [wsgi:error] [pid 4909:tid 140377373730560] [client <ip address>:64912] mod_wsgi (pid=4909): Target WSGI script '/var/www/reviewboard/htdocs/reviewboard.wsgi' cannot be loaded as Python module., referer: http://mywebsite-here.com

但是,如果我在/ usr / bin / python中运行WSGI脚本的前三行,我就没有错误。此外,这些包似乎确实存在

$ locate py31compat
/usr/local/lib/python2.7/dist-packages/pkg_resources/py31compat.py
/usr/local/lib/python2.7/dist-packages/pkg_resources/py31compat.pyc
/usr/local/lib/python2.7/dist-packages/setuptools/py31compat.py
/usr/local/lib/python2.7/dist-packages/setuptools/py31compat.pyc
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import idna
'2.6'
>>>

1 个答案:

答案 0 :(得分:0)

我最终在python虚拟环境中安装并运行了ReviewBoard。