`
gazeldx
  • 浏览: 102215 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Ruby On Rails和locomotiveCMS安装经历

阅读更多

ssh -qTfnN -D 7070 gazeldx@216.194.70.6  zj85..

听robbin说locomotivecms很棒,就下载来试试。我的环境是windows xp.后来在bundle install的过程中,发现有个叫kgio的gem无法正常使用,查资料发现该gem只能在unix-like OS下使用。所以就

安装UBUNTU

安装方法见我写的http://zhangjian1982.iteye.com/blog/1107268

然后要装ruby和rubygems还有rails啦,见http://wiki.rubyonrails.org/getting-started/installation/linux

 

安装ruby

如果用sudo apt-get install ruby -full build-essential这种方式安装到ruby的版本由ubuntu决定,如果自己想指定版本,则通过ftp://ftp.ruby-lang.org/pub/ruby/1.8/下载。

测试用ruby -v和$ ruby -ropenssl -rzlib -rreadline -e "puts :Hello" Will show:Hello

我建议你安装最新版本ruby,见http://www.ruby-lang.org/en/downloads/  我建议你采用rvm的方式安装,详见我的另一篇博文。

sudo apt-get install ruby gems即可。但是这种方法安装会导致rails的命令不能作为命令行直接执行,所以我建议按照rubyonrails.org的官方写法:即http://rubyforge.org/frs/?group_id=126下载,然后解压缩,然后执行 sudo ruby setup.rb

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem, rubygems被装到了/usr/lib/ruby/gems下面。

安装rails

如果用sudo apt-get install rails。测试用rails -h 这种方式会把rails安装到/usr/bin/rails ,安装的版本往往不是rails的最新版本,这是不推荐的。我推荐官方到安装方式:sudo gem install rails ,即通过rubygems安装,这能安装最新版本。

/var/lib/gems/1.8/gems/这是通过sudo apt-get rubygems的安装rails的目标文件夹。
/usr/lib/ruby/gems/1.8/gems/这是通过自己编译ruby setup.rb安装rubygems后安装rails的目标文件夹

 

然后我开始

rails new tweb

报错

bundle install后发现报sqlite3的错误:Installing sqlite3 (1.3.4) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
用sudo apt-get install libsqlite3-dev

和sudo gem install sqlite3-ruby解决

 

 

安装locomotive CMS

按照它官网的方法安装(因为有墙,所以我在文后加上相关内容),安装时如果执行bundle install报错,则执行sudo gem install bundler即可 (look:Bundler is a tool that manages gem dependencies for your ruby application. 后来报错:

 Could not find gherkin-2.5.2 in any of the sources,可能和我使用了rails3.1版本有关。目前locomotivecms是用3.0.10,因为这个问题,我没有安装成功,所以,我们现在必须把版本换到3.0.10,方法见:我之前写的一个文章,你可以搜索RVM http://zhangjian1982.iteye.com/blog/1222579

)。

这时要执行bundle install了。下面两个错误一般都会报,所以如果你打算节省时间,直接解决掉再执行。

*报错nokogiri 。。 native extension libxml2 is missing,用sudo apt-get install libxslt-dev libxml2-dev 解决

*报错Installing rmagick (2.12.2) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/usr/bin/ruby1.8 extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.12.2. Can't find Magick-config in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Can't find Magick-config

解决办法:

sudo apt-get install libmagick9-dev

sudo apt-get install libmagickwand-dev

在Engine installation方法下,bundle exec rails g locomotive:install会报错 :解决办法见本文下面的介绍!

 

bundle exec unicorn_rails启动rails

最后访问http://127.0.0.1:8080/admin OK啦。

 

 

官方安装说明:

Installation guide

Locomotive runs on my different platforms, but it's optimized for the Bushido hosting platform. Bushido enables Locomotive to set subdomains and custom domains directly, launch with built-in email accounts, and provides highly reliable hosting, all with a single click.

We suggest you to start to read the requirements section. Then choose one of the installation methods.
If you want to test Locomotive and sneak into the code, we recommend you the from source installation.

Let us know if you have any suggestions or if you find bugs .

 

Requirements

Ruby

Of course :-)

We tested it with both Ruby 1.8.7 (2009-06-12 patchlevel 174) and Ruby 1.9.2.p0 which are two of Ruby versions Heroku supports.

Please note that performances are much better with Ruby 1.9.2 and the stability seems okay (no bugs found for now).

Mongodb

Locomotive CMS does not use a classic sql database such as mysql or postgresql but rather a nosql database named mongodb.

Mongodb is available on many OS. Check this link out for more information.

Note: We suggest you to take a version from 1.6.0.

ImageMagick

Uploaded images for asset collections are cropped, for example, and Locomotive uses ImageMagick for this purpose. Again, ImageMagick is available on a large set of OS.

Note: On Mac OS X, try Homebrew or MagickInstaller to install it. This will save you a couple of hours because its installation can be really painful sometimes.

Browsers (back-office)

We haven't had time to test the IE versions. So for now, we ask you to use the Locomotive back-office with the following browsers: Safari , Firefox and Chrome

 

From source installation

This way of installing Locomotive is recommended when you want to add new features, correct bugs or see how Locomotive works internally.

1. Get source code from github.

git clone git://github.com/locomotivecms/engine.git locomotive
cd locomotive

2. Install gems.

bundle install

3. Edit the Locomotive settings.

mate config/initializers/locomotive.rb

Note: If you run Locomotive in local and with the multi-sites mode on, do not forget to update your /etc/hosts file accordingly.

By default, Locomotive uses Amazon S3 in production. To change it, modify the carrierwave initialization file.

mate config/initializers/carrierwave.rb

4. You also may want to change your mongodb connection settings.

mate config/mongoid.yml

5. Run the application server.

bundle exec unicorn_rails

6. Open your browser.

open http://localhost:8080/admin

7. Follow the instructions in the browser to create your first account and site.

8. (ONLY IN PRODUCTION ) Push the assets used by the Locomotive back-office to Amazon S3 for better performances.(Jammit-S3 ).

export S3_KEY_ID=<your s3 key id>
export S3_SECRET_KEY=<your s3 secret key>
export S3_BUCKET=<your s3 bucket name>
jammit-s3 --force

If you do not want to push the assets in S3 and instead leave them in your application, remove the lines about S3 in the config/assets.yml file and run the following command:

jammit --force

 

Engine installation

This is probably the cleanest way to build your own comprehensive hosting CMS platform because the Locomotive core cannot be broken and all you need to do is add your own content.

1. First, create a Rails project.

rails new my_platform -O -T -J
cd my_platform
rm public/index.html

2. You have to tell your Rails app that you want to include the Locomotive gem available on Gemcutter. Edit your application Gemfile and add these lines if missing.

gem 'rails', '3.0.10'
gem 'locomotive_cms', :git => 'git://github.com/locomotivecms/engine.git', :require => 'locomotive/engine'
gem 'unicorn', :group => 'development'

3. Install gems

bundle install

4. Add the Locomotive config files and assets

bundle exec rails g locomotive:install

(注意:这句话执行很可能报错rest - client - 1.4 . 2 / lib / restclient . rb : 9 : in `rescue in <top (required)>':

