Installing Mint On A Rails Machine
I recently added Shaun Inman’s superb Mint statistics package to my AssetGraphed Rails Machine installation. As the installation wasn’t particularly straightforward, I thought I’d write this little guide for others who may be struggling. I should point out that the real credit for the information here goes to Bradley Taylor from Rails Machine who was extremely helpful and persistent.
First of all, I should point out that these instructions cover installing Mint under your /public directory i.e. yoursite.tld/mint/ rather than the subdomain installation method (mint.yoursite.tld). Also note that β indicates that the line has a break in it in the instructions, but in reality it should all be on one line. With that out of the way, here’s what you need to do:
- Install PHP on your Rails Machine using these instructions. You should have no problems with them if you follow them exactly.
- Log in to your Rails Machine as your deploy user then become root by using
su - rootand entering your root password. - Edit
/etc/httpd/conf/httpd.confand search forDirectoryIndex index.html. Addindex.phpto the end if it’s not present as shown below and save the file:
DirectoryIndex index.html index.php - Edit
/etc/httpd/conf/apps/yourapp.confand add the following immediately after theRewriteEngine Online:
RewriteRule ^/mint/$ /mint/index.php [QSA] - Now find the three lines shown below:
βAnd add the following line immediately before them:
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$β
balancer://yourapp_cluster%{REQUEST_URI} [P,QSA,L]# Don't redirect requests to /mint
RewriteCond %{REQUEST_URI} !^/mint/(.*)$ - The full rewrite rules should look like this:
RewriteEngine On
RewriteRule ^/mint/?$ /mint/index.php [QSA]# Prevent access to .svn directories
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]# Don't redirect requests to /mint
RewriteCond %{REQUEST_URI} !^/mint/(.*)$# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$β
balancer://yourapp_cluster%{REQUEST_URI} [P,QSA,L] - Save the file. It’s probably read-only. If you edited it using vi then you can save it even though it’s read-only by using
:wq! - Finally, restart Apache by using
/sbin/service httpd reloadand log out completely from your Rails Machine.
You can now install Mint itself by adding it to your working copy directory under /public and adding it to your Subversion repository using svn add ./public/mint. Once you’ve deployed to your Rails Machine you’ll be able to complete the Mint installation by visiting http://yoursite.tld/mint/ and following the instructions.
P.S. I have spent the past several hours wrestling with WordPress trying to get the markup in this post to validate, but I have conceded defeat!
30 January 2007 at 4:36 pm
Hi John,
I was curious how you like RailsMachine. I am really impressed with what I have read, but the price point is kind of high.
-Theo
30 January 2007 at 8:20 pm
Hi Theo,
I think they’re great, as I wrote about here: http://www.johntopley.com/2007/01/03/assetsgraphed-on-rails-machine/
Sure, they’re are cheaper Rails hosts out there but it all depends on what you want. I wanted a package that lets me concentrate on development and not have to worry about infrastructure and deployment. I don’t have any complaints about their reliability. Oh and their support has been excellent too.
4 March 2007 at 3:18 am
excellent instructions. many thanks.
29 May 2007 at 7:39 am
I’ve been wondering how to do this for quite a while so many thanks for the detailed instructions.
There’s one inconsistency though. Step 4 says this:
RewriteRule ^/mint/$ /mint/index.php [QSA]
But the summary in step 6 says this:
RewriteRule ^/mint/?$ /mint/index.php [QSA]
Thanks again for writing all this up.
- Andy
29 May 2007 at 9:13 am
Hi Andy,
Good spot - thanks! It should be:
RewriteRule ^/mint/?$ /mint/index.php [QSA]
I’ll update the instructions.
30 May 2007 at 7:14 pm
Hmm, I just went to edit the original article and it turns out that it does have the question mark before the dollar in step four, but for some reason it’s being swallowed by WordPress!