v-hostsディレクトリ内にバーチャルホスト用のコンフィグファイルを作成します。 ここではvirtual.confとします。(ファイル名はXXX.confであれば任意の名称でかまいません) 以下の手順では80番ポートにApacheを利用したまま、8000番ポート、8080番ポートを追加しています。
# cd /opt/csw/apache2/etc/v-hosts # vi virtual.conf
【 記述例 】
★マークの列を環境に合わせて書き換えてください。
下記の例では、サーバ名をexampl.jp、mongrelを5プロセスで起動する例となります。
#===[Setting for Static]=======================================================# <VirtualHost ***.***.***.**:80> ★ ServerName example.jp ★ DocumentRoot /opt/csw/apache2/share/htdocs ★ <Directory /opt/csw/apache2/share/htdocs> ★ Options None AllowOverride All Allow from all </Directory> </VirtualHost> #===[Setting for mongrel]=======================================================# <VirtualHost ***.***.***.**:8000> ★ ServerName example.jp ★ DocumentRoot /var/mongrel/rubricks/public ★ <Directory /var/mongrel/rubricks/public> ★ Options None AllowOverride None Allow from all </Directory> </VirtualHost> #===[Setting for Rubricks]=====================================================# <VirtualHost ***.***.***.**:8080> ★ ServerName example.jp ★ ProxyRequests Off ProxyPass /errors/ http://example.jp:8000/errors/ ★ ProxyPass /images/ http://example.jp:8000/images/ ★ ProxyPass /javascripts/ http://example.jp:8000/javascripts/ ★ ProxyPass /stylesheets/ http://example.jp:8000/stylesheets/ ★ ProxyPass / balancer://rubricks/ timeout=2 ProxyPassReverse / balancer://rubricks/ <Location /> Options None AllowOverride None Allow from all </Location> <Proxy balancer://rubricks/> BalancerMember http://example.jp:3000 loadfactor=20 keepalive=on ★ BalancerMember http://example.jp:3001 loadfactor=20 keepalive=on ★ BalancerMember http://example.jp:3002 loadfactor=20 keepalive=on ★ BalancerMember http://example.jp:3003 loadfactor=20 keepalive=on ★ BalancerMember http://example.jp:3004 loadfactor=20 keepalive=on ★ </Proxy> </VirtualHost>
# cd /opt/csw/apache2/etc/extra # vi main.conf
【 記述例 】
DocumentRoot "/opt/csw/apache2/share/htdocs" ServerRoot "/opt/csw/apache2" Listen xxx.xxx.xxx.xxx:80 Listen xxx.xxx.xxx.xxx:8000 Listen xxx.xxx.xxx.xxx:8080
# vi virtualhostip.conf
NameVirtualHost xxx.xxx.xxx.xxx:80 NameVirtualHost xxx.xxx.xxx.xxx:443 NameVirtualHost xxx.xxx.xxx.xxx:8000 NameVirtualHost xxx.xxx.xxx.xxx:8080
Rubricks公式サイトより、rubricksをダウンロードします。 ここではrubricks-0.6.8.tar.gzを利用します。
# cd /usr/local # wget [ファイルURL]
# tar xvfz rubricks-0.6.8.tar.gz
mongrelインストールディレクトリを作成します。 ここでは/var/mongrelとします。
# mkdir /var/mongrel # chmod 701 /var/mongrel
解凍したrubricksディレクトリをmongrelディレクトリ配下に移動します。
# mv -p rubricks/ /var/mongrel
必要なGemパッケージをインストールします。
# cd /var/mongrel/rubricks # gem install rake # gem install mongrel_cluster # gem update --system
# gem install mongrel
Need to update 26 gems from http://gems.rubyforge.org .......................... complete Select which gem to install for your platform (i386-solaris2.8) 1. mongrel 1.1.4 (ruby) 2. mongrel 1.1.4 (java) 3. mongrel 1.1.4 (x86-mswin32-60) 4. mongrel 1.1.3 (java) 5. mongrel 1.1.3 (i386-mswin32) 6. mongrel 1.1.3 (ruby) 7. Skip this gem 8. Cancel installation
> 1 を入力します。
Install required dependency fastthread? [Yn] y Select which gem to install for your platform (i386-solaris2.8) 1. fastthread 1.0.1 (mswin32) 2. fastthread 1.0.1 (ruby) 3. fastthread 1.0.1 (i386-mswin32) 4. Skip this gem 5. Cancel installation
> 2 を入力します。
Building native extensions. This could take a while... Install required dependency cgi_multipart_eof_fix? [Yn] y Building native extensions. This could take a while... Successfully installed mongrel-1.1.4 Successfully installed fastthread-1.0.1 Successfully installed cgi_multipart_eof_fix-2.5.0 Installing ri documentation for mongrel-1.1.4... Installing ri documentation for fastthread-1.0.1... No definition for dummy_dump No definition for dummy_dump No definition for rb_queue_marshal_load No definition for rb_queue_marshal_dump Installing ri documentation for cgi_multipart_eof_fix-2.5.0... Installing RDoc documentation for mongrel-1.1.4... Installing RDoc documentation for fastthread-1.0.1... No definition for dummy_dump No definition for dummy_dump No definition for rb_queue_marshal_load No definition for rb_queue_marshal_dump Installing RDoc documentation for cgi_multipart_eof_fix-2.5.0...
インストールしたGemパッケージが表示される事を確認してください。
# gem list --local
【 出力結果例 】
*** LOCAL GEMS *** cgi_multipart_eof_fix (2.5.0) daemons (1.0.10) fastthread (1.0.1) gem_plugin (0.2.3) mongrel (1.1.4) mongrel_cluster (1.0.5) rake (0.8.1) rubygems-update (1.1.1) sources (0.0.1)
# cp /var/mongrel/rubricks/config/sample1_environment.rb /var/mongrel/rubricks/config/environment.rb # cp /var/mongrel/rubricks/config/sample1_database.yml /var/mongrel/rubricks/config/database.yml
socket,username,passwordの内容を修正します。
# vi /var/mongrel/rubricks/config/database.yml
【 記述内容例 】
common: &common adapter: mysql host: localhost socket: /tmp/mysql.sock username: root password: *************** encoding: utf8
socket | /tmp/mysql.sock | /opt/csw/mysql5/my.cnfを確認 |
username | root | ご契約時の設定完了メールの、MySQLアクセス情報ユーザー |
password | *** | ご契約時の設定完了メールの、MySQLアクセス情報初期パスワード |
# chown -R webservd:webservd /var/mongrel/rubricks
ここではデータベース名をrubricksとします。
# mysql -u root -p <パスワード> mysql> CREATE DATABASE rubricks; mysql> exit
# export RAILS_ENV=production # rake db:migrate
以下のコマンドで、ポート3000~3004番でmongrelを起動させる設定ファイルが作成されます。 ご自身の環境に合わせて、値を設定してください。
# cd /var/mongrel/rubricks # mongrel_rails cluster::configure -e production -p 3000 -N 5 -c /var/mongrel/rubricks/
# cd /var/mongrel/rubricks # mongrel_rails cluster::start
# cd /var/mongrel/rubricks # mongrel_rails cluster::stop
http://example.jp:8080にアクセスしRubriucksトップページが表示される事を確認します。 管理者ユーザでログインします。 デフォルトの管理者ユーザ、パスワードは以下になります。
ユーザ名 | admin |
パスワード | pass |
管理画面イメージ