453: Need help with Apache configuration and reviewboard.settings file

t**@alsop-fa******** (Google Code) (Is this you? Claim this profile.)
April 19, 2008
I have configured reviewboard and I am able to logon if I start it using:

./manage.py runserver

However, I want to use it in Apache using a sub directory, e.g.
http://server.domain/reviewboard should show the home page of reviewboard
(e.g. the dashboard). 

I am using mod_python in apache, so I am trying to use the
apache-modpython.conf.in file (from contrib/conf directory) as a template.

My apache configuration currently looks like:

DocumentRoot /opt/reviewboard/htdocs
ErrorDocument 500 /reviewboard/errordocs/500.html

<Location "/reviewboard/">
        PythonPath "['/usr/lib/python2.4/site-packages/django'] +
['/opt/reviewboard'] + ['/opt/reviewboard/djblets'] + sys.path"
        SetEnv DJANGO_SETTINGS_MODULE reviewboard.settings
        SetHandler mod_python
        PythonHandler django.core.handlers.modpython
        PythonAutoReload Off
        PythonDebug On
        PythonInterpreter reviewboard
</Location>

# Serve static media without running it through mod_python (overrides the
above)
<LocationMatch ^(/reviewboard/(media|errordocs))>
        SetHandler None
</LocationMatch>

# Alias static media requests to filesystem
Alias /reviewboard/media /opt/reviewboard/htdocs/media
Alias /reviewboard/errordocs /opt/reviewboard/htdocs/errordocs

However, when I try to logon I get the following in browser:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299,
in HandlerDispatch
    result = object(req)

  File
"/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line
189, in handler
    return ModPythonHandler()(req)

  File
"/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line
153, in __call__
    self.load_middleware()

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 27, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 28,
in __getattr__
    self._import_settings()

  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 59,
in _import_settings
    self._target = Settings(settings_module)

  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 87,
in __init__
    raise ImportError, "Could not import settings '%s' (Is it on sys.path?
Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

ImportError: Could not import settings 'reviewboard.settings' (Is it on
sys.path? Does it have syntax errors?): No module named reviewboard.settings

I am a little confused about reviewboard.settings file and what should go
in it, and where it needs to be placed. I tried to put a file by this name
in various locations, but I get the same error as above.

Can you please:

1. Explain to me what reviewboard.settings should contain
2. Tell me where I need to put the reviewboard.settings file
3. Help me with my configuration so that I can use Apache and have
reviewboard in the /reviewboard location, rather than at top of the URL. I
cannot use top of URL since I have another Apache site at that location.

Thanks,
Tim
chipx86
#1 chipx86
The settings file (settings.py) is provided by Review Board and should not be
modified or placed in any location. What this error means is that your configuration
isn't pointing to the right directory.

I strongly recommend you use one of the sample configuration files in
reviewboard/contrib/conf/ as a basis for your setup.

What you will have to create is a settings_local.py file. Use settings_local.py.tmpl
as a base for this, and put it in the reviewboard directory (same directory as
settings.py).

You will need to set the following variables: SITE_ROOT, MEDIA_URL, and LOGIN_URL.

They should look something like:

SITE_ROOT = "/reviewboard/"
MEDIA_URL = SITE_ROOT + "media/"
LOGIN_URL = SITE_ROOT + "account/login"
#2 t**@alsop-fa******** (Google Code) (Is this you? Claim this profile.)
I didn't change settings.py. I did as the documentation described and copied this
file to setting_local.py.tmpl to settings_local.py and made changes to this to make
RB work. I have RB working (apart from issues with pysvn) if I start it using
"manage.py runserver" but I need help making it work with Apache.

I did use the template in contrib/conf as a starting point, but that template (a)
doesn't use sub directory, and (b) uses a virtual server approach. I cannot use
differnet URL/domain, and I want to use a sub directory so I have tried to change the
template to meet my needs and this is where I am stuck.

I am still not clear what the reviewboard.settings file is - is this an actual
filename on file system, or is it some sort of logical representation which somehow
maps onto settings_local.py ?
#3 t**@alsop-fa******** (Google Code) (Is this you? Claim this profile.)
I just tried the following:

My RB files were in /opt/reviewboard - this is where I used svn to checkout the trunk
from RB website.
I created a symbolic link to the /opt/reviewboard directory in
/usr/lib64/python2.4/site-packages and now it gets further than before. I am getting
an error related to the database. I think I noticed somebody else had this issue and
it was due to permissions - I will check and then update this issue with my progress.

Note: The documentation should explain that the reviewboard software needs to be
located in the site-packages directory in a reviewboard sub directory. This is what
was missing that caused me to get these issues.
#4 t**@alsop-fa******** (Google Code) (Is this you? Claim this profile.)
Since I am using sqlite3 for my db I needed to change my DATABASE_NAME in
settings_local.py to '/opt/reviewboard/reviewboard.sqlite' instead of
'reviewboard.sqlite'.

Now, RB is working in Apache in a sub directory, and not using Virtual Directories ...

Hurray.

I need to close this issue, but I cannot find a way to change it's status. If
somebody else can change status for me I would appreciate it.
david
#5 david
Unfortunately, google code's issue tracker sucks for non-developers, so only we can
close it.  Glad things are working for you!
  • +Fixed