インストールガイド (CentOS4+Apache+FastCGI)

対象バージョン

当ドキュメントはRubricks-0.5.x向けです。
最新版での動作確認を行っていません。
当ドキュメントは参考情報としてご覧下さい。

CentOS 4.4のインストール情報

IP Address    : 192.168.0.10
Gateway       : 192.168.0.254
Host Name     : rubricks
Package Group : 最小
SELinux       : 無効

不要なデーモンの停止

chkconfig acpid off
chkconfig anacron off
chkconfig apmd off
chkconfig atd off
chkconfig autofs off
chkconfig canna off
chkconfig cups off
chkconfig gpm off
chkconfig haldaemon off
chkconfig iiim off
chkconfig isdn off
chkconfig kudzu off
chkconfig mdmonitor off
chkconfig messagebus off
chkconfig microcode_ctl off
chkconfig netfs off
chkconfig nfslock off
chkconfig openibd off
chkconfig pcmcia off
chkconfig portmap off
chkconfig psacct off
chkconfig rawdevices off
chkconfig readahead off
chkconfig readahead_early off
chkconfig rhnsd off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig sendmail off
chkconfig smartd off
chkconfig xfs off
chkconfig xinetd off

RPMの更新

rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4
yum -y update

shutdown -r now

MySQLの導入

yum -y install mysql mysql-server perl-DBI perl-DBD-MySQL
vi /etc/my.cnf
==[/etc/my.cnf]=============================================
[mysql]
user=root
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8

[mysqladmin]
user=root
socket=/var/lib/mysql/mysql.sock

[mysqld]
user=mysql
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8
datadir=/var/lib/mysql/data
old_passwords=1

[mysql.server]
user=mysql
default-character-set=utf8
basedir=/var/lib/mysql/data

[mysqld_safe]
pid-file=/var/lib/mysql/mysqld.pid
err-log=/var/log/mysqld.log

[client]
default-character-set=utf8

[mysqldump]
default-character-set=utf8
==[/etc/my.cnf]=============================================
mysql_install_db --defaults-file=/etc/my.cnf
chkconfig --level 2345 mysqld on
service mysqld start
mysql
mysql> REVOKE GRANT OPTION on *.* from ''@localhost;
mysql> DROP USER ''@rubricks;
mysql> DROP USER ''@localhost;
mysql> DROP DATABASE test;
mysql> CREATE DATABASE rubricks;
mysql> GRANT ALL ON rubricks.* TO rubricks@localhost;
mysql> CREATE DATABASE rubricks_test;
mysql> GRANT ALL ON rubricks_test.* TO rubricks@localhost;
mysql> EXIT

Ruby/Apache/FCGIの導入

注)
以下の手順で利用するRPMはCentOS公式のものではなく、utaが独自にビルドしたものです。
試用するには手軽ですが、実運用時の利用は推奨致しません。

yum -y install httpd httpd-suexec apr apr-util
vi /etc/yum.repos.d/u-jp.repo
==[/etc/yum.repos.d/u-jp.repo]==========================
[u-jp]
name=CentOS-$releasever - u-jp
baseurl=http://repos.u-jp.com/$basearch/
enabled=1
gpgcheck=0
==[/etc/yum.repos.d/u-jp.repo]==========================

yum -y install fcgi mod_fastcgi ruby rubygems rake ruby-fcgi

vi /etc/httpd/conf/httpd.conf
==[/etc/httpd/conf/httpd.conf]==============================
LoadModule              access_module           modules/mod_access.so
LoadModule              log_config_module       modules/mod_log_config.so
LoadModule              mime_module             modules/mod_mime.so
LoadModule              dir_module              modules/mod_dir.so

ServerRoot              /etc/httpd
DocumentRoot            /var/www/html
PidFile                 /var/run/httpd.pid
User                    apache
Group                   apache
ServerName              192.168.0.10
Listen                  80
ServerSignature         Off
ServerTokens            Prod
DirectoryIndex          index.html
HostnameLookups         Off
TypesConfig             /etc/mime.types
DefaultType             text/plain
AddDefaultCharset       utf-8

<Directory />
    Options             None
    AllowOverride       None
    Deny                from all
</Directory>
<Directory /var/www/html>
    Options             None
    AllowOverride       None
    Allow               from all
</Directory>

Timeout                 300
KeepAlive               On
MaxKeepAliveRequests    10000
KeepAliveTimeout        10
StartServers            8
MinSpareServers         5
MaxSpareServers         20
ServerLimit             256
MaxClients              256
MaxRequestsPerChild     10000

ErrorLog                /var/log/httpd/error.log
LogLevel                error
LogFormat               "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog               /var/log/httpd/access.log combined

#===[Setting for Rails]=========================================================#
LoadModule              alias_module            modules/mod_alias.so
LoadModule              rewrite_module          modules/mod_rewrite.so
LoadModule              fastcgi_module          modules/mod_fastcgi.so
<IfModule mod_fastcgi.c>
    Alias               /rubricks               /var/www/html/rubricks/public/
    FastCgiIpcDir       /tmp/fcgi_ipc/
    AddHandler          fastcgi-script          .fcgi
    <Directory /var/www/html/rubricks/public>
        Options         ExecCGI FollowSymLinks
        AllowOverride   All
        Allow           from all
    </Directory>
</IfModule>
==[/etc/httpd/conf/httpd.conf]==============================
chkconfig --level 2345 httpd on
service httpd start

Setup Rubricks

wget http://rubyforge.org/frs/download.php/xxxxx/rubricks-0.X.X.tar.gz
tar -zxf rubricks-0.X.X.tar.gz -C /var/www/html/
chown -R apache.apache /var/www/html/rubricks
mv /var/www/html/rubricks/config/sample1_database.yml /var/www/html/rubricks/config/database.yml
mv /var/www/html/rubricks/public/dot-htaccess /var/www/html/rubricks/public/.htaccess
vi /var/www/html/rubricks/public/.htaccess
==[/var/www/html/rubricks/public/.htaccess]=================
RewriteEngine   On
RewriteBase     /rubricks
RewriteRule     ^$ index.html [QSA]
RewriteRule     ^([^.]+)$ $1.html [QSA]
RewriteCond     %{REQUEST_FILENAME} !-f
RewriteRule     ^(.*)$ dispatch.fcgi [QSA,L]
==[/var/www/html/rubricks/public/.htaccess]=================

cd /var/www/html/rubricks
export RAILS_ENV=production
rake migrate
ruby script/rubricks_config default_language japanese
chown -R apache.apache /var/www/html/rubricks

Start Rubricks

ブラウザで http://192.168.0.10/rubricks にアクセスすると、Rubricksトップページを開くことができます。
管理者ユーザでログインしてください。デフォルトの管理者のユーザ名及びパスワードは以下の通りです。

ユーザ名'admin'
パスワード'pass'