確認した環境は以下のとおりです:
ここでは RDBMS として MySQL を使用します. また, Gfdnavi は productionモードで動かします.
Gfdnavi本体のインストール
詳しくは Gfdnavi インストーラ使用法 を参照してください. ここでは 以下のように install.rb を実行し, /var/www/rails に Gfdnavi をインストールします.
% ruby install.rb
In order to install Gfdnavi,
there are the following steps.
Step 1: Setup parameters
Step 2: Execute rails and copy files"
Step 3: Create "database.yml" and "gfdnavi.yml"
Step 4: Execute "rake setup"
Step 5: Set root's password
press any key to continue
***************************************
Step 1: Setup parameters
Set destination directory name and copy files.
gfdnavi will be installed to "/path_you_input/gfdnavi"
Please input destination path (default: /home/yourname): /var/www/rails
***
The database settings you will specify in the following will
be written in the file:
/var/www/rails/gfdnavi/config/database.yml
YOU CAN MANUALLY EDIT IT LATER IF YOU LIKE.
You must finish settings of RDBMS before installing gfdnavi unless you
will use "SQLite3". If you have not, use another terminal now to set up
an RDBMS. If you would like to use mysql, I can show you how to do that.
Would you like read the how-to for mysql? (yes/no, default:yes): no
***
If you have finished the settings, specify the RDBMS.
1. MySQL
2. SQLite3
(Sorry, other RDBMSs are not supported in this installation script.)
Select the RDBMS (default:1):
Input the RDB user name for gfdnavi_* databases : davis
Input the password for the databases: hogehero
***
Gfdanvi configuration
***
The gfdnavi settings you will specify in the following will
be written in the file:
/var/www/rails/gfdnavi/config/gfdnavi.yml
YOU CAN MANUALLY EDIT IT LATER IF YOU LIKE.
Set salt for encryption
input phrase (at least 5 characters): pleaseinputyourpassphrase
Set admin's email address
Input email address: yourname@your.email.address
Select server type to set default configuration parameters
The configurations in "config/gfdnavi.yml" will be set according to your choice
of server type.
1. private server
2. open-access server
Select the server type (default:1): 2
Select Rails environment.
When you use Gfdnavi as an open-access server, production environment is strongly recommended.
If you are unsure, you should select development environment.
1. development
2. production
Select environment (default:1): 2
***************************************
Step 2: Execute rails and copy files
/var/www/rails/gfdnavi does not exist.
Can I create the directories? (yes/no, default:yes):
Do you want to install sample data? (yes/no, default:yes):
***************************************
Step 3: Create "database.yml" and "gfdnavi.yml"
***************************************
Step 4: Execute rake setup
(in /var/www/rails/gfdnavi)
Input password for root (number of characters must be 5 to 40):
Repeat password:
== InitialScheme: migrating ===================================================
-- create_table("directories", {:force=>true})
-> 0.0089s
-- create_table("variables", {:force=>true})
-> 0.0019s
-- create_table("actual_files", {:force=>true})
-> 0.0016s
-- create_table("variable_relations", {:force=>true})
-> 0.0012s
-- create_table("keyword_attributes", {:force=>true})
-> 0.0019s
-- create_table("spatial_attributes", {:force=>true})
-> 0.0018s
-- create_table("functions", {:force=>true})
-> 0.0019s
-- create_table("function_outputs", {:force=>true})
-> 0.0015s
-- create_table("types", {:force=>true})
-> 0.0014s
-- create_table("function_arguments", {:force=>true})
-> 0.0015s
-- create_table("users", {:force=>true})
-> 0.0018s
-- create_table("sign_up_users", {:force=>true})
-> 0.0015s
-- create_table("groups", {:force=>true})
-> 0.0016s
-- create_table("group_members", {:force=>true})
-> 0.0012s
-- create_table("diagram_caches", {:force=>true})
-> 0.0706s
-- create_table("diagram_cache_data", {:force=>true})
-> 0.0085s
-- create_table("diagram_cache_sessions", {:force=>true})
-> 0.0021s
== InitialScheme: migrated (0.1122s) ==========================================
== Rel01: migrating ===========================================================
-- create_table("draw_parameters", {:force=>true})
-> 0.0016s
-- create_table("knowledges", {:force=>true})
-> 0.0018s
-- create_table("knowledge_figures", {:force=>true})
-> 0.0014s
-- create_table("query_histories", {:force=>true})
-> 0.0023s
== Rel01: migrated (0.0074s) ==================================================
"/var/www/rails/gfdnavi/public/data" is set as top directory.
..................................................................................................................................................................................
Directory tree search has been completed.
Notice: for analysis of variable relation, parse again. (tentatively).
Directory tree search has been completed.
Congraturations!
You sucessed to install gfdnavi to /var/www/rails/gfdnavi.
Before you start gfdnavi,
change the following configurations
1. "config/database.yml"
2. "config/gfdnavi.yml"
and check file pamissoin mode of their files (only webserver can read the files).
gfdnavi.yml の以下の項目を編集します:
DISPLAY: ":99.0"のコメントを外す (以下に示すように, 行頭のスペースは2つなので注意)
env: DISPLAY: ":99.0" RAILS_ENV: production
以下のコマンドでインストール:
# apt-get install apache2
ここでは設定の詳細は説明しないが, ちょっとだけ補足:
Debian のapache2のお作法は少し特殊で, /etc/apache2/apache2.conf はいじらない.
サイトの定義ファイルは /etc/apache2/sites-available/ 以下に作成し, a2ensite コマンドを使って /etc/apache2/sites-enabled/ 以下にシンボリックリンクをはって有効にする. (無効にするときは a2dissite コマンド)
/etc/apache2/sites-available/default を別の名前(たとえば hoge) でコピーし, 適切に編集して
# a2dissite default # a2ensite hoge # /etc/init.d/apache2 restart
とするのがよいだろう.
なお, モジュールも同様に a2enmod, a2dismod コマンドを使って有効/無効を制御する.
※ Debian では libapache2-mod-fcgid と libapache2-mod-fastcgi の2種類の FastCGI があるが, ここでは libapache2-mod-fcgid を使う.
以下のコマンドでインストール:
# apt-get install libapache2-mod-fcgid libfcgi-ruby1.8
/etc/apache2/mods-available/fcgid.conf を以下のように編集:
<IfModule mod_fcgid.c> AddHandler fcgid-script .fcgi SocketPath /var/lib/apache2/fcgid/sock IPCCommTimeout 300 # <- この行を追加 IPCConnectTimeout 60 # <- この行を追加 </IfModule>
以下のコマンドでモジュールを有効化:
# a2enmod fcgid # a2enmod rewrite
以下の内容で設定ファイル /etc/apache2/sites-available/rails を新規作成:
(ここではlocalhostのみアクセスを許可している. 外部に公開するときは Order, Deny, Allow の各行を適切に変更すればよい. 詳しくは apache の設定方法を別途参照のこと)
<IfModule mod_fcgid.c>
Alias /gfdnavi "/var/www/rails/gfdnavi/public"
<Directory /var/www/rails/gfdnavi/public/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</IfModule>以下のコマンドで設定ファイルを有効化:
# a2ensite rails
以下のコマンドで apache を再起動:
# /etc/init.d/apache2 restart
以下のコマンドでインストール:
# apt-get install xvfb
以下のようにして Xvfbサーバを立ち上げる:
# su - www-data $ Xvfb :99 -screen 0 640x480x8 -nolisten tcp >/dev/null 2>&1 &
※ 上記コマンドがブート時に自動的に実行されるように cron の設定をするとよい.
# crontab -u www-data -e
とするとエディタが立ち上がるので,
@reboot /usr/bin/X11/Xvfb :99 -screen 0 640x480x8 -nolisten tcp >/dev/null 2>&1
と一行書いてセーブ, 終了.
/var/www/rails/gfdnavi/public/.htaccess に以下の変更・追加をする:
#AddHandler fastcgi-script .fcgi # <- コメントアウトする AddHandler fcgid-script .fcgi RewriteBase /gfdnavi #RewriteRule ^(.*)$ dispatch.cgi [QSA,L] # <- コメントアウトする RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
www-data による書き込み権限が必要なディレクトリがいくつかあるので, パーミッションの変更をする:
# chgrp -R www-data /var/www/rails/gfdnavi/tmp # chmod -R g+w /var/www/rails/gfdnavi/tmp # chgrp -R www-data /var/www/rails/gfdnavi/log # chmod -R g+w /var/www/rails/gfdnavi/log # chmod 660 /var/www/rails/gfdnavi/log/*.log # chgrp -R www-data /var/www/rails/gfdnavi/usr # chmod -R g+w /var/www/rails/gfdnavi/usr # chgrp -R www-data /var/www/rails/gfdnavi/public/diagrams # chmod -R g+w /var/www/rails/gfdnavi/public/diagrams
ブラウザで http://localhost/gfdnavi/ にアクセスして動作を確認する.
うまく動作しない場合は, 以下のファイルを見ること:
たいていはこれらのファイルにエラーメッセージが吐かれているので, 手がかりになる.