Ruby on Rails
RailsOnCentos (Version #77)

Note This guide will help you install ruby on rails on centos 4.2 with apache2 acting as a proxy for lighttpd. This guide may and probably does have errors. Please feel free to correct them!

1. Install Ruby

Need to install the testing repository so add this to the /etc/yum.repos.d/ That will allow you to rock ruby 1.8.4


# packages in testing
[testing]
name=CentOS-$releasever - Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing


#yum update
#yum install ruby ruby-devel ruby-libs irb rdoc ruby-mysql

(uncommented)


yum update yum install ruby ruby-devel ruby-libs irb rdoc ruby-mysql

(or, updated 1.8.5 version of irb and rdoc can be installed as follows)

yum update yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql

2. Install lighttpd

Lighttpd and lighttpd-fcgi are in dag repository. Add it to the /etc/yum.repos.d/.

You may also need to import the Dag GPG key.

http://dag.wieers.com/home-made/apt/FAQ.php#B2

or, this works, too:

rpm --import</code> <a href="http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt">http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt</a>

#Dag
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1


#yum update
#yum install lighttpd-fastcgi lighttpd

For checkinstall method (builds a simple rpm)


yum install checkinstall

(uncommented)

yum update yum install lighttpd-fastcgi lighttpd

3. Get Gem


#cd /usr/local/src
#wget </code><tt><a href="http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz">http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz</a></tt>

(uncommented)


cd /usr/local/src wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz

4. Install Gem


#tar -xvzf rubygems-0.9.2.tgz
#cd rubygems-0.9.2
#ruby setup.rb
cd ..

(uncommented)


tar -xvzf rubygems-0.9.2.tgz cd rubygems-0.9.2 ruby setup.rb cd ..

5. Install fast-cgi

Checkinstall method (builds an RPM)


cd /usr/local/src
wget </code><tt><a href="http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz">http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz</a></tt></code>
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
checkinstall # Chose the rpm settings and create docs if you like
rpm -Uvh /usr/src/redhat/RPMS/i386/fcgi-2.4.0-1.i386.rpm
cd ..

Without checkinstall:


#cd /usr/local/src
#wget </code><tt><a href="http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz">http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz</a></tt><code>
#tar xzvf fcgi-2.4.0.tar.gz
#cd fcgi-2.4.0
#./configure
#make
#make install
#cd ..

(uncommented)


cd /usr/local/src wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz

tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
cd ..

6. Install fast-cgi Bindings


#cd /usr/local/src
#wget </code><tt><a href="http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz">http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz</a></tt><code>
#tar zxvf ruby-fcgi-0.8.6.tar.gz
#cd ruby-fcgi-0.8.6
#ruby install.rb config
#ruby install.rb setup 
#ruby install.rb install
#cd ..

(uncommented)


cd /usr/local/src wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz tar zxvf ruby-fcgi-0.8.6.tar.gz cd ruby-fcgi-0.8.6 ruby install.rb config ruby install.rb setup ruby install.rb install cd ..

7. Install Rails


#gem install rails --include-dependencies

(uncommented)


gem install rails --include-dependencies

If it doesn’t work, you even tried
http://onestepback.org/index.cgi/Tech/Ruby/DeleteYourCache.red
then try


gem install rails

and say “Y” when it askes to “Install required dependency *”
h2. Config Files


Add this to /etc/httpd/conf/httpd.conf


<VirtualHost *:80> ServerName ruby.werd.local ProxyRequests Off ProxyPass / http://ruby.werd.local:81/ ProxyPassReverse / http://ruby.werd.local:81 ProxyPreserveHost on


Complete example /etc/lighttpd/lighttpd.conf file:

You will need to set your own directory for the webroot to live in and run rails someapp to generate the application directories specified in the configuration file. Of course, you should tune this to match your settings (as well as the virtual host settings for Apache.)


server.port = 81
#server.bind = "0.0.0.0"
server.modules = (
        "mod_rewrite",
        "mod_access",
        "mod_fastcgi",
        "mod_accesslog"
)
server.indexfiles = (
        "dispatch.fcgi",
        "index.php",
        "index.html",
        "index.htm",
        "default.htm"
)
server.pid-file = "/tmp/lighttpd.pid"
url.access-deny = ( "~", ".inc" )

mimetype.assign = (
        ".rpm"          =>      "application/x-rpm",
        ".pdf"          =>      "application/pdf",
        ".sig"          =>      "application/pgp-signature",
        ".spl"          =>      "application/futuresplash",
        ".class"        =>      "application/octet-stream",
        ".ps"           =>      "application/postscript",
        ".torrent"      =>      "application/x-bittorrent",
        ".dvi"          =>      "application/x-dvi",
        ".gz"           =>      "application/x-gzip",
        ".pac"          =>      "application/x-ns-proxy-autoconfig",
        ".swf"          =>      "application/x-shockwave-flash",
        ".tar.gz"       =>      "application/x-tgz",
        ".tgz"          =>      "application/x-tgz",
        ".tar"          =>      "application/x-tar",
        ".zip"          =>      "application/zip",
        ".mp3"          =>      "audio/mpeg",
        ".m3u"          =>      "audio/x-mpegurl",
        ".wma"          =>      "audio/x-ms-wma",
        ".wax"          =>      "audio/x-ms-wax",
        ".ogg"          =>      "application/ogg",
        ".wav"          =>      "audio/x-wav",
        ".gif"          =>      "image/gif",
        ".jpg"          =>      "image/jpeg",
        ".jpeg"         =>      "image/jpeg",
        ".png"          =>      "image/png",
        ".xbm"          =>      "image/x-xbitmap",
        ".xpm"          =>      "image/x-xpixmap",
        ".xwd"          =>      "image/x-xwindowdump",
        ".css"          =>      "text/css",
        ".html"         =>      "text/html",
        ".htm"          =>      "text/html",
        ".js"           =>      "text/javascript",
        ".asc"          =>      "text/plain",
        ".c"            =>      "text/plain",
        ".cpp"          =>      "text/plain",
        ".log"          =>      "text/plain",
        ".conf"         =>      "text/plain",
        ".text"         =>      "text/plain",
        ".txt"          =>      "text/plain",
        ".dtd"          =>      "text/xml",
        ".xml"          =>      "text/xml",
        ".mpeg"         =>      "video/mpeg",
        ".mpg"          =>      "video/mpeg",
        ".mov"          =>      "video/quicktime",
        ".qt"           =>      "video/quicktime",
        ".avi"          =>      "video/x-msvideo",
        ".asf"          =>      "video/x-ms-asf",
        ".asx"          =>      "video/x-ms-asf",
        ".wmv"          =>      "video/x-ms-wmv",
        ".bz2"          =>      "application/x-bzip",
        ".tbz"          =>      "application/x-bzip-compressed-tar",
        ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
)

server.document-root = "/home/applications/devo/public/"
server.errorlog = "/home/applications/devo/log/lighttpd_error.log"
accesslog.filename = "/home/applications/devo/log/lighttpd_access.log"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
        ".fcgi" => (
                "rails" => (
                        "socket" => "/tmp/lighttpd-fcgi.socket",
                        "bin-path" =>
                                "/home/applications/devo/public/dispatch.fcgi",
                        "bin-environment" => ( "RAILS_ENV" => "production" ),
                        "min-procs" => 2,
                        "max-procs" => 2
                )
        )
)

Note

Don’t forget to do


chkconfig lighttpd on
service lighttpd start
service httpd restart

Problems?

Often problems are due to a misconfiguration of Apache or lighttpd. Lighttpd will look like it started okay even if there is a problem, which can lead to some confusion. Running service lighttpd status will help you to determine if things are okay there. If you get a message like: lighttpd dead but subsys locked Something is wrong. Check very carefully that all of the paths are correct (and that they exist) in the configuration file.

Credits

thanks to dadro

mods to doc and some fixes by LeahCunningham

Note This guide will help you install ruby on rails on centos 4.2 with apache2 acting as a proxy for lighttpd. This guide may and probably does have errors. Please feel free to correct them!

1. Install Ruby

Need to install the testing repository so add this to the /etc/yum.repos.d/ That will allow you to rock ruby 1.8.4


# packages in testing
[testing]
name=CentOS-$releasever - Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing


#yum update
#yum install ruby ruby-devel ruby-libs irb rdoc ruby-mysql

(uncommented)


yum update yum install ruby ruby-devel ruby-libs irb rdoc ruby-mysql

(or, updated 1.8.5 version of irb and rdoc can be installed as follows)

yum update yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql

2. Install lighttpd

Lighttpd and lighttpd-fcgi are in dag repository. Add it to the /etc/yum.repos.d/.

You may also need to import the Dag GPG key.

http://dag.wieers.com/home-made/apt/FAQ.php#B2

or, this works, too:

rpm --import</code> <a href="http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt">http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt</a>

#Dag
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1


#yum update
#yum install lighttpd-fastcgi lighttpd

For checkinstall method (builds a simple rpm)


yum install checkinstall

(uncommented)

yum update yum install lighttpd-fastcgi lighttpd

3. Get Gem


#cd /usr/local/src
#wget </code><tt><a href="http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz">http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz</a></tt>

(uncommented)


cd /usr/local/src wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz

4. Install Gem


#tar -xvzf rubygems-0.9.2.tgz
#cd rubygems-0.9.2
#ruby setup.rb
cd ..

(uncommented)


tar -xvzf rubygems-0.9.2.tgz cd rubygems-0.9.2 ruby setup.rb cd ..

5. Install fast-cgi

Checkinstall method (builds an RPM)


cd /usr/local/src
wget </code><tt><a href="http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz">http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz</a></tt></code>
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
checkinstall # Chose the rpm settings and create docs if you like
rpm -Uvh /usr/src/redhat/RPMS/i386/fcgi-2.4.0-1.i386.rpm
cd ..

Without checkinstall:


#cd /usr/local/src
#wget </code><tt><a href="http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz">http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz</a></tt><code>
#tar xzvf fcgi-2.4.0.tar.gz
#cd fcgi-2.4.0
#./configure
#make
#make install
#cd ..

(uncommented)


cd /usr/local/src wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz

tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
cd ..

6. Install fast-cgi Bindings


#cd /usr/local/src
#wget </code><tt><a href="http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz">http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz</a></tt><code>
#tar zxvf ruby-fcgi-0.8.6.tar.gz
#cd ruby-fcgi-0.8.6
#ruby install.rb config
#ruby install.rb setup 
#ruby install.rb install
#cd ..

(uncommented)


cd /usr/local/src wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz tar zxvf ruby-fcgi-0.8.6.tar.gz cd ruby-fcgi-0.8.6 ruby install.rb config ruby install.rb setup ruby install.rb install cd ..

7. Install Rails


#gem install rails --include-dependencies

(uncommented)


gem install rails --include-dependencies

If it doesn’t work, you even tried
http://onestepback.org/index.cgi/Tech/Ruby/DeleteYourCache.red
then try


gem install rails

and say “Y” when it askes to “Install required dependency *”
h2. Config Files


Add this to /etc/httpd/conf/httpd.conf


<VirtualHost *:80> ServerName ruby.werd.local ProxyRequests Off ProxyPass / http://ruby.werd.local:81/ ProxyPassReverse / http://ruby.werd.local:81 ProxyPreserveHost on


Complete example /etc/lighttpd/lighttpd.conf file:

You will need to set your own directory for the webroot to live in and run rails someapp to generate the application directories specified in the configuration file. Of course, you should tune this to match your settings (as well as the virtual host settings for Apache.)


