PDA

View Full Version : Setting up Trac


MarmaladeMan
06-12-2007, 02:53 PM
I'm having some trouble getting Trac to work. I've been following the steps on the wiki (http://guide.apisnetworks.com/index.php/Trac). The initial Trac environment setup went fine (/home/marmalademan/trac).

I'd like Trac to operate from /home/dev/public_html/trac (Step 4). Here's where I may have started making a mistake or two or three. I made a hard link, ln -f /usr/local/share/trac/cgi-bin/trac.fcgi /home/dev/public_html/trac. I also tried copying trac.fcgi over when I realized I wasn't having any success.

I added:

import os
os.environ['TRAC_ENV'] = "/home/marmalademan/trac"

...to trac.fcgi in the correct place. I made a symlink to /usr/local/share/trac/htdocs/ in /home/dev/public_html/trac/ as per step 6.

I added htdocs_location = /trac/public to trac.ini, and added DirectoryIndex trac.fcgi to .htaccess in the trac.fcgi folder (though I wasn't sure if it meant /usr/local/share/trac/cgi-bin/ or /home/dev/public_html/trac/ ...either way I put it in both).

I'm completely new to Trac and I'm really not sure where to go from here, and I admit I'm not seeing the big picture of how this overall setup works. When I load up the URL to trac (dev.hiprmod.net/trac), it just loads and loads and nothing happens. Any help is greatly appreciated! Cheers,

Chris

Matt
06-12-2007, 02:55 PM
Use the trac.cgi script instead. There's something wonky with the FastCGI interface bundled in Trac 0.10.x. It'll load up eventually, but there is a noticeable delay between the request and when the page finally loads (a bunch of mutex timeouts). Check the permissions on the parent directory and trac.fcgi,cgi file too since it goes through Suexec (http://guide.apisnetworks.com/index.php/Suexec) if it's not loading period.

MarmaladeMan
06-12-2007, 03:02 PM
Roger, will try that. One thing about Step 5 confuses me:

If you're using trac.cgi (not recommended), create a file called .htaccess under the Trac.

Under the Trac document root (/home/dev/public_html/trac)? Or in /usr/local/share/trac/cgi-bin? Or in /home/marmalademan/trac? The wiki is a little vague on that.

Matt
06-12-2007, 03:04 PM
If you're using trac.cgi (not recommended), create a file called .htaccess under the Trac.

That's in reference to the document root for the Trac installation. If http://foobar.com/trac/ is the location you access Trac from and it corresponds to /var/www/html/trac/, then the .htaccess file goes there.

MarmaladeMan
06-12-2007, 03:13 PM
I'm now just getting a blank screen when I browse to the trac root through my browser. Is it right that I should only have trac.cgi, .htaccess, and a symlink to /usr/local/share/trac/htdocs/ in my Trac document root?

I checked permissions on trac.cgi and parent folders, 755 all around.

Matt
06-12-2007, 03:17 PM
You're missing the os.environ... part in trac.cgi.

MarmaladeMan
06-12-2007, 03:25 PM
Added... still no dice.

Is that needed if the SetEnv TRAC_ENV "/home/marmalademan/trac" is in .htaccess? Are those redundant?

Matt
06-12-2007, 03:27 PM
Don't edit the file in Notepad. The CGI scripts need the \n line ending for the shebang line.

MarmaladeMan
06-12-2007, 03:31 PM
I've been editing the .cgi files in Dreamweaver because they're illegible in Notepad. Does that work?

-edit- Just thought of something: user dev wasn't created with CGI as a service, is that necessary?

Matt
06-12-2007, 03:32 PM
Obvious answer would be in this current state: no. Make sure when you save the file it's encoded with the Unix-style (\n) line endings and not Windows (\r\n).

MarmaladeMan
06-12-2007, 03:49 PM
Okay, I set DW to Unix mode, saved the file, uploaded, still no dice. Hrm

Matt
06-12-2007, 03:50 PM
You need to actually convert the existing line endings to Unix...

MarmaladeMan
06-12-2007, 04:02 PM
I've recreated all the line breaks in the file, though no luck. Is that what you meant? I literally went through each line, deleted the line break, made a new one, then once I was done I saved it and uploaded.

Could it have anything to do with the Trac environment folder being under user marmalademan, but the document root under user dev?

Matt
06-12-2007, 04:03 PM
No, observe:

[root@borel trac]# ./trac.cgi
: bad interpreter: No such file or directory
[root@borel trac]# ls -al trac.cgi
-rwxr-xr-x+ 1 marmalademan marmalademan 1167 Jun 12 14:59 trac.cgi
[root@borel trac]# dos2unix trac.cgi
dos2unix: converting file trac.cgi to UNIX format ...
[root@borel trac]# chown marmalademan:marmalademan trac.cgi
[root@borel trac]# ./trac.cgi
'SERVER_PORT'
Traceback (most recent call last):
File "./trac.cgi", line 21, in ?
cgi_frontend.run()

MarmaladeMan
06-12-2007, 04:20 PM
Ah, I didn't know about dos2unix. I also dos2unix'd trac.ini since that may have been afflicted as well. Trac remains non-functioning though.

Matt
06-12-2007, 04:23 PM
Because the dev subdomain is owned by the user dev the trac.cgi file must also be owned by dev.

MarmaladeMan
06-12-2007, 04:23 PM
Thanks a ton Matt! You are amazing. :D

Matt
07-14-2007, 03:13 AM
The abysmal performance with Trac and the FastCGI handler for Python should be fixed on all of the servers by next weekend. Turns out there was a bug in the older Core 2 Duo microcode was causing several mutex timeouts. Intel addressed this problem with its microcode update in April, but we need to run 2.6.20 at the bare minimum to utilize the changes. All of the servers are running 2.6.19, so I'll need to take them down next week for a kernel upgrade. It takes roughly 3 minutes to complete and afterwards Trac's FastCGI handler will be humming along.

ocdude
07-22-2007, 02:41 PM
Not to hijack the thread, but I'm having similar issues with my setup on http://dev.bluewavedigital.net/trac

I honestly have no idea if I goofed somewhere in the setup (though the tracd test worked fine). I'm using the .fcgi version.

trac initenv:
/home/ocdude/trac/

and where it resides on the subdomain:
/var/www/dev_azul/trac/

This subdomain is owned by ocdude, and .fcgi is owned by ocdude. I followed the wiki, and running trac.fcgi from the command line outputs html, but it gives me the following errors at the top of the output:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!

I know PHP fairly well, but when it comes down to this setup, I'm completely lost.

Matt
07-22-2007, 02:42 PM
See http://guide.apisnetworks.com/index.php/Suexec

Incorrect permissions on trac.fcgi and its parent directory.

ocdude
07-22-2007, 03:36 PM
Okay, I've changed permissions and now the page loads, but it seems all the layout information still doesn't. I get a page with the layout all screwy.

I'm sorry I'm such a newbie at this, but thanks for your help Matt!

Matt
07-22-2007, 04:06 PM
htdocs_location in trac.ini should be /trac/htdocs and not /trac/public, since you have a symlink named htdocs to /usr/local/share/trac/htdocs/. Looks like the Wiki syntax highlighting on guide.apisnetworks.com got slightly munged during the upgrade. I'll need to fix that after the MediaWiki one-click update.

ocdude
07-22-2007, 04:09 PM
Oh, oops. I figured it was something like that. Once again, Matt, you are a life saver.

MarmaladeMan
08-27-2007, 12:55 AM
I'm trying to install the WebAdmin (http://trac.edgewall.org/wiki/WebAdmin) plugin and I think I've hit the limit of my comprehension. I've been reading the TracPlugins (http://trac.edgewall.org/wiki/TracPlugins) page for instructions. Since it appears we don't have easy_install support, I take it that setuptools is needed. I'm not sure where to put ez_setup.py, or if that's even what I should be doing. Can someone point me in the right direction?

Thanks!

Matt
08-27-2007, 01:34 AM
Unzip the egg and toss it in /usr/local/lib/python2.3/site-packages/, then configure the trac.ini as mentioned. If you're running Trac as a FastCGI application (trac.fcgi dispatcher), then be sure to touch trac.fcgi from the shell to ensure the changes are loaded by FastCGI.

MarmaladeMan
08-30-2007, 11:38 AM
I dropped the egg into the folder, but how do I go about installing/unzipping it without easy_install?

Matt
08-30-2007, 11:42 AM
Download and install setuptools (http://peak.telecommunity.com/DevCenter/setuptools) if you haven't already (python setup.py install --prefix=/usr/local/). Don't forget you guys have access to /usr/local/.

Edit: shoot, just run ez_setup.py (http://peak.telecommunity.com/DevCenter/EasyInstall#using-easy-install) and be done with it.

MarmaladeMan
08-30-2007, 01:06 PM
Okay, ez_setup.py ran fine. Now I'm trying to run easy_install (in /usr/local/lib/python2.3/site-packages/) and I'm still getting 'command not found'. I've tried for both the .egg and an easy_install http://svn.edgewall.com/repos/trac/sandbox/webadmin. Any idea what I'm doing wrong?

Matt
08-30-2007, 04:30 PM
Well easy_install's directory would need to be in your PATH variable to run it without the prefix ./ to denote the cwd.
./easy_install
error: No urls, filenames, or requirements specified (see --help)
pwd
/usr/local/lib/python2.3/site-packages

Works fine for me.

MarmaladeMan
09-01-2007, 02:52 AM
Awesome, thanks for the help Matt! I was able to get it running.

I have two questions now:

1) Is it possible/easy for me to switch Trac to run under fcgi? (I'm running cgi currently) Would I need to back up my db's and reconfigure the environments from scratch?

2) -edit- nevermind, resolved it.

MarmaladeMan
09-04-2007, 12:34 PM
For the past day I've been trying to get Trac running again after a failed attempt at switching to the fcgi version. I ran into the same problem as I did way back at the start of this thread (fcgi loading and loading but nothing happens). So I switched back to cgi and tried to recreate the steps I took to getting it working initially, and now nothing is working.

I want to have two project environments, which correspond to two URLs:

/home/marmalademan/trac/mod -> dev.hiprmod.net/trac/mod
/home/marmalademan/trac/code -> dev.hiprmod.net/trac/code

(currently the 'code' one is not configured at all since I can't seem to get the 'mod' one to work)

When I go to dev.hiprmod.net/trac/mod, I just get a blank page. I tried running the standalone tracd server to see if I could get some insight. When I visit dev.hiprmod.net:8000/trac/mod, I get "Environment not found".

I've looked and relooked over everything I can think of:

trac.cgi contains in the appropriate location:
import os
os.environ['TRAC_ENV'] = "/home/marmalademan/trac/mod"

.htaccess contains:
SetEnv TRAC_ENV "/home/marmalademan/trac/mod"
DirectoryIndex trac.cgi

I edit my files in DW with unix-style encoding, then I dos2unix them after uploading just to be sure. Files and directories under the dev subdomain are all owned by user dev. I'm not sure what to do. Thanks for any help!

Matt
09-04-2007, 04:08 PM
A) dos2unix trac.cgi:
[mod]# ./trac.cgi
: bad interpreter: No such file or directory

B) See the Suexec Wiki entry (http://guide.apisnetworks.com/index.php/Suexec). Parent directory cannot be 775.

MarmaladeMan
09-05-2007, 12:43 AM
Well I must say I do feel a little silly about that. Thanks again Matt. :)

So I read the suexec article but I don't understand why 755 works and 775 doesn't. How come a higher permission level breaks it?

Also, I'm trying to run the ScriptAlias directive but I keep getting 500 Internal Server Error. I read about it at the Apache page (http://httpd.apache.org/docs/1.3/mod/mod_alias.html#scriptalias) after reading the Trac manual (http://trac.edgewall.org/wiki/TracCgi). I've tried a few different variations but I keep coming up empty:

(I use this after my SetEnv and DirectoryIndex lines in the Trac document root)
ScriptAlias /trac/mod /home/dev/public_html/trac/mod/trac.cgi

I've also tried:
ScriptAlias /trac/mod/ /home/virtual/site123/fst/home/dev/public_html/trac/mod/trac.cgi

Any idea what's wrong with my syntax? I know we have mod_alias installed - is this possible under our setup?

Matt
09-05-2007, 12:14 PM
775 on the CGI script itself is a bad thing, because anyone in the group could edit the CGI script to inject arbitrary. It executes under the owner's UID and that means bad things could happen to a script with 775 permissions. Therefore it's mandatory to ensure nothing more permissive than 755 with a CGI script. Ensim carried over the check to the parent directory too, which is why you run into problems. Yes, the suexec wrapper is still borrowed from Ensim. When I'll write a replacement suexec wrapper is a good question.

You can't use scriptalias in the .htaccess context (http://httpd.apache.org/docs/2.2/mod/mod_alias.html#scriptalias). Are you looking to do a rewrite on the index? In other words when I access http://dev.hiprmod.net/trac/mod/ it'll access trac.cgi?

That's an easy fix:
RewriteEngine On
RewriteRule ^$ trac.cgi [L]

MarmaladeMan
09-05-2007, 04:27 PM
Ah I see, thanks for the info about suexec and perms, that's helpful.

I'm getting 404'd when I try to access dev.hiprmod.net/trac/mod with that rewriterule, but if I access dev.hiprmod.net/trac/mod/trac.cgi it works fine of course.

Matt
09-05-2007, 04:32 PM
Shoot, I forgot about the rewritebase and sub-directory. This version will work.

RewriteEngine On
RewriteBase /
RewriteRule ^$ /trac/mod/trac.cgi [L]

MarmaladeMan
09-05-2007, 05:16 PM
How does this differ from the DirectoryIndex directive? What I was hoping to accomplish with ScriptAlias was to remove the trac.cgi component of the URL altogether (e.g. dev.hiprmod.net/trac/mod/timeline would deliver dev.hiprmod.net/trac/mod/trac.cgi/timeline).

Matt
09-05-2007, 05:39 PM
They're analogous for that purpose.

MarmaladeMan
09-10-2007, 12:37 AM
Pardon my delayed response, just started school this week. :)

It doesn't work for me. I need the trac.cgi in the URL or else I get 404'd. Simply accessing dev.hiprmod.net/trac/mod/ works fine without trac.cgi (as expected). However, if I want to access the timeline or browser, I have to access /trac/mod/trac.cgi/timeline, etc.

This page (http://trac.edgewall.org/wiki/TracPrettyUrls) has a RewriteRule similar to what you suggested, though I had no more success with that. I may pop by the IRC channel tomorrow during the day in between classes.

Matt
09-11-2007, 04:05 PM
If you'd like to access /trac/mod/browser/, then this should work:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /trac/mod/trac.cgi/$1 [L,QSA]

The problem now would be any requests on that page would use trac.cgi in forming a self-referential URL.

MarmaladeMan
09-30-2007, 05:49 PM
Now for another episode of "Chris Is Horribly Confused" :) Hopefully this is the season finale...

Okay, I have my Trac installs behind a password protected directory. /home/dev/public_html is password protected (set up through esprit). I've read in the Trac docs and on the apis wiki about implementing simple authentication, and I can see that when I browse Trac, it says "logged in as MarmaladeMan". WebAdmin is installed, and while I'm able to browse through the WebAdmin pages, if I try to apply any changes, I get a screen that says "Internal Error" and a little red box that says "No admin pages available".

The authenticating as set up through esprit puts people into groups, whereas the description on the Trac wiki article (http://guide.apisnetworks.com/index.php/Trac) describes authenticating valid-user. Is it important to have it one way over the other?

When I use the htpasswd command, I get "command not found". This occurs when I'm logged in as user dev. I guess I could create the file manually and upload it, but I was curious about why this was happening. Any help? Thanks.

Matt
09-30-2007, 09:24 PM
htpasswd is in /usr/sbin/. You'd need to explicitly give the path, i.e. /usr/sbin/htpasswd instead of just htpasswd. Whenever you encounter an Internal Server Error just check /var/log/httpd/error_log for more information. Also be sure to see this section on authentication (http://guide.apisnetworks.com/index.php/Apache#Secure_Directory_Access).

MarmaladeMan
10-01-2007, 12:50 AM
Hm sorry should have been clearer, the Internal Error was within the Trac interface itself. I should also that it also logs me out when the error displays. Clicking on any other link logs me back in and I'm back at square one. Thanks for the tip on htpasswd, I will try that out tomorrow when I've got some time.

Matt
10-02-2007, 11:31 AM
Drop me a PM with the steps to reproduce the problem and I'll take a look at it.

MarmaladeMan
10-06-2007, 07:49 PM
Just sent the PM now, but it seems I managed to fix the problem. I clicked on "Apply Changes" in the main WebAdmin page without actually having made any changes. Ever since then it's been working a-okay. :) Thanks again for the help Matt.

Kakesu
05-20-2008, 09:32 PM
I've been trying to set up Trac on my site, and have done fairly well so far. I have everything set up, but none of the stylesheets are working - everything is just plain text. I've traced it to that Trac thinks that the stylesheets are located at http://trac.kakesu.org/trac/public/css/, when they are really at http://trac.kakesu.org/trac.fcgi/chrome/common/css/. I can't for the life of me figure out how to change this setting, and am having even more trouble searching the Trac documentation for this, as they seem to have changed all of the documentation over to the new system that is being implemented in Trac 0.11 already. Any thoughts on how I can fix this? I'm at a loss.

Matt
05-20-2008, 09:59 PM
1) Missing: RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /trac.fcgi/$1 [L,QSA]

2) htdocs_location directive was wrong. public/ doesn't exist. You do however have htdocs/. Renamed the htdocs/ symlink to public/

3) All set.

