Ruby installation in linux

Source: Internet
Author: User
Tags nameserver
Linux ruby installation-general Linux technology-Linux programming and kernel information. For more information, see the following. Author: LIMIMGJIE

Ruby installation package
: Http://www.ruby-lang.org/en/downloads/
Ruby-1.8.6-p111.tar.gz
Unzip and install:
Tar-xvzf ruby-1.8.6-p111.tar.gz
Cd ruby-1.8.6-p111
./Configure-prefix =/opt/modules/ruby
Make
Make install
PATH of the operating system:
Export PATH =/opt/modules/ruby/bin: $ PATH

Rails Remote Installation:
Gem: http://rubyforge.org/projects/rubygems/
Unzip and install:
Tar xzvf rubygems-1.0.1.tgz
Cd rubygems-1.0.1/
Ruby setup. rb
Ruby/bin/gem install rails -- remote
Install the mysql_ruby driver
: Http://www.tmtm.org/en/mysql/ruby/
Unzip and install:
Tar-xvzf mysql-ruby-2.7.4.tar.gz
Cd mysql-ruby-2.7.4
Ruby extconf. rb -- with-mysql-dir =/opt/modules/mysql/
Make & make install
Fast-cgi installation:
: Http://www.fastcgi.com/dist/
Unzip and install:
Tar xzvf fcgi-2.4.0.tar.gz
Cd fcgi-2.4.0
./Configure -- prefix =/opt/modules/fcgi
Make & make install
Install the fcgi support library of ruby:
Tar xzvf ruby-fcgi-0.8.7.tar.gz
Cd ruby-fcgi-0.8.7
Ruby install. rb config -- with-fcgi-include =/opt/modules/fcgi/include -- with-fcgi-lib =/opt/modules/fcgi/lib
Ruby install. rb setup
Ruby install. rb install

Lighttpd installation:
: Http://www.lighttpd.net/download/
Note: Check the pcre in linux before installation. The pcre-4.5-3.2.RHEL4 is installed by default in RedHat, which does not support lighttpd.
Two additional rpm, grep-2.5.1-32.2.i386.rpm, and pcre-devel-4.5-3.2.SEL4.i386.rpm must be downloaded,
: Http://scientificlinux.physik.un... 2.5.1-32.2.i386.rpm
: Ftp://ftp.pbone.net/mirror/www.s... 5-3.2.SEL4.i386.rpm

Installation command: rpm-ivh rpm package name

Unzip and install:
Tar xzvf lighttpd-1.4.18.tar.gz
./Configure -- prefix =/opt/modules/lighttpd
Make & make install

Configuration environment:
1. Put the configuration file of lighttpd in/etc/lighttpd/
Cp doc/sysconfig. lighttpd/etc/sysconfig/lighttpd
Mkdir/etc/lighttpd
Cp doc/lighttpd. conf/etc/lighttpd. conf

2. Add the Startup file of the startup server to the user's directory.
Cp doc/rc. lighttpd. redhat/etc/init. d/lighttpd
Edit this file:
LIGHTTPD_BIN =/usr/sbin/lighttpd
Change
LIGHTTPD_BIN =/usr/local/lighttpd/sbin/lighttpd

To enable lighttpd when the server is started:
Chkconfig lighttpd on


Configure Lighttpd

Modify/etc/lighttpd. conf

1) server. modules
Uncomment the module that needs to be used. mod_rewrite, mod_access, mod_fastcgi, mod_simple_vhost, mod_cgi, mod_compress, and mod_accesslog are generally used.

22.16server.doc ument-root, server. error-log, accesslog. filename need to specify the corresponding directory

3) the root user is used by default to run lighttpd.
Server. username = "nobody"
Server. groupname = "nobody"
From the security perspective, it is not recommended to run the web server with the root permission. You can specify the common user permissions on your own.

