UPDATE:I've moved to Mongrel, so the setup has changed.
I'll leave the old installation notes as a reference, but the new installation notes are much different. With these notes, you should be able to set up a flexible, scalable typo installation very quickly.
- Install mongrel.
# gem install -ry mongrel -
Run Mongrel in your typo directory:
# cd (typo_dir)
# mongrel_rails start -d -e production - Set up a new hostname that's a pointer to the webserver. Consult the docs for your DNS server for how to do this.
- setup an Apache virtualhost to redirect to the mongrel server by adding the following lines to httpd.conf
<VirtualHost *:80> ServerAdmin webmaster@example.com DocumentRoot /var/www/html ServerName blog.example.com ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </VirtualHost>This redirects all requests to blog.example.com to the mongrel server on port 3000 - Then, in your root server config add the following two lines.
redirectMatch ^/$ http://blog.example.com/ redirectMatch ^$ http://blog.example.com/This redirects all matches to the root directory of the web server to the virtualhost we''ve created, which, in turn redirects to the mongrel server. - Test your setup as it is. Assuming you've started up your mongrel server, you can hit:
- http://www.example.com:3000
- http://blog.example.com
- http://www.example.com
- Now, you've got your installation setup, you just have to set it up so that mongrel is set up to run at boot. I did this by writing an SysVinit script. Here it is:
#!/bin/bash # chkconfig: 2345 99 01 # description: starts up the typo blog export PATH=$PATH:/usr/local/bin test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions start() { /usr/local/bin/mongrel_rails start -c /home/user/rails/typo --user user --group user -d -e production } stop() { /usr/local/bin/mongrel_rails stop -c /home/user/rails/typo } case "$1" in start) start ;; stop) stop ;; esac
Congratulations, you've got your typo blog running on mongrel! This way, it's well integrated with the rest of your server. and even though I'm running the svn trunk, with these instructions, you can set up the gem version of typo by simply following these instructions after following the installation instructions for typo. I did this mainly because I was unhappy with the performance of fastcgi, and it's poor caching performance, IMHO. When I hit the webserver, the dispatch.fcgi process would pin the cpu for a good 20 seconds.
I had a hell of a time doing this, and it was hell trying to find out how to do this. I ended up using tips and tricks from more pages than I can actually remember, so I thought I'd put this together as a guide, so that hopefully, no-one will have to go through the same thing. Also, I need some tips on this. For this tutorial, I'm going to assume you have rails and apache installed already, and already have some familiarity with both. Don't worry, you don't have to be an expert, but if you need it, the basics are covered elsewhere.
First, install the fastcgi Developer Kit from FastCGI. This step is pretty easy
wget http://fastcgi.com/dist/fcgi.tar.gz
tar zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure && sudo make install- Then install the mod_ fcgid apache module. This step is somewhat experimental, and not as easy as it should be. It's customary to use mod _fastcgi with rails, or at least so I've gathered, but I like the idea behind fcgid. Anyway, enough of my ramblings, lets get to the steps
wget http://fastcgi.coremail.cn/mod_fcgid.1.07.tar.gz
tar -xvzf mod_fcgid.1.07.tar.gz
cd mod_fcgid.1.07
wget http://constant.northnitch.com/~chip/mod_fcgid.1.07-apache2.2.0.patch
patch -p0 < mod_fcgid.1.07-apache2.2.0.patch
- Edit the Makefile to make sure that topdir matches the root directory of your web server. In my case, I had to change the topdir directive from /usr/local/apache2 to /etc/httpd
make install - Next, I'm not sure whether or not this is necessary, but the one document I've read by one of the developers said to do this, so I did. copy .libs/mod_fcgid.so to the modules directory of your apache install.
- Next, make a file in your ServerRoot/conf.d/ called fcgid.conf and put the following contents in it
LoadModule fcgid_module modules/mod_fcgid.so
IPCCommTimeout 40
IPCConnectTimeout 10
DefaultInitEnv RAILS_ENV production
SocketPath /tmp/fcgidsock
Move the typo directory to a place that's accessible to your main apache install, I used "/var/www/html/typo" , and will use this in all my examples, because I have a fedora server, and the web root directory is "/var/www/html", but you can use any directory,
cp -r /path/to/typo/ /var/www/html/typo
rename /var/www/html/typo/public/.htaccess to /var/www/html/typo/htaccess (this step screwed me up for hours)
Make the following changes to your VirtualHost container for the root of the website,
<VirtualHost *:80> #The following 4 lines are specific to your site #don't use these lines ServerAdmin webmaster@example.com DocumentRoot /var/www/html ServerName www.example.com ServerAlias example.com #The following two lines redirect a bare hostname #to the /blog Alias we'll setup later on in the file redirectMatch ^/$ http://www.example.com/blog/ redirectMatch ^$ http://www.example.com/blog/ #Alias the /blog to the real dir Alias /blog "/var/www/html/typo/public/" <Directory "/var/www/html/typo/public"> Options All ExecCGI AllowOverride All Order allow,deny Allow from all AddHandler fcgid-script .fcgi RewriteBase /blog </Directory> <Location /blog> RewriteEngine On # Let apache handle purely static files like images by itself. RewriteCond %{REQUEST_FILENAME} !-f # Send Everything else to Typo RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </Location> </VirtualHost>
