Search code examples
tracmod-python

Trac logo and favicon 404


This is going to read similar to the other Trac static resource issues I found (pretty well encompassed by this SO question), but this doesn't appear to be the same issue.

I have partial (non-root) access to a server with other Trac projects, and I have the ability to create my own Trac site. The server has the following software versions:

  • Python 2.7
  • Trac 1.0
  • mod_python 3.3.1

So I've created and have been using the site for a few weeks, but I can't get the logo or the favicon to show up. There is another Trac project to which I have access, and to make sure I wasn't missing anything obvious I compared the trac.ini files from both projects. The relevant sections have very similar settings, e.g.:

[header_logo]
src = site/my_logo.png

[project]
icon = site/favicon.ico

and those are both sitting in their respective Trac environments' htdocs folders:

/
  opt/
    trac/
      trac_env_1/
        htdocs/
          my_logo.png
          favicon.ico
      trac_env_2/
        htdocs/
          my_logo.png
          favicon.ico

However, the images only appear on one site but not the other. On my site Google Chrome says:

GET https://{Intranet URL}/trac/{my_trac_env}/chrome/site/my_logo.png 404 (Not Found)

I have tried the following, all of which have been unsuccessful:

  • Setting the width and height inside [header_logo] to the correct dimensions
  • Copying the exact same images that work on the other project over to my project
  • Changing site/favicon.ico to /favicon.ico and /favicon.ico? (as suggested on the Trac wiki)
  • Running trac-admin deploy . in place, copying the images to htdocs/common, and changing the trac.ini setting to common/my_logo.png
  • Changing site/my_logo.png to /images/my_logo.png and matching that folder structure in my trac environment.
  • Making an htdocs/site/ folder and adding the logo to it (which, I know, is what other people did wrong, but I'm banging my head against the wall here).

The only thing left I can think of is Apache settings, but from what I can tell it should handle whatever Trac environments it can find in /opt/trac. In /etc/httpd/conf.d/trac.conf, it has:

<Location /trac>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /opt/trac
PythonOption TracUriRoot /trac
PythonOption PYTHON_EGG_CACHE /var/trac/egg-cache
</Location>

That it uses TracEnvParentDir instead of just TracEnv is the important bit, I think.

So, I am at a loss. Please, can somebody help me?


Solution

  • Gah, I knew I was missing something simple.

    The problem was file permissions. Apache did not have read access to my Trac environment, so a simple chmod -R a+rX /opt/trac/trac_env_2 solved it.

    I guess that's another answer to the "My static files won't show up in Trac" question:

    1. Don't make an actual folder named "site" in your Trac environment; site/my_logo.png will look in trac_env/htdocs
    2. Make sure your server knows where to find your Trac environments. Both mod_python and mod_wsgi settings for this are easily found.
    3. Make sure your server has read access to your particular Trac environment (chmod a+rX to give directories-only execute permission)

    Just posting here in case anyone else runs into a similar issue.