Matt
05-21-2008, 12:13 AM
I have cleaned up the Trac entry (http://guide.apisnetworks.com/index.php/Trac). It should be easier to follow now.

Kakesu
05-23-2008, 03:18 PM
Thank you, Matt. That does indeed look much clearer.

cbergy
09-09-2008, 08:14 PM
Hey all! I'm going to be that guy who bumps this thread.

Been attempting to install Trac all afternoon, and have come really close. Currently, Trac resides in /home/carbonpop/trac, and my subdomain is pointing to /var/www/source.carbonpop.com/

I've made sure (multiple times) that the permissions are set to 755 on both the CGI files and their parent directory. All of the settings for trac.ini and .htaccess have been checked and double-checked. Still running into a 500 Internal Error in the browser.

Here's the various output status codes and errors from executing the .cgi and .fcgi file from the shell:

./trac.cgi

KeyError: 'SERVER_PORT'
Status: 500 Internal Server Error


and:

./trac.fcgi

SGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 Ok


After doing a quick bit of googling on each issue, I find that others who had similar problems nailed it with permissions. Any insight into what could be going wrong?

Thanks!
` Chuck

Matt
09-10-2008, 12:34 AM
You had two issues with your Trac installation:

First- the rewrite rule was incorrect in the wiki. It should read RewriteRule ^(.*)$ /trac.fcgi [L,QSA]

Second- when making a relative symlink, remember to count the ../'s when transversing directories. You went up one too many directories. When the Web server attempted to serve your static content it was outside its filesystem. Your link was parsed as /home/virtual/site1/usr/local... instead of the intended /home/virtual/site1/fst/usr/local...

Symlink creation within the File Manager provides a simple and foolproof way of creating relative symlinks.

cbergy
09-10-2008, 12:20 PM
Yup, that oughta do it! Well, I'm glad it wasn't a permissions issue. And it's always great to stumble upon errors on the wiki so that those documentation errors get ironed out.

I'll be sure to make use of the File Manager's symlink creator from here on in.

Thanks again, Matt!

cbergy
09-10-2008, 02:19 PM
Looks like I've run into one more snag. When I attempt to use the Basic Auth as outlined on the Wiki entry, I receive this in my error log:


[Wed Sep 10 13:13:38 2008] [error] [client *.*.*.*] (2)No such file or directory: Could not open password file: /usr/local/share/trac/passwds/trac.passwd


I've followed the steps listed in Apache's Basic Auth doc, and tried multiple passwd file locations and permission setups on the server. One odd thing was that the /home/virtual/carbonpop.com/home directory (or symlink) did not exist. I attempted to symlink it to /home/carbonpop/ using the File Manager, still with no luck.

Matt
09-10-2008, 03:26 PM
[Wed Sep 10 13:13:38 2008] [error] [client *.*.*.*] (2)No such file or directory: Could not open password file: /usr/local/share/trac/passwds/trac.passwd



Apache directives aren't jailed (http://guide.apisnetworks.com/index.php/Filesystem#Filesystem_Jailing). It should be /home/virtual/carbonpop.com/usr/... or more accurately, /home/virtual/siteNN/fst/usr/... where siteNN is the value derived from the "Site ID" field in the Account Overview (http://guide.apisnetworks.com/index.php/Site_Dashboard#Account_Overview).

cbergy
09-10-2008, 04:03 PM
Ahah, that's the ticket! Worked like a charm.

Thanks Matt!