server.port = 81
#server.bind = "0.0.0.0"
server.modules = (
        "mod_rewrite",
        "mod_access",
        "mod_fastcgi",
        "mod_accesslog"
)
server.indexfiles = (
        "dispatch.fcgi",
        "index.php",
        "index.html",
        "index.htm",
        "default.htm"
)
server.pid-file = "/tmp/lighttpd.pid"
url.access-deny = ( "~", ".inc" )

mimetype.assign = (
        ".rpm"          =>      "application/x-rpm",
        ".pdf"          =>      "application/pdf",
        ".sig"          =>      "application/pgp-signature",
        ".spl"          =>      "application/futuresplash",
        ".class"        =>      "application/octet-stream",
        ".ps"           =>      "application/postscript",
        ".torrent"      =>      "application/x-bittorrent",
        ".dvi"          =>      "application/x-dvi",
        ".gz"           =>      "application/x-gzip",
        ".pac"          =>      "application/x-ns-proxy-autoconfig",
        ".swf"          =>      "application/x-shockwave-flash",
        ".tar.gz"       =>      "application/x-tgz",
        ".tgz"          =>      "application/x-tgz",
        ".tar"          =>      "application/x-tar",
        ".zip"          =>      "application/zip",
        ".mp3"          =>      "audio/mpeg",
        ".m3u"          =>      "audio/x-mpegurl",
        ".wma"          =>      "audio/x-ms-wma",
        ".wax"          =>      "audio/x-ms-wax",
        ".ogg"          =>      "application/ogg",
        ".wav"          =>      "audio/x-wav",
        ".gif"          =>      "image/gif",
        ".jpg"          =>      "image/jpeg",
        ".jpeg"         =>      "image/jpeg",
        ".png"          =>      "image/png",
        ".xbm"          =>      "image/x-xbitmap",
        ".xpm"          =>      "image/x-xpixmap",
        ".xwd"          =>      "image/x-xwindowdump",
        ".css"          =>      "text/css",
        ".html"         =>      "text/html",
        ".htm"          =>      "text/html",
        ".js"           =>      "text/javascript",
        ".asc"          =>      "text/plain",
        ".c"            =>      "text/plain",
        ".cpp"          =>      "text/plain",
        ".log"          =>      "text/plain",
        ".conf"         =>      "text/plain",
        ".text"         =>      "text/plain",
        ".txt"          =>      "text/plain",
        ".dtd"          =>      "text/xml",
        ".xml"          =>      "text/xml",
        ".mpeg"         =>      "video/mpeg",
        ".mpg"          =>      "video/mpeg",
        ".mov"          =>      "video/quicktime",
        ".qt"           =>      "video/quicktime",
        ".avi"          =>      "video/x-msvideo",
        ".asf"          =>      "video/x-ms-asf",
        ".asx"          =>      "video/x-ms-asf",
        ".wmv"          =>      "video/x-ms-wmv",
        ".bz2"          =>      "application/x-bzip",
        ".tbz"          =>      "application/x-bzip-compressed-tar",
        ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
)

server.document-root = "/home/applications/devo/public/"
server.errorlog = "/home/applications/devo/log/lighttpd_error.log"
accesslog.filename = "/home/applications/devo/log/lighttpd_access.log"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
        ".fcgi" => (
                "rails" => (
                        "socket" => "/tmp/lighttpd-fcgi.socket",
                        "bin-path" =>
                                "/home/applications/devo/public/dispatch.fcgi",
                        "bin-environment" => ( "RAILS_ENV" => "production" ),
                        "min-procs" => 2,
                        "max-procs" => 2
                )
        )
)

Note

Don’t forget to do


chkconfig lighttpd on
service lighttpd start
service httpd restart

Problems?

Often problems are due to a misconfiguration of Apache or lighttpd. Lighttpd will look like it started okay even if there is a problem, which can lead to some confusion. Running service lighttpd status will help you to determine if things are okay there. If you get a message like: lighttpd dead but subsys locked Something is wrong. Check very carefully that all of the paths are correct (and that they exist) in the configuration file.

Credits

thanks to dadro

mods to doc and some fixes by LeahCunningham