no such file to load -- net/https. Try running apt-get install libopenssl-ruby (LoadError)

解决办法:

sudo apt-get install build - essential bison openssl libreadline5 libreadline5 - dev curl git zlib1g zlib1g - dev libssl - dev libsqlite3 - 0 libsqlite3 - dev sqlite3 libxml2 - dev

 

$ rvm remove 1.9 . 2
$ rvm pkg install openssl

$ rvm install 1.9 . 2 - C -- with - openssl - dir = $HOME /. rvm / usr

)

5. Edit the locomotive settings

mate config/initializers/locomotive.rb

By default, Locomotive uses Amazon S3 in production. To change it, modify the carrierwave initialization file.

mate config/initializers/carrierwave.rb

6. You also may want to change your mongodb connection settings

mate config/mongoid.yml

7. Run the application server

bundle exec unicorn_rails

8. Open your browser

open http://localhost:8080/admin

9. Follow the instructions in the browser to create your first account and site.

10. (ONLY IN PRODUCTION ) Push the assets used by the Locomotive back-office to Amazon S3 for better performances (Jammit-S3 ).

export S3_KEY_ID=<your s3 key id>
export S3_SECRET_KEY=<your s3 secret key>
export S3_BUCKET=<your s3 bucket name>
jammit-s3 --force

If you do not want to push the assets in S3 but leave them in your application instead, remove the lines about S3 in the config/assets.yml file and run the following command

jammit --force  

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics