When you're ready to take a LocomotiveCMS site live on the world wide web, you will need a public Engine to push the site too. The hosting requirements for LocomotiveCMS Engine are flexible: it can be hosted on any Unix based server or using service providers like Heroku and Amazon S3. LocomotiveCMS sites can also be hosted easy, zero-setup LocomotiveHosting platform.
Readers looking specifically to host their Engine on Heroku should consult our Heroku guide. Those just looking to setup Engine on their local machine for development purposes should read our Install Engine locally guide.
Since the the exact steps for setting up a LocomotiveCMS Engine in production vary greatly depending on the environment, it is not possible for us to give detailed step by step instructions. But the general steps below for setting up LocomotiveCMS on a Linux server can be adapted to most situations.
1. Setup MongoDB
LocomotiveCMS Engine uses the MongoDB database. The mongoDB database can be hosted on the same server as the Rails app (which you will install later), on a separate server, or through a service, such as MongoLab or MongoHQ.
For instructions on installing MongoDB, please see the MongoDB installtion documentation.
2. Install ImageMagick
On the same server as the Rails app (which you will install later), you need to install ImageMagick, an image manipulation library.
ImageMagick can be installed through your distribution's package manager. For example, yum install ImageMagick
on Red Hat/CentOS or apt-get install imagemagick
on Ubuntu. Of course, you may also choose to compile it from the source.
3. Install Ruby
LocomotiveCMS Engine require Ruby version 1.9.3 or higher. We recommend using LocomotiveCMS with Ruby 2.0.0.
If the version of Ruby offered by your distribution's package manager is sufficient, you may install Ruby through it.
Otherwise, you can install Ruby 2.0.0 with a Ruby version manager like RVM or rbenv.
And of course, you can install Ruby by compiling the source. The Ruby website's installation page does a good job of outlining the various options.
3. Create the Ruby on Rails app
LocomotiveCMS depends on Ruby on Rails version 3.2.x, which you can install with the gem install
command.
gem install rails --version=3.2.19
You will then need to create a Rails app on your server. Use the rails new
command to create a new project.
$ rails new acme_cms --skip-active-record --skip-test-unit --skip-javascript --skip-bundle
$ cd acme_cms
Add the locomotive_cms, compass-rails, and therubyracer gems to the Gemfile. You may also wish puma or unicorn to your Gemfile if you wish to plan to use either in serving your rails app. A sample Gemfile is shown below.
gem 'rails', '3.2.19'
gem 'locomotive_cms', '~> 2.5.6', :require => 'locomotive/engine'
group :assets do
gem 'compass-rails', '~> 0.12.7'
gem 'compass-rails', '~> 2.0.0'
gem 'sass-rails', '~> 3.2.6'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '~> 2.5.1'
gem 'therubyracer', :platforms => :ruby
end
After setting up the Gemfile, run bundle.
$ bundle install
4. Setup LocomotiveCMS
Run the LocomotiveCMS install generator.
$ bundle exec rails g locomotive:install
The output for this command includes instructions on configuration files to edit, which include:
- config/initializers/locomotive.rb
- config/initializers/carrierwave.rb
- config/initializers/dragonfly.rb
- config/mongoid.yml
- config/devise.yml
- config/routes.rb
The default options in the files will be sufficient for many setups. Be sure to update config/mongoid.yml
with the correct host for your database and change the database names to something specific to your app.
The config/initializers/locomotive.rb
file includes many important settings like the default locale, email settings, and settings to activate multisite.
5. Precompile assets
As with any Rails application, you need to precompile the assets when the engine runs within the production environment.
RAILS_ENV=production bundle exec rake assets:precompile
6. Serve the application
Finally, you will need to serve the application itself. When deploying on your own server, the most popular application servers for Rails are Phusion Passenger, Puma, and Unicorn.
If this is your first time deploying a Rails application, checkout the Rails deployment documentation.