From: gander Date: 2005-05-16T03:20:31+09:00 Subject: Re: RoR on WinXP/Apache At Curt's (excellent) request, here's how I got Typo running on WinXP, Apache, with Craig's guidance: Http://localhost ruturned the "Congratulations, you've put Ruby on Rails!" screen. Except, there was no index.html in my typo/public directory, so that "Congrats" page was coming from somewhere else. I had been messing around with the ToDo tutorials, so I suspected it might be the "Congrats" page from ToDo. So I edited ToDo/public/index.html and added some markup to identify this particular "Congrats" page as living in the ToDo/public directory. Back in the browser, I refreshed http://localhost and, lo, I saw the ToDo "Congrats" page. At this point I saw it wasn't a Rails issue, but an Apache issue. In Apache's httpd.conf, I had this, left over from the ToDo tutorial: ServerName todo DocumentRoot /www/webroot/ToDo/public Options ExecCGI FollowSymlinks AllowOverride all Allow from all Order allow,deny So I commented out that block. Whenever you change httpd.conf, you must restart Apache so the new config is loaded. So I restarted Apache. Back in the browser; refresh http://localhost and I get ------------------------------------------ Application error (Apache) 500 Error Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html ------------------------------------------ I knew the typo/public directory had a 500.html file in it, so I edited that file and changed "500 Error" to "Typo: 500 Error." Save the changes. Refresh http://localhost and I get the 500 error again, but this time I see "Typo: 500 Error" so I know Apache is serving the right directory. Now I need to figure out what's causing the 500 error. I thought really, really hard about it. And for a long time. But that didn't work. Not at all. So it then dawned on me to read the log files, which turned out to be much more productive than just thinking. By luck, I started poking around in the typo/log directory looking for the most recently modified file. The file "fastcgi.crash.log" been very recently modified. That fit with the scenario since 500 errors are "web server errors" which means something, typically below the level of code you right for your web site, crashed, choked or blew up. Fastcgi qualifies as something below the level of my code and the name of the file ("fastcgi.crash.log") validated the fact that something went amiss with the process. Opening the log, the first line of the bottom block (the block relevant to the date/time I was now working) showed: ------------------------------------------- [Sat May 14 22:04:19 Eastern Daylight Time 2005] Dispatcher failed to catch: #42000Unknown database 'typo_dev' (Mysql::Error) ------------------------------------------- Unknown database 'typo_dev'? I was using 'ganderson_typo' for my database, no wonder it crashed. So now the question: What in my code said I was using 'typo_dev' as my database (and was ultimately responsible for crashing fastcgi and producing the 500 error)? I didn't know the answer to that question, but I knew that typo/config/database.yaml held info on "my" databases. So I changed "development," "test," and "production" to: database: ganderson_typo I restarted Apache and refreshed http://localhost. BANG! It worked. Later I found the settings for which database is used are in typo/config/environment.rb. I believe when you make changes to this file, you need to restart Apache because, and I may be completely wrong, fastcgi causes some of these config options to be cached by Apache. Changes to such files may not be reflected until the Apache service is restarted. One last thing I forgot to mention: I have this in httpd.conf: ServerName typo DocumentRoot /www/webroot/typo/public Options ExecCGI FollowSymlinks AllowOverride all Allow from all Order allow,deny and I had to remove this line: ServerName typo which left me with this: DocumentRoot /www/webroot/typo/public Options ExecCGI FollowSymlinks AllowOverride all Allow from all Order allow,deny Craig pointed this out in his original response. Now everything is being served out of http://localhost. Can anyone tell me how to serve typo out of http://localhost/typo? I know it's a change in Apache's httpd.conf, I just don't know what to change. Thanks for your help. --George