论坛首页 编程语言技术论坛

Rails Linux安装配置全集

浏览 11454 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-04-11  
最近在railscn的群里面总是看到很多朋友希望在linux里面安装rails缺不得其法,我将自己的安装笔记整理了下,包括ubuntu通用安装系列(ruby, ror, mysql, other plugins, etc),apache/mongrel安装,mysql拷贝备份,以及附带的cvs与ftp安装配置。也希望其他朋友有更好的做法能在本贴下留言,解决新手们此类问题。

转发本帖或引用文档,请注明出处。
ye.huang
BLOG: www.yehuang.net
ROR based recommendation Filter/bookmarks:
http://www.nextdoors.info/


Ubuntu common installation
http://www.yehuang.net/archives/30

Apache2 Mongrel-Cluster Configuration
http://www.yehuang.net/archives/31

Mysql Replication
http://www.yehuang.net/archives/60

Ubuntu cvs installation and configuration
http://www.yehuang.net/archives/44

Ubuntu FTP installation
http://www.yehuang.net/archives/47

   发表时间:2007-04-11  
Ubuntu common installation

Notes: The package name mentioned in this document might be out of date when you see it.If you can’t find a proper one or apt-get announce you no such library, please use
$ apt-cache search package-name
to find a available one.

1. Make sure the universe repository in /etc/apt/sources.list is uncommented:
deb http://archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ dapper-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu dapper universe

2. Make sure you are up to date:
$ sudo apt-get update
$ sudo apt-get dist-upgrade

3. Make sure you already have zlib1g(libzlib-ruby) package installed before ruby
./configure and installed.
$ sudo apt-get install build-essential
$ sudo apt-get install gcc
$ sudo apt-get install g++
$ sudo apt-get install libssl0.9.8      (Important!)
$ sudo apt-get install libssl0.9.7
$ sudo apt-get install libssl0.9.8-dbg
$ sudo apt-get install libssl-dev       (Important!)

$ sudo apt-get install zlib1g-dev (NOTE! zlibl”1″g means the number 1, not charactor l)
or
$ sudo apt-get install libzlib-ruby
or if you can’t find a proper libzlib package, search it using
$ apt-cache search libzlib
firstly and install the proper one.

4. We need to grab the latest ruby gems from rubyforge. You may need to modify this command if a version after 0.90 is available.
$ sudo wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
$ tar -xvzf rubygems-0.9.0.tgz
$ cd rubygems-0.9.0
$ sudo ruby setup.rb
$ sudo gem update –system

5. Install the ruby base packages:

Then tar the file, enter /ext, change Setup.x86 file to uncomment #openssl
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5-p12.tar.gz
./configure; make;make test; make install;

Then we could confirm & update
$ sudo apt-get install libzlib-ruby rdoc ri irb ruby1.8-dev

6. Install ruby tool lib.
$ sudo apt-get install libopenssl-ruby
$ sudo apt-get install libgd-ruby1.8 libyaml-ruby libzlib-ruby
$ sudo apt-get install imagemagick

