======================================================================================================
下載ruby-enterprise到/opt/ror
http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
解壓ruby-enterprise
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
安裝ruby-enterprise
./ruby-enterprise-1.8.7-2010.02/installer
移除舊版ruby
mv /usr/bin/ruby /usr/bin/ruby1.8.7
更新版ruby
------------------------------------------------------------------------------
root用戶登錄修改PATH:
# cd ~
# vi .bash_profile
PATH=$PATH:$HOME/bin:/opt/ruby-enterprise-1.8.7-2010.02/bin
# chown -R oracle /opt/ruby-enterprise-1.8.7-2010.02/
# chown -R oracle /opt/ror/
# chown -R oracle rails_apps/
oracle用戶登錄
$ vi .profile.custom.noninteractive
加入一行:
export PATH=/opt/ruby-enterprise-1.8.7-2010.02/bin:$PATH
------------------------------------------------------------------------------
cp /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby /usr/bin/
cp /opt/ruby-enterprise-1.8.7-2010.02/bin/gem /usr/bin/
ruby -v
gem -v
gem list -l
下載passenger-3.0.2.gem到/opt/ror/gems
http://rubygems.org/downloads/passenger-3.0.2.gem
安裝passenger
gem install passenger-3.0.2.gem -l --no-ri --no-rdoc
再執行一次安裝ruby-enterprise
./ruby-enterprise-1.8.7-2010.02/installer
--------------------------------------------
Ruby Enterprise Edition is successfully installed!
If want to use Phusion Passenger (http://www.modrails.com) in combination
with Ruby Enterprise Edition, then you must reinstall Phusion Passenger against
Ruby Enterprise Edition, as follows:
? /opt/ruby-enterprise-1.8.7-2010.02/bin/passenger-install-apache2-module
Make sure you don't forget to paste the Apache configuration directives that
the installer gives you.
If you ever want to uninstall Ruby Enterprise Edition, simply remove this
directory:
? /opt/ruby-enterprise-1.8.7-2010.02
?
創建可執行文件: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby_with_env
#!/bin/bash
export ORACLE_HOME=/opt/oracle/eesrv/10.2.0/db1
export LD_LIBRARY_PATH=/opt/oracle/otk/1.0/lib/:/opt/oracle/otk/1.0/lib:/opt/oracle/eesrv/10.2.0/db1/lib32:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export SQLPATH=$LD_LIBRARY_PATH
export TNS_ADMIN=/opt/oracle/network
export NLS_LANG=AMERICAN_AMERICA.UTF8
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby $*
======================================================================================================
安裝rails3.0.3
gem install -l --no-ri --no-rdoc rails-3.0.3.gem
??????? actionpack requires activemodel (= 3.0.3, runtime)
??????? activemodel requires builder (~> 2.1.2, runtime)
??????? activemodel requires i18n (~> 0.4, runtime)
??????? actionpack requires rack-test (~> 0.5.6, runtime)
??????? actionpack requires rack-mount (~> 0.6.13, runtime)
??????? actionpack requires tzinfo (~> 0.3.23, runtime)
??????? actionpack requires erubis (~> 2.6.6, runtime)
??????? erubis requires abstract (>= 1.0.0, runtime)
??????? activerecord requires arel (~> 2.0.2, runtime)
??????? actionmailer requires mail (~> 2.2.9, runtime)
??????? mail requires mime-types (~> 1.16, runtime)
??????? mail requires treetop (~> 1.4.8, runtime)
??????? treetop requires polyglot (>= 0.3.1, runtime)
??????? mail requires i18n (~> 0.4.1, runtime)
安裝相關gems
gem install -l --no-ri --no-rdoc haml-3.0.25.gem
gem install -l --no-ri --no-rdoc coderay-0.9.
gem install -l --no-ri --no-rdoc coderay-0.9.6.gem
gem install -l --no-ri --no-rdoc fa
gem install -l --no-ri --no-rdoc faker-0.9.4.gem
gem install -l --no-ri --no-rdoc inploy-1.9.gem
gem install -l --no-ri --no-rdoc will_paginate-
gem install -l --no-ri --no-rdoc will_paginate-3.0.pre2.gem
gem install -l --no-ri --no-rdoc i18n-0.5.0.gem
gem install -l --no-ri --no-rdoc treetop-1.4.9.gem
gem install -l --no-ri --no-rdoc mail-2.2.13.gem
gem install -l --no-ri --no-rdoc arel-2.0.6.gem
gem install -l --no-ri --no-rdoc faker-0.9.2.gem
gem install -l --no-ri --no-rdoc inploy-1.8.gem
gem install -l --no-ri --no-rdoc open4-1.0.1.gem
gem install -l --no-ri --no-rdoc perftools.rb-0.5.4.gem
gem install -l --no-ri --no-rdoc rack-perftools_profiler-0.2.1.gem
gem install -l --no-ri --no-rdoc thor-0.14.6.gem
gem install -l --no-ri --no-rdoc meta_where-0.9.10.gem
Oracle相關gems
gem install -l --no-ri --no-rdoc activerecord-oracle_enhanced-adapter-1.3.2.gem
gem install -l --no-ri --no-rdoc activerecord-oracle_enhanced-adapter-1.3.1.gem
gem install -l --no-ri --no-rdoc ruby-oci8-2.0.4.gem
gem install -l --no-ri --no-rdoc ruby-plsql-0.4.4.gem
gem install -l --no-ri --no-rdoc oracle_enhanced-1.3.2.gem
Netzke相關gems
gem install -l --no-ri --no-rdoc netzke-core-0.6.4.gem
gem install -l --no-ri --no-rdoc netzke-basepack-0.6.2.gem
gem install -l --no-ri --no-rdoc netzke-persistence-0.1.0.gem
#测试
ruby -r oci8 -e "OCI8.new('netzke','practice').exec('select * from users') do |r| puts r.join(',');end"
======================================================================================================
下載Ext JS 3.3.1
http://www.sencha.com/products/js/download.php
unzip ext-3.3.1.zip
======================================================================================================
安裝netzke-demo
# cd /opt
# mkdir rails_apps
# chown oracle rails_apps/
# su - oracle
$ cp netzke-demo.tar.gz /opt/rails_apps/
$ cp netzke-core-v0.6.4-61.tar.gz /opt/rails_apps/
$ cp netzke-basepack-v0.6.2-58.tar.gz /opt/rails_apps/
$ cd /opt/rails_apps
$ tar zxvf netzke-demo.tar.gz
$ tar zxvf netzke-core-v0.6.4-61.tar.gz
$ tar zxvf netzke-basepack-v0.6.2-58.tar.gz
$ mv skozlov-netzke-demo-d88bf76 netzke-demo
$ mv skozlov-netzke-core-4476578 netzke-demo/vendor/plugins/netzke_core
$ mv skozlov-netzke-basepack-94aaf03 netzke-demo/vendor/plugins/netzke_basepack
$ cd netzke-demo
--------------------------------------------------------------------------------
$ vi Gemfile
source 'http://rubygems.org'
gem 'rails', '~>3.0.3'
#gem 'mysql2'
gem 'ruby-oci8', ">= 2.0.4"
gem "activerecord-oracle_enhanced-adapter", "~>1.3.2"
# optionally also use ruby-plsql
gem "ruby-plsql", ">=0.4.4"
gem 'haml'
gem 'coderay'
gem 'faker'
gem 'netzke-core' #, :git => "git://github.com/skozlov/netzke-core.git"
gem 'netzke-basepack' #, :git => "git://github.com/skozlov/netzke-basepack.git"
gem 'netzke-persistence' #, :git => "git://github.com/skozlov/netzke-persistence.git"
gem 'inploy'
gem 'will_paginate', '~>3.0.pre2'
group :profiling do
? gem 'rack-perftools_profiler', '~> 0.1', :require => 'rack/perftools_profiler'
end
--------------------------------------------------------------------------------
Install required gems
$ bundle
$ bundle install
$ bundle show
Gems included by the bundle:
? * abstract (1.0.0)
? * actionmailer (3.0.3)
? * actionpack (3.0.3)
? * activemodel (3.0.3)
? * activerecord (3.0.3)
? * activerecord-oracle_enhanced-adapter (1.3.2)
? * activeresource (3.0.3)
? * activesupport (3.0.3)
? * acts_as_list (0.1.2)
? * arel (2.0.6)
? * builder (2.1.2)
? * bundler (1.0.7)
? * coderay (0.9.6)
? * erubis (2.6.6)
? * faker (0.9.2)
? * haml (3.0.25)
? * i18n (0.5.0)
? * inploy (1.8)
? * mail (2.2.13)
? * meta_where (0.9.10)
? * mime-types (1.16)
? * netzke-basepack (0.6.2)
? * netzke-core (0.6.4)
? * netzke-persistence (0.1.0)
? * open4 (1.0.1)
? * perftools.rb (0.5.4)
? * polyglot (0.3.1)
? * rack (1.2.1)
? * rack-mount (0.6.13)
? * rack-perftools_profiler (0.2.1)
? * rack-test (0.5.6)
? * rails (3.0.3)
? * railties (3.0.3)
? * rake (0.8.7)
? * ruby-oci8 (2.0.4)
? * ruby-plsql (0.4.4)
? * thor (0.14.6)
? * treetop (1.4.9)
? * tzinfo (0.3.23)
? * will_paginate (3.0.pre2)
--------------------------------------------------------------------------------
$ ln -s /opt/ror/ext-3.3.1 public/extjs
$ vi config/database.yml
development: &development
? adapter: oracle_enhanced
? database: test
? username: netzke_demo
? password: practice
test:
? adapter: oracle_enhanced
? database: test
? username: netzke_demo
? password: practice
production:
? adapter: oracle_enhanced
? database: test
? username: netzke_demo
? password: practice
?
$ rake db:create && rake db:migrate
$ rails server
======================================================================================================
運行netzke-demo
http://172.18.60.39:3000/
see the error : uninitialized constant Netzke::Basepack::SimpleApp
replace Netzke::Basepack::SimpleApp as Netzke::Basepack::BorderLayoutPanel
then work.
$ vi app/components/some_simple_app.rb
production需注釋config.serve_static_assets = false
$ rails server -e production
$ vi config/environments/production.rb
? # Disable Rails's static asset server
? # In production, Apache or nginx will already do this
? # config.serve_static_assets = false
======================================================================================================
安裝 nginx
下載安裝prce
http://sourceforge.net/projects/pcre/files/
# tar zxvf pcre-8.11.tar.gz?
# ./configure?
# make?
# make install
下載nginx
http://nginx.org/download/nginx-0.8.53.tar.gz
# tar zxvf nginx-0.8.53.tar.gz
# mkdir nginx
# chown oracle nginx
--------------------------------------------------------------------------------
安裝 passenger-install-nginx-module
$ passenger-install-nginx-module
Welcome to the Phusion Passenger Nginx module installer, v3.0.2.
This installer will guide you through the entire installation process. It
shouldn't take more than 5 minutes in total.
Here's what you can expect from the installation process:
?1. This installer will compile and install Nginx with Passenger support.
?2. You'll learn how to configure Passenger in Nginx.
?3. You'll learn how to deploy a Ruby on Rails application.
Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.
Press Enter to continue, or Ctrl-C to abort.
--------------------------------------------
Checking for required software...
?* GNU C++ compiler... found at /usr/bin/g++
?* The 'make' tool... found at /usr/bin/make
?* A download tool like 'wget' or 'curl'... found at /usr/bin/wget
?* Ruby development headers... found
?* OpenSSL support for Ruby... found
?* RubyGems... found
?* Rake... found at /opt/ruby-enterprise-1.8.7-2010.02/bin/rake
?* rack... found
?* Curl development headers with SSL support... found
?* OpenSSL development headers... found
?* Zlib development headers... found
--------------------------------------------
Automatically download and install Nginx?
Nginx doesn't support loadable modules such as some other web servers do,
so in order to install Nginx with Passenger support, it must be recompiled.
Do you want this installer to download, compile and install Nginx for you?
?1. Yes: download, compile and install Nginx for me. (recommended)
??? The easiest way to get started. A stock Nginx 0.8.53 with Passenger
??? support, but with no other additional third party modules, will be
??? installed for you to a directory of your choice.
?2. No: I want to customize my Nginx installation. (for advanced users)
??? Choose this if you want to compile Nginx with more third party modules
??? besides Passenger, or if you need to pass additional options to Nginx's
??? 'configure' script. This installer will? 1) ask you for the location of
??? the Nginx source code,? 2) run the 'configure' script according to your
??? instructions, and? 3) run 'make install'.
Whichever you choose, if you already have an existing Nginx configuration file,
then it will be preserved.
Enter your choice (1 or 2) or press Ctrl-C to abort: 2
--------------------------------------------
Where is your Nginx source code located?
Please specify the directory: /opt/ror/nginx-0.8.53
--------------------------------------------
Where do you want to install Nginx to?
Please specify a prefix directory [/opt/nginx]:
--------------------------------------------
Extra Nginx configure options
If you want to pass extra arguments to the Nginx 'configure' script, then
please specify them. If not, then specify nothing and press Enter.
If you specify nothing then the 'configure' script will be run as follows:
? sh ./configure --prefix='/opt/nginx' --with-http_ssl_module --add-module='/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/nginx'
Extra arguments to pass to configure script:
--------------------------------------------
Confirm configure flags
The Nginx configure script will be run as follows:
? sh ./configure --prefix='/opt/nginx' --with-http_ssl_module --add-module='/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/nginx'
Is this what you want? (yes/no) [default=yes]:
--------------------------------------------
Nginx with Passenger support was successfully installed.
The Nginx configuration file (/opt/nginx/conf/nginx.conf)
must contain the correct configuration options in order for Phusion Passenger
to function correctly.
This installer has already modified the configuration file for you! The
following configuration snippet was inserted:
? http {
????? ...
????? passenger_root /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2;
????? passenger_ruby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby;
????? ...
? }
After you start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.
Press ENTER to continue.
--------------------------------------------
Deploying a Ruby on Rails application: an example
Suppose you have a Ruby on Rails application in /somewhere. Add a server block
to your Nginx configuration file, set its root to /somewhere/public, and set
'passenger_enabled on', like this:
?? server {
????? listen 80;
????? server_name www.yourhost.com;
????? root /somewhere/public;?? # <--- be sure to point to 'public'!
????? passenger_enabled on;
?? }
And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:
? /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2/doc/Users guide Nginx.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
--------------------------------------------------------------------------------
設置 /opt/nginx/conf/nginx.conf
http {
??? passenger_root /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2;
??? passenger_ruby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby;
??? passenger_default_user oracle;
?? server {
??????? listen?????? 3002;
??????? server_name? 172.18.60.39;
??????? root /opt/rails_apps/netzke-demo/public;
??????? passenger_enabled on;
??????? rails_env development;
?? }
}
--------------------------------------------
設置 start and stop nginx with init script:
git clone git://github.com/xdite/rails-nginx-passenger-centos.git
mv rails-nginx-passenger-centos/nginx/nginx /etc/init.d/nginx
chown root:root /etc/init.d/nginx
/etc/init.d/nginx start
/etc/init.d/nginx status
/etc/init.d/nginx stop
/sbin/chkconfig nginx on
--------------------------------------------
apache/nginx+passenger+ruby+rails+oracle的关键步骤
在配置passenger的时候一定要记住以下一行话:
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.8;
passenger_ruby /usr/local/bin/ruby;
上面两行应该100%的人都加了,但是下面这行,是重中之重:
?passenger_default_user oracle;
这个千万要加上,不然连不上oracle.
--------------------------------------------
OCI Library Initialization Error
http://wiki.github.com/rsim/oracle-enhanced/troubleshooting
Using mod_rails with Rails applications on Oracle
Oracle/OCI libraries could not be loaded: libclntsh.so.10.1: cannot open shared object file: No such file or directory - /usr/local/lib/ruby/site_ruby/1.8/x86_64-linux/oci8lib.so
創建可執行文件: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby_with_env
#!/bin/bash
export ORACLE_HOME=/opt/oracle/eesrv/10.2.0/db1
export LD_LIBRARY_PATH=/opt/oracle/otk/1.0/lib/:/opt/oracle/otk/1.0/lib:/opt/oracle/eesrv/10.2.0/db1/lib32:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export SQLPATH=$LD_LIBRARY_PATH
export TNS_ADMIN=/opt/oracle/network
export NLS_LANG=AMERICAN_AMERICA.UTF8
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby $*
更改配置文件: Apache httpd.conf(nginx nginx.conf)
# passenger_ruby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby;
passenger_ruby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby_with_env;???
======================================================================================================