4) Static File compression
Compress. cache-dir = "/tmp/lighttpd/cache/compress"
Compress. filetype = ("text/plain", "text/html", "text/javascript", "text/css ")
Some static resource types can be specified to be transmitted in compression mode to save bandwidth. for a large number of AJAX applications, the page loading speed can be greatly improved.

Problems encountered during the installation process: (install thread)
1. During rails installation, the installation fails because rails needs to be remotely installed,
Command Prompt:
ERROR: While executing gem... (Gem: RemoteFetcher: FetchError)
Getaddrinfo: Temporary failure in name resolution (SocketError)
Getting size of http://gems.rubyforge.org/Marshal.4.8
The reason is that no DNS is set for this server and the network cannot be accessed externally.
Solution:
#> Vi/etc/resolv. conf
Nameserver 202.106.46.151
Nameserver 202.106.196.115
Nameserver 211.98.2.4
Nameserver 211.98.4.1
2. Install lighttpd, because the original pcre package does not support this service, you need to install a Linux kernel package pcre-devel-4.5-3.2.SEL4.i386.rpm,
But cannot be installed normally.
Command Prompt:
Warning: pcre-devel-4.5-3.2.SEL4.i386.rpm: V3 DSA signature: NOKEY, key ID 652e84dc
Error: Failed dependencies:
Pcre = 4.5-3.2.SEL4 is needed by pcre-devel-4.5-3.2.SEL4.i386

The reason is that the installation package cannot be directly installed. You must install another grep rpm package to install it normally.
Solution:
#> Rpm-ivh grep-2.5.1-32.2.i386.rpm
#> Rpm-ivh pcre-devel-4.5-3.2.SEL4.i386.rpm

3. In the lighttpd configuration, the service cannot be started normally. the startup procedure is as follows:
#>/Etc/init. d/lighttpd status
Command Prompt:
Lighttpd dead but pid file exists
In the configuration process, because the content of the configuration file is not very familiar, you have to compare the configuration that can be run. After debugging, it is found that there are several adjustments,
1) server. pid-file = "/var/run/lighttpd. pid"
This is the PID of the current project;
2) compress. cache-dir = "/opt/modules/lighttpd/compress"
You must manually create a directory. Otherwise, loading will fail!
3) fastcgi. server = (
". Fcgi" => (
"Rails" => (
"Socket" => "/tmp/lighttpd/socket/rails. socket ",
"Bin-path" => "/opt/pptv-data/pptvCMS/public/dispatch. fcgi ",
"Bin-environment" => ("RAILS_ENV" => "development "),
"Min-procs" => 10,
"Max-procs" => 10
)
)
)
The above code is the path of the project to which the service is accessed. This project starts 10 processes and creates 10 rails. socket to ensure that the directory where the socket is created exists.
Whether the physical address of the Project is correct (/opt/pptv-data/pptvCMS/public/dispatch. fcgi ).
4) index-file.names = ("dispatch. fcgi", "index. php", "index.html", "index.htm", "default.htm ")
Add "dispatch. fcgi" as the access page.
5) check whether the first line in public/dispatch. fcgi corresponding to the project is the ruby installation path of the current server.
Ruby installation path:/opt/modules/ruby
The first line in dispatch. fcgi :#! /Opt/modules/ruby/bin/ruby
The files to be modified include: dispatch. cgi, dispatch. rb, and dispatch. fcgi.

4. The lighttpd configuration is correct. The service is started normally and the project cannot be accessed normally:
Command Prompt:
Error access No. 500, the page does not exist,
Cause: In the environment. rb file, you must specify the rails version number,
For example:
RAILS_GEM_VERSION = '1. 2.6 'unless defined? RAILS_GEM_VERSION
Check that the rails version is 2.0.2. Because the development version is 1.2.6, You Need To uninstall the current version 2.0.2 and Install Version 1.2.6.
Solution:
Gem uninstall rails
Gem install rails -- version' = 1.2.6'
Restart the service. Everything is OK.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.