6.1 You might encounter problems while install imagemagick, here’s the details(from http://www.photopost.com/):
____________6.1 start____________

First, if you already tried to install ImageMagick unsuccessfully, you need to uninstall it for this to work properly (trust me, I learned this after installing it 15 times over an old installation). To uninstall ImageMagick, go to your ImageMagick source directory and type:

$ make uninstall

6.1.1. ImageMagick needs a few support libraries to install properly. You can check for the header files in /usr/include and /usr/local/include to see if each library is installed. If you don’t find one or all of them then they will need to be installed.

tiff.h
png.h
jpeglib.h

6.2.2. Download the following files and FTP them (via binary mode) to a directory on your server (in my case, I chose /home/techimo/imagemagick - that’s a temporary directory for the source files):

ImageMagick-6.2.5-5.tar.gz (sudo wget ftp://mirror.aarnet.edu.au/pub/ImageMagick/ImageMagick-6.2.5-5.tar.gz)
jpegsrc.v6b.tar.gz (sudo wget http://www.photopost.com/jpegsrc.v6b.tar.gz)
libpng-1.0.6.tar.gz (sudo wget http://www.photopost.com/libpng-1.0.6.tar.gz)
libtiff-lzw-compression-kit-1.1.tar.gz (sudo wget http://www.photopost.com/libtiff-lzw-compression-kit-1.1.tar.gz)
tiff-v3.5.5.tar.gz (sudo wget http://www.photopost.com/tiff-v3.5.5.tar.gz)

$ gunzip *.gz
Then unpack everything:

$ tar -xvf ImageMagick-6.2.5-5.tar
$ tar -xvf libpng-1.0.6.tar
$ tar -xvf libtiff-lzw-compression-kit-1.1.tar
$ tar -xvf jpegsrc.v6b.tar
$ tar -xvf tiff-v3.5.5.tar

then:
$ cd libpng-1.0.6
$ cd scripts

Now do an “ls” and look for the makefile that matches your operating system. If you can’t find one for your OS, makefile.gcc should work. Copy the makefile to the libpng-1.0.6 directory:

$ cp makefile.linux ../makefile

In the line above, I used makefile.linux, but you should use your appropriate makefile. Continue:

$ cd ..
$ make
$ sudo make install
$ cd ..

$ cd jpeg-6b
$ ./configure –enable-shared
$ make
$ sudo make install
$ cd ..

(For this next part, if you don’t have “pico”, you can use “vi” instead)

$ cd libtiff-lzw-compression-kit
$ pico Makefile

change
TIFF_SRC_DIR = /tmp/libtiff
to
TIFF_SRC_DIR = ../tiff-v3.5.5

Then save and exit the Editor $ make install
$ cd ..
$ cd tiff-v3.5.5
$ ./configure

Answer yes to TIFF Configuration Parameters

$ make
$ sudo make install
$ cd ..

$ cd ImageMagick-6.2.5
$ ./configure –enable-lzw=yes –enable-shared=yes –disable-static –without-perl
$ make
$ sudo make install

That’s it!
____________6.1 end____________

7. Install Rails
$ sudo gem install rails –include-dependencies
$ sudo gem install mongrel –include-dependencies
$ sudo gem install ajax_scaffold_generator
$ sudo gem install redcloth
$ sudo gem install BlueCloth
$ sudo apt-get install build-essential     (To make sure Mongrel could be installed properly)
$ sudo apt-get install libmagick9-dev ruby1.8-dev (You should make sure imagemagick-ruby is already installed: from step 6.1)

Once you encounter problems while installing ‘RMagick’, you can do the following:
———————–
wget http://rubyforge.org/frs/download.php/16684/RMagick-1.15.0.tar.gz
tar this tar.gz file
./configure –enable-allow-example-errors –disable-htmldoc
make
sudo make install

If you wanna it works together with your mongrel, you might tree more steps:
1.$ sudo  cp RMagick.rb & RMagick.so  /usr/local/lib       (if RMagick.rb & RMagick.so does not exist in this path)
2.$ echo /usr/local/lib >> /etc/ld.so.conf(as root)
3.$  ldconfig(as root)
———————–

You can check whether RMagick is installed properly using this:
$ ruby -rrubygems -e “require ‘RMagick’; puts Magick::Long_version;”
If success, the result should be like:

This is RMagick 1.14.1 ($Date: 2006/10/21 13:43:23 $) Copyright (C) 2006 by Timothy P. Hunter
Built with ImageMagick 6.2.5 01/11/07 Q16 http://www.imagemagick.org
Built for ruby 1.8.5 (2006-08-25) [i686-linux]
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org


8. Install Mysql and mysql/ruby lib.
$ sudo apt-get install mysql-server-5.0 libmysql-ruby1.8
$ sudo gem install mysql

8.1 Mysql configure
After mysql installed on Ubuntu, the listen socket port should be changed like this:
$ sudo vi /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/vendor/mysql.rb

Then, change the value of MYSQL_UNIX_ADDR from ‘/tmp/mysql.sock’ into ‘/var/run/mysqld/mysqld.sock’
MYSQL_UNIX_ADDR = “/var/run/mysqld/mysqld.sock”

8.2 You might encounter problems while install ’sudo gem install mysql’, here’s the details:

____________8.2 start____________

If the problem looks like:

error:
Building native extensions.  This could take a while…
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.


It might be lack of some library, please check mkmf.log to find out.
In my case, it tells me lack of ‘lmysqlclient’, so I searched the packages and install some of them:
$ apt-cache search libmysqlclient

libmysqlclient10 - LGPL-licensed client library for MySQL databases
libmysqlclient10-dev - LGPL-licensed client development files for MySQL databases
libmysqlclient12 - mysql database client library
libmysqlclient12-dev - mysql database development files
libmysqlclient14 - mysql database client library
libmysqlclient14-dev - mysql database development files
libmysqlclient15off - mysql database client library


$ sudo apt-get install libmysqlclient14
$ sudo apt-get install libmysqlclient14-dev

____________8.2 end____________
0 请登录后投票
   发表时间:2007-04-11  
Apache2 Mongrel-Cluster Configuration

$ wget http://apache.justdn.org/httpd/httpd-2.2.4.tar.gz
($ sudo apt-get install apache2 is NOT recommended)

$ sudo gem install mongrel –include-dependencies
$ sudo gem install mongrel_cluster –include-dependencies
$ sudo /usr/sbin/adduser -r mongrel (creating a user for mongrel running)

cd httpd-2.2.4
./configure –prefix=/etc/apache2 –enable-cache –enable-mem-cache \
–enable-deflate –enable-proxy –enable-proxy-html –enable-proxy-balancer \
–enable-rewrite –enable-headers –enable-filecache –enable-ssl \

make
make install

–Note
# Apache and mongrel could work together in two ways, single instance and cluster
# We will describe both of them as follows:

1 — single mongrel instance
–enter your application’s path
$ mongrel_rails start -d -p 8000

–enter your apache2 httpd.conf, usually /etc/apache2 , and add these scripts


ServerName localhost
ServerAlias http://localhost

ProxyPass / http://localhost:8000/
ProxyPass /images !
ProxyPass /stylesheets !
#continue with other static files that should be served by apache

#continue with aliases for static content

ProxyPassReverse / http://localhost:8000/
ProxyPreserveHost on
2 — mongrel cluster
$ sudo gem install daemons gem_plugin mongrel mongrel_cluster –include-dependencies
$ sudo /usr/sbin/adduser -r mongrel

$ cd /path/to/yourapps
$ sudo mongrel_rails cluster::configure -e production \
-p 8000 -N 3

[NOTE! please make sure there’re only one mongrel_cluster.yml file in your system.]

You could test now:
—————
$ sudo mongrel_rails cluster::start
$ sudo mongrel_rails cluster::stop
—————

$ sudo mkdir /etc/mongrel_cluster
$ sudo ln -s /path/to/yourapp/config/mongrel_cluster.yml \
/etc/mongrel_cluster/yourapp.yml
$ cd /etc/init.d/
$ sudo cp /usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-0.2.1/resources/mongrel_cluster mongrel_cluster
$ sudo chmod +x /etc/init.d/mongrel_cluster

make sure these configuration is uncommented in httpd.conf
NOTE, if you have these modules buit-in, you may ignore it.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

DocumentRoot /path/to/yourapp/public

Edit httpd.conf:
BalancerMember http://localhost:8000
BalancerMember http://localhost:8001
BalancerMember http://localhost:8002
ServerName yourapp.com
ServerAlias http://yourapp.com
ServerAdmin yourapp@yourapp.com

DocumentRoot “/path/to/yourapp/public”
RewriteEngine On

ProxyPass /images balancer://yourCluster/images

ProxyPass /stylesheets balancer://yourCluster/stysheets
ProxyPass /javascripts balancer://yourCluster/javascripts

ProxyPass / balancer://yourCluster/

ProxyPassReverse / balancer://yourCluster/
ProxyPreserveHost on
0 请登录后投票
   发表时间:2007-04-11  
Ubuntu 6.10下面用apt安装ruby,版本是1.8.4 (2005-12-24),有点旧,不过够用了。

一个问题:Ubuntu将ruby的安装包打散了,分成几个相互依赖的deb包,这样安装倒也没什么不妥,但我用IDEA+Ruby插件时,IDEA提示我需要设置Ruby SDK,我设置到Ubuntu默认的ruby安装目录下/usr/lib/ruby,可是IDEA不干,Google了一圈也没找到特别明确的办法

不得已只好自己从源代码编译一个ruby到/usr/local/ruby,不过这样IDEA就认了,感觉还是源码编译更灵活些
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics