Install Trac on Dreamhost
I’ve just installed Trac on a sub-domain on Dreamhost. The best information I could find on this is at natmaster.com but the information does have one issue.
The instructions cause the required Python libraries to be installed in two places – some go into lib/python and others into lib/python2.3/site-packages. To make the installation work for me, I needed to add both locations to the PYTHONPATH environment variable in all the locations that define it.
PYTHONPATH=/home/{user}/packages/lib/python2.3/site-packagesbecomes
PYTHONPATH=/home/{user}/packages/lib/python2.3/site-packages:/home/{user}/packages/lib/pythonIt took me an hour to track down the error when running trac-admin.
Also, I did miss some places where the username must be added to the scripts, as I was trying to go too fast.
I’ve given up on Collaboa for this function, as I need to spend time debugging my own code. Running Rails apps on Dreamhost can be tricky, and if the app needs some advanced configuration, like talking to Subversion, then the problems compound to the point where you spend all of your time trying to keep the site running.
SFTP Error with Deprec on Windows
Anyone who’s using Deprec from Windows is likely to run into a problem where they get a strange SFTP StatusException error. The stack looks something like this:
c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/abstract.rb:78:in`do_status':Net::SFTP::Operations::StatusException (4, "Failure") Net::SFTP::Operations::StatusException (4, "Failure"))
from c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:221:in `do_status'The Bug
The bug is in a method called su_put that puts configuration files on the server using sudo. The temporary file name for this process is incorrectly generated if a /tmp directory does not exist on the client. This code should check for the /tmp directory on the server, not the client.
The Workaround
To workaround this, just create a directory called tmp in the root of the drive your project is on.
Ubuntu server on Virtual PC
Earlier this week, I was installing Ubuntu server 6.06 as a virtual machine on Microsoft Virtual PC 2007. When this OS boots, the screen freaks out and goes into a screen resolution that makes it impossible to do anything useful.
If you search for this in Google and others, all the information you find will point you towards X Windows configuration changes. Ubuntu server doesn’t have X Windows installed so none of that information is useful.
The only place I found that was useful was the What Works page for Virtual PC. Here is the relevant section:
At Grub press ESC and edit the kernel line to include the option vga=0×314. To make it permanent edit /boot/grub/menu.lst
So, for bad screen resolution with Ubuntu Server 6.06 on Virtual PC, this one configuration change will make the system usable.
Apache authentication Rails plugin
Do you use Apache to perform your authentication and want to hook this into your Rails app? Me too! I’ve just published a simple plugin that uses the REMOTE_USER variable set by Apache authentication modules to load up your User model and ensure the user is authenticated for the controllers and actions you care about.
Check out the Authenticate As Remote User plugin page for more info.
Action Cache plugin bug fixes
I’ve just checked in three fixes for the action_cache plugin.
- Don’t send cookie headers when serving cached responses (the original response will be untouched)
- Always use 2 cache fragments for action cache entries. This avoids the escape/unescape overhead for the body and speeds cache serving up and reduces the code complexity a little
- Remove use of the returning method. Older versions of Rails don’t have this method.
I’ve also added a specific page to this site for details about the action_cache
Thanks to Paul Haddad and Timur Vafin for bug reports.
My best post on Rails page caching
I was going to write a great post about Rails page caching, but then I found Gregg’s post about page caching
There are two points I’d like to make to add to the Rails page cache knowledge base.
Firstly, if you use paging in your cached actions, then you must use the FileUtils method for sweeping these pages (unless you want to write code that checks for every possible page number and expires that page with expire_page, and you really don’t)
Secondly(?), if you are going to use the FileUtils to remove files from the cache, you don’t need to move the cache location. You only need to move the cache location if you want to delete the entire cache in a single call.
For example, I have code that deletes a paged action, and the cache files are in /public/controller/action/page-number.html and /public/controller/action.html, so FileUtils.rm_rf ”/public/controller/action works for me without changing the cache path.
Rails page caching and monitor services
This evening, I added page caching to a Rails app I’m building. I want to cache the top page of the site (the index action), so I added the caches_page :index to the correct controller.
All was going well until I deployed to a ‘production’ server.
Doing a View/Source on my web page, I see urls that looked like http:// /foo/bar with a space replacing the server name. This isn’t good.
It took me a few minutes of looking at the Rails production log to see that, about every 60 seconds, something was hitting my site without a server name. What hits my site every 60 seconds? Monit does!
For each of my Mongrel instances, I have a monit configuration that contains the line if failed port xxxx protocol http. This technique doesn’t send a server name when it does the test.
Why is this a problem?
Since monit is hitting the root of the web site, the cached url is what gets accessed. Since I have monit hitting the Mongrel instances directly, the page cache is bypassed, and a broken version of the page is generated and cached. Within 60 seconds, my site is broken!
What do I do?
I solved this by adding a ‘heartbeat’ action to my site that renders the text ‘OK’.
def heartbeat
render :text => "OK"
endI now have my monit configured to access the url instead of the port checking. This is also much lighter load than hitting the main page of the site.
if failed url http://127.0.0.1:xxxx/main/heartbeat content == "OK"RedHat clever security system (where 'clever' is stupid)
So I’m getting my Rails app working on Apache on my virtual RedHat server, when something strange happens. The proxy to Mongrel works great and the app is running, but my static files aren’t coming down from the server – no images, CSS or javascript. These should be easy for Apache to serve up – what’s going on?
After looking in the Apache error log, I see that there’s a permission error for those files. No problem, set the flags with chmod and I’ll be onto the next thing.
No such luck.
With some quick Googling of the error, it seems that SELinux may be the issue.
After using the information I found in the documentation I set the new ownership for the static files using chcon and they can now be seen in my browser.
I can see the point of having a beefed-up security system available for an OS, but why on earth was this turned on by default?
Update: I could not get MySQL to start using /etc/init.d/mysql start until I disabled the SELinux system. No useful errors, the process would start and exit immediately.
My Favorite Rails Plugins
Ben has updated his plugin directory to allow you to mark plugins as favorites. I’ve added mine from my previous post on the subject
Ben details what he’s done here
Now if only I could get a list of these plugins as a widget for my sidebar – RSS would work, as Wordpress has a plugin for that.
Ben’s doing real work with OpenID too. Works great in this application (I think its going to take a while for real users to get used to having a URL for their identity, but programmers don’t have that problem)
Fun with Red Hat
I installed Red Hat for the first time this week. I’ve done Debian a number of times, but this was my first go around with the King of Linux. Here’s my thoughts on why Red Hat has yet to achieve world domination.
Use a graphical UI?
During install, you get to pick which packages to install. Under UI, I unchecked all the graphical UI options, cause I want to run a server. On first login after the install, the login system comes up in with a graphical UI.
The fix here is to boot in Single User mode and change a 5 to a 3 in /etc/inittab.
How to login?
During install, I was asked for a root password, but never a user account. At the graphical login prompt, it informs me that root is not allowed to login. Now I have a system I can’t get into. Nice job.
Once again, single user mode comes to the rescue. In single user mode I can use the various tools to create a user and set the password, remembering to unlock the user so they can log in!
Disabled packages run anyway!
The install allowed me to uncheck Sendmail. Silly me for thinking that this would ensure that Sendmail would not run, and might even be left off the disk. But no! Sendmail is installed and running (without any configuration from me, so who knows what mail is flowing)
Good points?
The Red Hat knowledge base did help get me past these issues. When I typed in my query, I always got back a response that moved me forward. I’ve been using Microsoft technologies for 20 years, and their help stuff stopped doing this for me back in 1993.
Which would you use?
Sadly, I have to use Red Hat for a specific project, so I will beat it into submission and bend it to my will! Given a choice, I’d be using Debian for my server.
Next: Install my Rails stack.