The production and Running Environments recommended by Ruby on Rails are Linux/FreeBSD/Unix, that is, UNIX operating systems. They use Lighttpd + fcgi solutions. I will take the Linux operating system, Lighttpd + fcgi, MySQL database as an example, from Source code Compilation and installation start. Before installation, ensure that the GCC compiler has been installed in the Linux operating system. Otherwise, use the Linux installation CD to install the GCC compiler first: If gcc-V can return the GCC version number, the GCC is correctly installed.
I. Installation
Ruby
Parser In some Linux releases, the MacOSX operating system comes with a ruby parser, but I still recommend that you download the ruby source by yourself. Code Compile and install. On the one hand, you can customize the path for Ruby installation, and on the other hand, you can add more features during the compilation process. Ruby source code can be downloaded from the ruby Official Website: http://www.ruby-lang.org/en/downloads/ download source code package to the local Linux host, and then extract, enter the directory, configure, compile and install: Tar xzvf ruby-1.8.5.tar.gzcd ruby-1.8.5. /configure-Prefix =/usr/local/rubymake & make install if you want to browse all the configure parameters, you can :. /configure-help | more if you do not customize the installation directory, it will be installed under the/usr/local directory by default. However, we recommend that you customize a ruby installation directory, such as/usr/local/Ruby, to facilitate future upgrades without mixing with other software in the operating system. After the installation, modify the path of the operating system path and add/usr/local/Ruby/bin: Export Path =/usr/local/Ruby/bin: $ path puts our self-installed Ruby in front of the system path to avoid interference caused by the built-in Ruby of the operating system. In Linux, the settings are generally placed in/etc/profile for global effect.
Ii. Installation
Ruby on Rails Before installing rails, install rubygems first. Rubygems is Ruby's online package management tool, which can be downloaded from rubyforge rubygems: http://rubyforge.org/projects/rubygems/download the source code package, uncompress, install: Tar xzvf rubygems-0.9.0.tgzcd/Ruby setup. RB then you can install rails. When you confirm that the server is connected to the Internet, run gem install rails-y to download all the rails dependency packages from the rubyforge website through gem. After installing rails, run rails-V to check the version of rails.
Iii. Installation
Ruby
Database Adapter The rails release package already comes with a MySQL database adapter of pure Ruby. However, for the production environment, we should still download and install the database adapter of Version C to achieve better performance. Download mysql-ruby-2.7.3.tar.gz: http://www.tmtm.org/en/mysql/ruby/tar xzvf mysql-ruby-2.7.3.tar.gzcd extconf. RB -- With-mysql-Dir =/opt/mysql5 make & make install note -- With-mysql-Dir should point to the installation path of the MySQL database, if the database server and web server are not on the same machine, MySQL software must be installed on the Web server, because the ruby C-version MySQL adapter needs to be connected to the MySQL system library during compilation.
Iv. Installation
Ruby
Of
Fcgi
Supported Since the fcgi support library of Ruby needs to be connected to the fcgi system library during compilation, We need to install the fcgi Library first, download the fcgi source code release package: http://www.fastcgi.com/dist/tar xzvf fcgi-2.4.0.tar.gzcd fcgi-2.4.0. /configure -- prefix =/usr/local/fcgimake & make install. Similarly, install fcgi in the specified directory instead of the default/usr/local directory, avoid mixing multiple software. Then you can install rubyfcgi, download ruby-fcgi-0.8.7.tar.gz: http://rubyforge.org/projects/fcgi/tar xzvf ruby-fcgi-0.8.7.tar.gzcd install. RB config -- with-fcgi-include =/usr/local/fcgi/include -- With-fcgi-Lib =/usr/local/fcgi/lib Ruby install. RB setupruby install. RB install
V. Installation
Lighttpd Web Server
Install
Lighttpd Before installing Lighttpd, make sure that PCRE has been installed in the operating system, that is, the perl-Compatible Rule Expression Library: rpm-Qa | grep PCRE. If not, install it on the Linux installation CD. Then download Lighttpd: http://www.lighttpd.net/download/tar xzvf lighttpd-1.4.13.tar.gzcd lighttpd-1.4.13. /configure -- prefix =/usr/local/Lighttpd after configure is completed, a list of activated modules and unactivated modules will be provided. Check the list, whether the required modules have been activated. In the Enable module, you must have "mod_rewrite". Otherwise, re-check whether the PCRE is installed. Then compile and install: Make & make install. After compilation, configure: cp doc/sysconfig. lighttpd/etc/sysconfig/lighttpdmkdir/etc/lighttpdcp DOC/Lighttpd. conf/etc/Lighttpd. conf if your Linux is RedHat/centos, then: cp doc/RC. lighttpd. redHat/etc/init. d/Lighttpd if your Linux is Suse, then: cp doc/RC. lighttpd/etc/init. d/Lighttpd for other Linux distributions, you can modify the file by referring to the file content. Then modify/etc/init. d/Lighttpd: Change lighttpd_bin =/usr/sbin/Lighttpd to lighttpd_bin =/usr/local/Lighttpd/sbin/Lighttpd. This script is used to control the close and restart of Lighttpd: /etc/init. d/Lighttpd start/etc/init. d/Lighttpd stop/etc/init. d/Lighttpd restart if you want to start Lighttpd when the server is started, install Lighttpd like chkconfig Lighttpd on and configure Lighttpd.
Configuration
Lighttpd Modify/etc/Lighttpd. conf 1) The server. Modules cancels the comments of the modules required. mod_rewrite, mod_access, mod_fastcgi, mod_simple_vhost, mod_cgi, mod_compress, and mod_accesslog are generally. 22.16server.doc ument-root, server. Error-log, accesslog. filename need to specify the corresponding directory 3) What permissions should be used to run lighttpdserver. 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) compress static files. 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. 5) The simplest configuration of Ruby on Rails is as follows: $ HTTP ["host"] = "www.xxx.com" {server.doc ument-root = "/yourrails/Public" server. error-Handler-404 = "/dispatch. fcgi "FastCGI. server = (". fcgi "=> ("Localhost" => ("Min-procs" => 10, "Max-procs" => 10, "Socket" => "/tmp/Lighttpd/socket/rails. socket ", "Bin-path" => "/yourrails/public/dispatch. fcgi ", "Bin-Environment" => ("rails_env" => "production ") ) ) )} 10 fcgi processes are started by Lighttpd. The local UNIX socket is used for communication between Lighttpd and fcgi.
Vi. Installation
ImageMagick
And
Rmagic Rmagic is a library required for Ruby image processing. Many Ruby applications often rely on rmagic because it involves image processing functions. However, installing ImageMagick and rmagic is cumbersome and requires special instructions.
Install
ImageMagick Http://www.imagemagick.org ImageMagick is a graph processing library implemented in C language, which has UNIX and Windows versions. For the unix version, installation is more difficult. In addition, it is not recommended to install the ImageMagick binary version, which may lead to the lack of some image processing functions, leading to rmagic installation failure. Download ImageMagick source code, decompress, configure: Tar xzvf ImageMagick-6.2.9-0.tar.gzcd tar xzvf ImageMagick-6.2.9. /configure -- prefix =/usr/local/ImageMagick observe the supported graphic format after the configuration to see if the supported graphic format is yes. If not, then, you must first install the local library in the image format. For example, you should check whether the following RPM package has been installed: rpm-Qa | grep libpngrpm-Qa | grep libpng-develrpm-Qa | grep lib1_rpm-Qa | grep Gd-devel if you want to support the TIFF format, check the rpm-Qa | grep LibTIFF if it is not installed. Find the appropriate RPM package on the Linux installation disc and then configure it again until you confirm that all the required graphic formats are supported, then compile and install: Make & make install. Since imagemagic is installed in the/usr/local/ImageMagick we specify, rmagic cannot find the imagemagic command and library to be used after installation, therefore, you need to configure the operating system: edit the PATH environment variable in/etc/profile, and add: Export Path =/usr/local/Ruby/bin:/us at the end. R/local/ImageMagick/bin: $ PATH edit/etc/lD. so. conf, add:/usr/local/ImageMagick/lib execute the command: ldconfig Add the ImageMagick Library to the system Connection Library and then log off the current user and log on again, so that the environment variable modification takes effect. Execute: convert logo: logo.gif.
Install
Rmagic Compile make & make install: If no error is reported during the configuration and compilation process, it is a success. For MacOSX, the installation of rmagic above will be wrong, please refer to: http://rmagick.rubyforge.org/install-osx.html in general, ImageMagick and rmagic installation is easy to error, installation is more difficult, if you encounter problems that cannot be solved, you can use Google to find a solution.
From: http://www.javaeye.com/topic/43228