October 6th, 2011
LocomotiveCMS has one killer feature for me which makes it beat out RefineryCMS in my books. That feature is the ability to do multi-site. I host websites for many people and have felt the pain of configuring sites by hand for each one of them, plus the extra sever load of running a separate process / instance for each website.
A good multi-site CMS will take care of that pain pretty handily – it means that I can run one instance of the CMS with mulitiple processes. So, my server costs go down and I can ensure that all the sites respond quickly – I don’t have to worry about their instances spinning down and having to spin up again if they are not visited regularly.
Setting it up
LocomotiveCMS doesn’t have great documentation, but their code seems to be really solid. It required me to do a bit of reading between the lines to sort it out. Actually, it was more reading the lines of code but that’s a separate point.
Step 1 – config/initializers
Once you have locomotive running locally (see the installation guide) then you need to modify the initializer to tell it to operate in multi-site mode. The comments will tell you what to do, but this is what I did.
config.multi_sites do |multi_sites| multi_sites.domain = 'local.i' multi_sites.reserved_subdomains = %w(www email blog webmail mail support help site sites) end
This is for a local environment. The reason that I used
local.i was because I want to be able to test this on my development machine. I also removed admin from the list of reserved subdomains.
Step 2 – set up your /etc/hosts (Mac)
Now that the initializer is set, you need to configure your hosts file so that you can access your local server via subdomains using the built-in webserver (e.g. WEBrick)
This is what I added to my hosts file.
127.0.0.1 local.i 127.0.0.1 admin.local.i 127.0.0.1 sub1.local.i
Step 3 – fire up the server and configure
This next step took me a bit to sort out because I had already set up my locomotive config weeks ago. I was trying to switch things into multi-site mode but it wasn’t working. The easiest way for me to do it was to wipe out the db that I had created and visit the site again. If there is no db, it will prompt you to set up a new one from scratch. So, if you already have a locomotive db and you don’t care about the contents, wipe it out and start fresh. if you do care about the contents: back it up, rename it, whatever. I’m not responsible for you wiping out your valued dataHere are the two steps it takes you through:
- create an admin user
- set up a default site
For the default site, I used
name = Awesome Hosting and
subdomain = admin. The subdomain needs to match what you put into your
/etc/hosts file. Make sure you upload the default template
Step 4 – enjoy!
Now if you visit
admin.local.i:3000 you will see your admin site. To administer it, go to
admin.local.i:3000/admin and login with your credentials. From there you can visit
settings -> my account and add new sites with the little (+ new site) button.
There are some oddities here that I’m not 100% comfortable with.
- Why can’t I create the default site with no subdomain? e.g. just
local.ifor the admin site rather than
- Why is adding sites under the obscure location of
settings -> my account? It should be somewhere like
settings -> sites
One thing I just noticed as I finish this write-up is that you can click on the little link it the top menu
switch to another site and you can switch between sites and add new sites from there. That’s cool.
April 28th, 2008
How to Transfer from SQLite to MySQL
I noticed something while working on a couple Radiant sites. I found that when I was building them locally, I prefer to work with SQLite3 databases. Then when I deploy them they use MySQL. Since so much of the configuration and site template lives in the database, I wanted an easy way to go from SQLite to MySQL. In the end I built it!
Wouldn’t it be Nice… to Backup from MySQL to SQLite? And vice-versa?
At the same time, I always thought it would be nice to be able to create a backup of the live database in SQLite. That way, if a client ever wanted their site ‘packaged up and portable’ as it were, it would be easy, just dump the production DB into a SQLite development DB, zip up the radiant folder and you have the whole site ready to run.
My ‘Plugin’ – Installation
I created this as a plugin for Radiant. Just download the package (at the end of this entry), uncompress into your plugins folder and you’re ready to go.
How to Use it
It’s fairly simple. Make sure you have SQLite and MySQL set up and running. Then configure your installation to use a SQLite DB for development and a MySQL DB for production.
development: adapter: sqlite3 database: db/development.sqlite3 production: adapter: mysql database: myradiant_production username: radixhound password: paSSwerd host: localhost
Then make sure your target DB is pre-created. So if you don’t have a production DB up to this point, you can do this.
rake db:migrate rake db:migrate:extensions
Then when you want to transfer from development to production, you can do this…
rake db:backup:to_db TARGET_DB=production
To do the reverse, you will do this…
rake production db:backup:to_db
Or Backup to another SQLite DB altogether…
You can also configure a third, fourth or fifth DB in your database.yml file and use that to back-up to, in case you don’t want to wipe out your development DB. Just add something like this to your database.yml file…
backup: adapter: sqlite3 database: db/development.sqlite3
Then you can do this..
rake production db:backup:to_db TARGET_DB=backup
Download the Goods
PS: I also have a version that works for Mephisto sites. you only get it in zip format ‘cause I have somewhere to be right now.
PPS: I figured this out from someone else’s script that did something similar-ish but not quite this. I don’t remember who or what though, sorry.
August 13th, 2007
I just transferred over from a nice little Mac Mini to a Macbook Pro, and found that my Ruby on Rails installation is goooone. No problem! I’ll just re-install.
I’m following the instructions over at Hivelogic. The only problem with the instructions is that with the rapidly changing world of open source development, it’s bound to be out of date. So, since comments are closed on the article, I’ll just write my own entry with the latest versions as of today.
To get the latest versions, follow the instructions at Hivelogic and I’ll provide updated code to copy and paste only for the sections that have changed.Read the rest of this entry
September 13th, 2006
I recently discovered the Litespeed web server. It turns out to be a very easy way to get Rails apps running, compared with Lighttpd + FCGI or Apache + Mongrel.
I had to try it out and I found that is was certainly much more simple. I especially like the web interface! No more digging around in log files. It’s no slouch when it comes to performance either. It claims to be the fastest option because it is all written in C++.
The only thing that I am looking into now is how much memory usage it takes. I’m finding that it’s using up nearly all of my 256MB of RAM for just one rails app with sqlite3.
Check out this great resource for getting up and running fast using Litespeed.
August 2nd, 2006
I was just watching the keynote address from RailsConf 2006. I have to say that I am always impressed with the lucidity of David Heinemeier Hansson’s thought when it comes to making technology make sense. He definitely has a gift. On the other hand, his approach is so simple that it seems silly that no one did it before.
One of the keys to his genius is being revealed in this talk. That key is that belief comes before understanding.Read the rest of this entry
August 1st, 2006
I’m going to blast of a flurry of blogging starting with Ruby on Rails news in Vancouver. Last week I attended a mini workshop on getting started on Rails.
I was amazed to see a room full of people in Vancouver listening to a presentation about Ruby on Rails. It makes sense, since Vacouver was the host of the first ever Rails Conference. There’s just a huge difference in going from being a Rails fanboy gazing through your LCD looking glass at this marvelous world and being actually in and among people who are into Rails.
I didn’t manage to meet any of the people there except for Nathaniel Brown , the presenter, because I had to navigate the maze that was UBC and get back home to my family. Still I hope to meet more of the Vancouver Ruby community and get out there and spread the excitement about Rails.