Bonjour,
Je voulais juste partager avec les membres de la communauté mon expérience sur l'installation de Rails sur Unix. C'est selon moi la partie la plus difficile.
Le développement étant quant à lui un véritable plaisir. En espérant que d'ici peu on aura autant de plaisir à developper qu'à installer et configurer le serveur.
PS : Le tutorial est en anglais mais je suis sûr, ce n'est un problème pour personne ;-)
L'installation du framework Rails est différente de celle décrite sur le site officiel car sur mes serveurs je n'ai pas de connection internet.
J'ai également fait l'install sur mon home directory (pour des tests), à vous de choisir vos directories, bien que je vous conseille d'installer les produits dans les directories standards UNIX.
Bonne chance !
How to install Ruby on Rails (v 1.1.6) and Apache (v 2.0.59) on UNIX
--------------------------------------------------------------------
Packages used :
* ruby-1.8.4.tar.gz
* ruby-oci8-0.1.16.tar.gz
* fcgi-2.4.0.tar.gz
* fcgi-0.8.7.gem
* httpd-2.0.59.tar.gz
* mod_fastcgi-2.4.2.tar.gz
* rubygems-0.9.0.tgz
* actionmailer-1.2.5.gem
* actionpack-1.12.5.gem
* actionwebservice-1.1.6.gem
* activerecord-1.14.4.gem
* activesupport-1.3.1.gem
* rake-0.7.1.gem
* rails-1.1.6.gem
0) Check that a C compile is in the path (such as gcc or cc). Usually it is under /usr/local/bin
1) Install ruby in cd $HOME/ruby
In $HOME, gunzip -c ruby-1.8.4.tar.gz ¦ tar xvf -
cd ruby-1.8.4
./configure --prefix=$HOME/ruby
make
make install
Add ruby executable path ($HOME/ruby/bin) to the PATH environment variable by editing the .profile file
Check that ruby is installed successfully
ruby -v
2) Install gem
In $HOME, gunzip -c rubygems-0.9.0.tgz ¦ tar xvf -
cd rubygems-0.9.0
ruby setup.rb
3) Install rails and its dependencies in this order :
Activesupport
gem install activesupport-1.3.1.gem
Actionpack
gem install actionpack-1.12.5.gem
Actionmailer
gem install actionmailer-1.2.5.gem
Activerecord
gem install activerecord-1.14.4.gem
Actionwebservice
gem install actionwebservice-1.1.6.gem
Rake
gem install rake-0.7.1.gem
Rails
gem install rails-1.1.6.gem
3) Test the rails installation :
Create a test application
mkdir $HOME/rails_apps
cd $HOME/rails_apps
rails test_app
Start the server (WEBrick)
cd test_app
ruby script/server
Open the web browser and go to : http://localhost:3000
If you can see something then rails is successfully installed
4) Install the Oracle Driver
In $HOME, gunzip -c ruby-oci8-0.1.16.tar.gz ¦ tar xvf -
cd ruby-oci8-0.1.16
make
make install
Check that the ORACLE_HOME and the LD_LIBRARY_PATH are defined environment variables
Usually it is something like this :
ORACLE_HOME=/PROD/oradreps/app/oracle/product/9.2.0
LD_LIBRARY_PATH=/PROD/oradreps/app/oracle/product/9.2.0/lib
Test the connection with a database "myDB", a user "myUser" and a password "myPassword"
vi test.rb
Insert in the file the lines
require 'oci8'
OCI8.new('myUser', 'myPassword', 'myDB').exec('select sysdate from dual') do |r| puts r.join(',');
end
Execute the test
ruby test.rb
If the programs displays the current date and time then the Oracle driver is successfully installed
5) Install Apache
In $HOME, gunzip -c httpd-2.0.59.tar.gz ¦ tar xvf -
cd apache-2.0.59
./configure --enable-rewrite --enable-cgi --enable-so --prefix=$HOME/apache
make
make install
6) Install FastCGI
In $HOME, gunzip -c fcgi-2.4.0.tar.gz ¦ tar xvf -
cd fcgi-2.4.0
./configure --prefix=$HOME/fastcgi
make
make install
7) Install mod_fastcgi
In $HOME, gunzip -c mod_fastcgi-2.4.2.tar.gz ¦ tar xvf -
cd mod_fastcgi-2.4.2
cp Makefile.AP2 Makefile
Edit the Makefile and change the "top_dir" variable to point to the Apache install directory $HOME/apache
make
make install
8) Install fcgi gem
gem install fcgi -- --with-fcgi-include=$HOME/fastcgi/include --with-fcgi-lib=$HOME/fastcgi/lib
9) Configure the application server
Edit the server configuration file $HOME/apache/conf/httpd.conf
Replace the line
Listen 80
with the line
Listen 8090
Add the lines
# -------------------
# RoR modifications -
# -------------------
# For CGI
AddHandler cgi-script .cgi
SetEnv ORACLE_HOME /PROD/oradreps/app/oracle/product/9.2.0
# For FastCGI
LoadModule fastcgi_module modules/mod_fastcgi.so
AddHandler fastcgi-script .fcgi
FastCgiConfig -maxClassProcesses 1 -maxProcesses 5 -minProcesses 1 -processSlack 1 -idle-timeout 120 \
-initial-env ORACLE_HOME=/PROD/oradreps/app/oracle/product/9.2.0 \
-initial-env RAILS_ENV=development \
-initial-env RUBYOPT=rubygems
ServerAdmin firstname.lastname@rbcdexia-is.net
DocumentRoot /globalhome2/eg818/rails_apps/test_app/public/
ServerName www.test_app.com
ErrorLog logs/test_app-error_log
CustomLog logs/test_app-access_log common
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
Start the server
In $HOME/apache/bin, apachectl start
10) Configure the application
In $HOME/rails_apps/test_app/public
Check that the files dispatch.rb, dispatch.cgi and dispatch.cgi are 755. If not chmod them.
Edit the files dispatch.rb, dispatch.cgi and dispatch.cgi and update the ruby executable path in the first line
This should be something like :
#!/globalhome2/eg818/ruby/bin/ruby
Edit the file .htaccess and comment the 3 Apache options like this (since they have already been set in the httpd.conf)
# General Apache options
#AddHandler fastcgi-script .fcgi
#AddHandler cgi-script .cgi
#Options +FollowSymLinks +ExecCGI
Test the application with CGI
Go to the app page (http://localhost:8090), the app should display (very slowly...)
Test the application with FastCGI
Edit the file .htaccess and replace the line
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
with the line
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Go to the app page (http://localhost:8090), the app should display (fast !)
11) Cleanup the install directories
rm -r $HOME/ruby-1.8.4
rm -r $HOME/rubygems-0.9.0
rm -r $HOME/ruby-oci8-0.1.16
rm -r $HOME/httpd-2.0.59
rm -r $HOME/fastcgi
rm -r $HOME/mod_fastcgi-2.4.2
12) For debugging problems there are 3 log files
Apache general error log file : $HOME/apache/logs/error_log
Apache application specific error log file : $HOME/apache/logs/test_app-error_log
Application common log files under : $HOME/rails_apps/test_app/log
|
il y a 3 heures 35 min
il y a 3 jours 5 heures
il y a 3 jours 5 heures
il y a 3 jours 10 heures
il y a 3 jours 11 heures
il y a 4 jours 6 heures
il y a 5 jours 6 heures
il y a 5 jours 10 heures
il y a 1 semaine 3 jours
il y a 1 semaine 3 jours