Internal Server Error with Trac: "ModuleNotFoundError: No module named 'trac'"

521 Views Asked by At

I'm installing Trac on a new RHEL 8 server and am getting an Internal Server Error in the httpd error log:

ModuleNotFoundError: No module named 'trac'

I've tried looking in audit logs with

journal -xe | grep httpd 

(and also grepped for trac, and apache) - and zero error information shown there either.

httpd starts normally without error.

Trac is configured to use wsgi, it's not the standalone version that has its own built in server. Apache HTTPD should be error handling.

Here is the httpd trac.conf file:

WSGIScriptAlias /trac /data/www/virtualhosts/trac/cgi-bin/trac.wsgi
 
<Location "/trac/login">
  AuthType Basic
  AuthName "Issue Tracker"
  AuthUserFile /data/www/virtualhosts/trac/conf/trac.htpasswd
  Require valid-user
</Location>
 
 
<Directory /data/www/virtualhosts/trac/cgi-bin>
    WSGIApplicationGroup %{GLOBAL}
    # For Apache 2.2
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Allow from all
    </IfModule>
    # For Apache 2.4
    <IfModule mod_authz_core.c>
        Require all granted
    </IfModule>
</Directory>

and trac.wsgi

import os
 
def application(environ, start_request):
    if not 'trac.env_parent_dir' in environ:
        environ.setdefault('trac.env_path', '/data/www/virtualhosts/trac')
    if 'PYTHON_EGG_CACHE' in environ:
        os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
    elif 'trac.env_path' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_path'], '.egg-cache')
    elif 'trac.env_parent_dir' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
    from trac.web.main import dispatch_request
    return dispatch_request(environ, start_request)

python version

[user@box] # python --version
Python 2.7.17 

I'm at a loss on why I can't get any error information to either display on screen or preferably write to a log file. This server isn't production so I can have stuff on screen for now.

Any help greatly appreciated

1

There are 1 best solutions below

12
RjOllos On

The problem might be the permissions on the cgi-bin directory or one of its parents.

The trac-admin deploy command will create a trac.wsgi for you, but you need to deploy outside your environment directory, otherwise, you'll get this error:

Error: Resources cannot be deployed to a target directory that is equal to or below the source directory '/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.4/htdocs'.

Please choose a different target directory and try again.

If your environment is /data/www/virtualhosts/trac, run:

$ trac-admin /data/www/virtualhosts/trac deploy /data/www/virtualhosts/www

Then point your virtualhosts file to /data/www/virtualhosts/www/cgi-bin/trac.wsgi.