2011年12月26日月曜日

CentOS6.2 インストールパッケージ(2)

CentOS6.2のサーバタイプ「Minimal」でインストール後のOSのパッケージ一覧を中心に記載してみる。

即行でつまづいたのは、「Minimal」はipv6がデフォルトになっており、リモート接続すらできない。(T-T)
まずはipv6を無効にし、ipv4のIPアドレスを設定するところから…。

■ipv6無効
⇒/etc/modprobe.d/dist.conf の最下行に "alias net-pf-10 off"と追記してOS再起動。

[root@centos62 ~]# vi /etc/modprobe.d/dist.conf
[root@centos62 ~]# tail /etc/modprobe.d/dist.conf
alias rpc_svc_gss_pipefs sunrpc

install eth1394 /bin/true

install snd-emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 && /sbin/modprobe snd-emu10k1-synth

alias gre0 ip_gre
alias char-major-89-* i2c-dev

alias net-pf-10 off
[root@centos62 ~]#


■ipv4設定
[root@centos62 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@centos62 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="00:0C:29:xx:xx:25"
NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO=static
BROADCAST=192.168.xxx.255
IPADDR=192.168.xxx.143
NETMASK=255.255.255.0
NETWORK=192.168.xxx.0
[root@centos62 ~]#
↑3行目以降を追記した。

⇒本来は下記のようにネットワークインターフェースを再起動したいところだが、接続が切れるだけなのでヤメ。
[root@centos62 ~]# ifconfig eth0 down
[root@centos62 ~]# ifconfig eth0 up

⇒ipv6無効化の設定反映も兼ねてOS再起動。
[root@centos62 ~]# reboot

⇒OS再起動後にipv4のIPアドレスが設定されていることを確認。
[root@centos62 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:xx:xx:25
          inet addr:192.168.xxx.143  Bcast:192.168.xxx.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:xxxx:7825/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:262 errors:0 dropped:0 overruns:0 frame:0
          TX packets:233 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:26236 (25.6 KiB)  TX bytes:31968 (31.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centos62 ~]#


■rpmでインストールパッケージ確認
[root@centos62 ~]# rpm -qa | wc -l
250
[root@centos62 ~]# rpm -qa | sort
ConsoleKit-0.4.1-3.el6.x86_64
ConsoleKit-libs-0.4.1-3.el6.x86_64
MAKEDEV-3.24-6.el6.x86_64
acl-2.2.49-6.el6.x86_64
aic94xx-firmware-30-2.el6.noarch
atmel-firmware-1.3-7.el6.noarch
attr-2.4.44-7.el6.x86_64
audit-2.1.3-3.el6.x86_64
audit-libs-2.1.3-3.el6.x86_64
authconfig-6.1.12-5.el6.x86_64
b43-openfwwf-5.2-4.el6.noarch
basesystem-10.0-4.el6.noarch
bash-4.1.2-8.el6.centos.x86_64
bfa-firmware-3.0.0.0-1.el6.noarch
binutils-2.20.51.0.2-5.28.el6.x86_64
boost-1.41.0-11.el6_1.2.x86_64
boost-date-time-1.41.0-11.el6_1.2.x86_64
boost-filesystem-1.41.0-11.el6_1.2.x86_64
boost-graph-1.41.0-11.el6_1.2.x86_64
boost-iostreams-1.41.0-11.el6_1.2.x86_64
boost-program-options-1.41.0-11.el6_1.2.x86_64
boost-python-1.41.0-11.el6_1.2.x86_64
boost-regex-1.41.0-11.el6_1.2.x86_64
boost-serialization-1.41.0-11.el6_1.2.x86_64
boost-signals-1.41.0-11.el6_1.2.x86_64
boost-system-1.41.0-11.el6_1.2.x86_64
boost-test-1.41.0-11.el6_1.2.x86_64
boost-thread-1.41.0-11.el6_1.2.x86_64
boost-wave-1.41.0-11.el6_1.2.x86_64
bzip2-1.0.5-7.el6_0.x86_64
bzip2-libs-1.0.5-7.el6_0.x86_64
ca-certificates-2010.63-3.el6_1.5.noarch
centos-release-6-2.el6.centos.7.x86_64
checkpolicy-2.0.22-1.el6.x86_64
chkconfig-1.3.47-1.el6.x86_64
coreutils-8.4-16.el6.x86_64
coreutils-libs-8.4-16.el6.x86_64
cpio-2.10-9.el6.x86_64
cracklib-2.8.16-4.el6.x86_64
cracklib-dicts-2.8.16-4.el6.x86_64
cronie-1.4.4-7.el6.x86_64
cronie-anacron-1.4.4-7.el6.x86_64
crontabs-1.10-33.el6.noarch
curl-7.19.7-26.el6_1.2.x86_64
cyrus-sasl-2.1.23-13.el6.x86_64
cyrus-sasl-lib-2.1.23-13.el6.x86_64
dash-0.5.5.1-3.1.el6.x86_64
db4-4.7.25-16.el6.x86_64
db4-utils-4.7.25-16.el6.x86_64
dbus-1.2.24-5.el6_1.x86_64
dbus-glib-0.86-5.el6.x86_64
dbus-libs-1.2.24-5.el6_1.x86_64
device-mapper-1.02.66-6.el6.x86_64
device-mapper-event-1.02.66-6.el6.x86_64
device-mapper-event-libs-1.02.66-6.el6.x86_64
device-mapper-libs-1.02.66-6.el6.x86_64
dhclient-4.1.1-25.P1.el6.x86_64
dhcp-common-4.1.1-25.P1.el6.x86_64
diffutils-2.8.1-28.el6.x86_64
dracut-004-256.el6.noarch
dracut-kernel-004-256.el6.noarch
e2fsprogs-1.41.12-11.el6.x86_64
e2fsprogs-libs-1.41.12-11.el6.x86_64
efibootmgr-0.5.4-9.el6.x86_64
eggdbus-0.6-3.el6.x86_64
elfutils-libelf-0.152-1.el6.x86_64
ethtool-2.6.33-0.3.el6.x86_64
expat-2.0.1-9.1.el6.x86_64
file-libs-5.04-11.el6.x86_64
filesystem-2.4.30-3.el6.x86_64
findutils-4.4.2-6.el6.x86_64
fipscheck-1.2.0-7.el6.x86_64
fipscheck-lib-1.2.0-7.el6.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
gamin-0.1.10-9.el6.x86_64
gawk-3.1.7-6.el6.x86_64
gdbm-1.8.0-36.el6.x86_64
glib2-2.22.5-6.el6.x86_64
glibc-2.12-1.47.el6.x86_64
glibc-common-2.12-1.47.el6.x86_64
gmp-4.3.1-7.el6.x86_64
gnupg2-2.0.14-4.el6.x86_64
gpgme-1.1.8-3.el6.x86_64
grep-2.6.3-2.el6.x86_64
groff-1.18.1.4-21.el6.x86_64
grub-0.97-75.el6.x86_64
grubby-7.0.15-2.el6.x86_64
gzip-1.3.12-18.el6.x86_64
hwdata-0.233-7.6.el6.noarch
info-4.13a-8.el6.x86_64
initscripts-9.03.27-1.el6.centos.x86_64
ipa-gothic-fonts-003.02-4.2.el6.noarch
ipa-mincho-fonts-003.02-3.1.el6.noarch
ipa-pgothic-fonts-003.02-4.1.el6.noarch
ipa-pmincho-fonts-003.02-3.1.el6.noarch
iproute-2.6.32-17.el6.x86_64
iptables-1.4.7-4.el6.x86_64
iptables-ipv6-1.4.7-4.el6.x86_64
iputils-20071127-16.el6.x86_64
ipw2100-firmware-1.3-11.el6.noarch
ipw2200-firmware-3.1-4.el6.noarch
ivtv-firmware-20080701-20.2.noarch
iwl100-firmware-39.31.5.1-1.el6.noarch
iwl1000-firmware-39.31.5.1-1.el6.noarch
iwl3945-firmware-15.32.2.9-4.el6.noarch
iwl4965-firmware-228.61.2.24-2.1.el6.noarch
iwl5000-firmware-8.83.5.1_1-1.el6_1.1.noarch
iwl5150-firmware-8.24.2.2-1.el6.noarch
iwl6000-firmware-9.221.4.1-1.el6.noarch
iwl6000g2a-firmware-17.168.5.3-1.el6.noarch
iwl6000g2b-firmware-17.168.5.2-1.el6.noarch
iwl6050-firmware-41.28.5.1-2.el6.noarch
kbd-1.15-11.el6.x86_64
kbd-misc-1.15-11.el6.noarch
kernel-2.6.32-220.el6.x86_64
kernel-firmware-2.6.32-220.el6.noarch
keyutils-libs-1.4-3.el6.x86_64
krb5-libs-1.9-22.el6.x86_64
less-436-10.el6.x86_64
libacl-2.2.49-6.el6.x86_64
libattr-2.4.44-7.el6.x86_64
libblkid-2.17.2-12.4.el6.x86_64
libcap-2.16-5.5.el6.x86_64
libcap-ng-0.6.4-3.el6_0.1.x86_64
libcom_err-1.41.12-11.el6.x86_64
libcurl-7.19.7-26.el6_1.2.x86_64
libdrm-2.4.25-2.el6.x86_64
libertas-usb8388-firmware-5.110.22.p23-3.1.el6.noarch
libffi-3.0.5-3.2.el6.x86_64
libgcc-4.4.6-3.el6.x86_64
libgcrypt-1.4.5-9.el6.x86_64
libgpg-error-1.7-4.el6.x86_64
libicu-4.2.1-9.el6.x86_64
libidn-1.18-2.el6.x86_64
libnih-1.0.1-7.el6.x86_64
libselinux-2.0.94-5.2.el6.x86_64
libselinux-utils-2.0.94-5.2.el6.x86_64
libsemanage-2.0.43-4.1.el6.x86_64
libsepol-2.0.41-4.el6.x86_64
libss-1.41.12-11.el6.x86_64
libssh2-1.2.2-7.el6_1.1.x86_64
libstdc++-4.4.6-3.el6.x86_64
libudev-147-2.40.el6.x86_64
libusb-0.1.12-23.el6.x86_64
libuser-0.56.13-4.el6_0.1.x86_64
libutempter-1.1.5-4.1.el6.x86_64
libuuid-2.17.2-12.4.el6.x86_64
libxml2-2.7.6-4.el6.x86_64
logrotate-3.7.8-12.el6_0.1.x86_64
lua-5.1.4-4.1.el6.x86_64
lvm2-2.02.87-6.el6.x86_64
lvm2-libs-2.02.87-6.el6.x86_64
m4-1.4.13-5.el6.x86_64
matahari-0.4.4-11.el6.x86_64
matahari-agent-lib-0.4.4-11.el6.x86_64
matahari-broker-0.4.4-11.el6.x86_64
matahari-host-0.4.4-11.el6.x86_64
matahari-lib-0.4.4-11.el6.x86_64
matahari-network-0.4.4-11.el6.x86_64
matahari-service-0.4.4-11.el6.x86_64
matahari-sysconfig-0.4.4-11.el6.x86_64
mingetty-1.08-5.el6.x86_64
module-init-tools-3.9-17.el6.x86_64
mysql-libs-5.1.52-1.el6_0.1.x86_64
ncurses-5.7-3.20090208.el6.x86_64
ncurses-base-5.7-3.20090208.el6.x86_64
ncurses-libs-5.7-3.20090208.el6.x86_64
net-tools-1.60-109.el6.x86_64
newt-0.52.11-3.el6.x86_64
newt-python-0.52.11-3.el6.x86_64
nspr-4.8.8-3.el6.x86_64
nss-3.12.10-16.el6.x86_64
nss-softokn-3.12.9-11.el6.x86_64
nss-softokn-freebl-3.12.9-11.el6.x86_64
nss-sysinit-3.12.10-16.el6.x86_64
nss-util-3.12.10-2.el6.x86_64
openldap-2.4.23-20.el6.x86_64
openssh-5.3p1-70.el6.x86_64
openssh-server-5.3p1-70.el6.x86_64
openssl-1.0.0-20.el6.x86_64
pam-1.1.1-10.el6.x86_64
passwd-0.77-4.el6.x86_64
pciutils-libs-3.1.4-11.el6.x86_64
pcre-7.8-3.1.el6.x86_64
pinentry-0.7.6-6.el6.x86_64
plymouth-0.8.3-24.el6.centos.x86_64
plymouth-core-libs-0.8.3-24.el6.centos.x86_64
plymouth-scripts-0.8.3-24.el6.centos.x86_64
policycoreutils-2.0.83-19.18.el6.x86_64
polkit-0.96-2.el6_0.1.x86_64
popt-1.13-7.el6.x86_64
postfix-2.6.6-2.2.el6_1.x86_64
procps-3.2.8-21.el6.x86_64
psmisc-22.6-15.el6_0.1.x86_64
pth-2.0.7-9.3.el6.x86_64
pygpgme-0.1-18.20090824bzr68.el6.x86_64
python-2.6.6-29.el6.x86_64
python-iniparse-0.3.1-2.1.el6.noarch
python-libs-2.6.6-29.el6.x86_64
python-pycurl-7.19.0-8.el6.x86_64
python-urlgrabber-3.9.1-8.el6.noarch
ql2100-firmware-1.19.38-3.1.el6.noarch
ql2200-firmware-2.02.08-3.1.el6.noarch
ql23xx-firmware-3.03.27-3.1.el6.noarch
ql2400-firmware-5.06.02-1.el6.noarch
ql2500-firmware-5.06.02-1.el6.noarch
qpid-cpp-client-0.12-6.el6.x86_64
qpid-cpp-client-ssl-0.12-6.el6.x86_64
qpid-cpp-server-0.12-6.el6.x86_64
qpid-cpp-server-ssl-0.12-6.el6.x86_64
qpid-qmf-0.12-6.el6.x86_64
readline-6.0-3.el6.x86_64
redhat-logos-60.0.14-10.el6.centos.noarch
rootfiles-8.1-6.1.el6.noarch
rpm-4.8.0-19.el6.x86_64
rpm-libs-4.8.0-19.el6.x86_64
rpm-python-4.8.0-19.el6.x86_64
rsyslog-4.6.2-12.el6.x86_64
rt61pci-firmware-1.2-7.el6.noarch
rt73usb-firmware-1.8-7.el6.noarch
sed-4.2.1-7.el6.x86_64
selinux-policy-3.7.19-126.el6.noarch
selinux-policy-targeted-3.7.19-126.el6.noarch
setup-2.8.14-13.el6.noarch
shadow-utils-4.1.4.2-13.el6.x86_64
sigar-1.6.5-0.4.git58097d9.el6.x86_64
slang-2.2.1-1.el6.x86_64
sqlite-3.6.20-1.el6.x86_64
sudo-1.7.4p5-7.el6.x86_64
system-config-firewall-base-1.2.27-5.el6.noarch
sysvinit-tools-2.87-4.dsf.el6.x86_64
tar-1.23-3.el6.x86_64
tcp_wrappers-libs-7.6-57.el6.x86_64
tzdata-2011l-4.el6.noarch
udev-147-2.40.el6.x86_64
upstart-0.6.5-10.el6.x86_64
ustr-1.0.4-9.1.el6.x86_64
util-linux-ng-2.17.2-12.4.el6.x86_64
vim-minimal-7.2.411-1.6.el6.x86_64
vlgothic-fonts-20091202-2.el6.noarch
vlgothic-fonts-common-20091202-2.el6.noarch
vlgothic-p-fonts-20091202-2.el6.noarch
which-2.19-6.el6.x86_64
xorg-x11-drv-ati-firmware-6.14.2-7.el6.noarch
xz-libs-4.999.9-0.3.beta.20091007git.el6.x86_64
yum-3.2.29-22.el6.centos.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-plugin-fastestmirror-1.1.30-10.el6.noarch
zd1211-firmware-1.4-4.el6.noarch
zlib-1.2.3-27.el6.x86_64
[root@centos62 ~]#


■runlevel別のサービス起動設定
[root@centos62 ~]# chkconfig --list
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:off
matahari-broker 0:off   1:off   2:off   3:off   4:off   5:off   6:off
matahari-host   0:off   1:off   2:off   3:off   4:off   5:off   6:off
matahari-network        0:off   1:off   2:off   3:off   4:off   5:off   6:off
matahari-service        0:off   1:off   2:off   3:off   4:off   5:off   6:off
matahari-sysconfig      0:off   1:off   2:off   3:off   4:off   5:off   6:off
messagebus      0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
qpidd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
restorecond     0:off   1:off   2:off   3:off   4:off   5:off   6:off
rsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:off
saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
udev-post       0:off   1:on    2:on    3:on    4:on    5:on    6:off
[root@centos62 ~]# 
さすがminimal。インストールされているサービスはかなり少ないようです。


■ディスク使用状況
[root@centos62 ~]# df -m
Filesystem           1M-ブロック    使用   使用可 使用% マウント位置
/dev/mapper/vg_centos62-lv_root
                          7599       739      6474  11% /
tmpfs                      499         0       499   0% /dev/shm
/dev/sda1                  485        31       429   7% /boot
[root@centos62 ~]#

2011年12月24日土曜日

CentOS6.2 インストールパッケージ(1)

2011年12月初旬にCentOS6.2がリリースされたようなので早速インストールしてみた。
CentOS5系と比べてインストールパッケージの内容、というかインストール方法もガラっと変わっているようだ。
まずサーバのタイプを選択し、「今すぐカスタマイズ」で、選択したサーバのタイプをベースにパッケージというかアプリケーションを追加する方式となっている。
今回はサーバタイプ「Minimal」を選択してどのようにパッケージの選択肢が表示されるかを記載してみる。

【High Availability】
 □ High Availability
 □ High Availability の管理

【Load Balancer】
 □ Load Balancer

【Resilient Storage】
 □ Resilient Storage

【Scalable Filesystem】
 □ Scalable Filesystem

【Webサービス】
 □ PHP サポート
 □ TurboGears アプリケーションフレームワーク
 □ Web サーバー
 □ Web サーブレットエンジン

【アプリケーション】
 □ Emacs
 □ TeX のサポート
 □ インターネットアプリケーション
 □ インターネットブラウザ
 □ オフィススイートと生産性
 □ グラフィックツール
 □ 技術文書

【サーバー】
 □ CIFS ファイルサーバー
 □ FTP サーバー
 □ Identity Management Server
 □ NFS ファイルサーバ
 □ サーバープラットフォーム
 □ システム管理ツール
 □ ディレクトリサーバー 
 □ ネットワークインフラストラクチャサーバー
 □ ネットワークストレージサーバー
 □ バックアップサーバー
 □ プリントサーバー
 □ 電子メールサーバー

【システム管理】
 □ SNMP サポート
 □ WBEM サポート
 □ システム管理
 □ システム管理 Messaging Server のサポート
 □ メッセージング接続クライアントのサポート

【デスクトップ】
 □ KDEデスクトップ
 □ X Window System
 □ グラフィカル管理ツール
 □ デスクトップ
 □ デスクトップのデバッグとパフォーマンスツール
 □ デスクトッププラットフォーム
 □ フォント
 □ リモートデスクトップ接続クライアント
 □ レガシー X Windows システムの互換性
 □ 入力メソッド
 □ 汎用デスクトップ (GNOMEデスクトップ)

【データベース】
 □ MySQL データベースサーバー
 □ MySQL データベース接続クライアント
 □ PostgreSQL データベースサーバー
 □ PostgreSQL データベース接続クライアント

【ベースシステム】
 □ FCoE ストレージ接続クライアント
 □ Infiniband のサポート
 □ Java プラットフォーム
 □ Perl のサポート
 □ Ruby Support
 □ iSCSI ストレージ接続クライアント
 ■ クライアント管理ツール
 □ コンソールインターネットツール
 □ ストレージ可用性ツール
 □ スマートカードのサポート
 □ セキュリティツール
 □ ダイヤルアップネットワークサポート
 □ ディレクトリ接続クライアント
 □ デバッグツール
 □ ネットワーキングツール
 □ ネットワークファイルシステムクライアント
 □ ハードウェア監視ユーティリティ
 □ バックアップクライアント
 □ パフォーマンスツール
 □ ベース
 □ メインフレームアクセス
 □ レガシー UNIX の互換性
 □ 互換性ライブラリ
 □ 印刷クライアント
 □ 大規模システムのパフォーマンス
 □ 数学/科学系および並列計算

【仮想化】
 □ 仮想化
 □ 仮想化クライアント
 □ 仮想化ツール
 □ 仮想化プラットフォーム

【言語】
 ■ 日本語のサポート
 ※ 他は省略

【開発】
 □ Eclipse
 □ その他の開発
 □ サーバープラットフォーム開発
 □ デスクトッププラットフォーム開発
 □ 開発ツール

---------------------------------------
 □:インストールしない
 ■:インストールする


画面キャプチャも併記。※解像度がいまいちなので参考程度に…。
【サーバタイプ選択画面】

【High Availability】

【Load Balancer】

【Resilient Storage】

【Scalable Filesystem】

【Webサービス】

【アプリケーション】

【サーバー】

【システム管理】

【デスクトップ】

【データベース】

【ベースシステム】

【仮想化】

【言語】

【開発】

Minimalでインストールした場合のOSのパッケージ一覧や、サービス起動設定、ディスク使用状況については次回に記載予定。

2011年12月21日水曜日

ファイル名にタイムスタンプを付与してコピー


■スクリプト概要
バックアップする際、元ファイルのタイムスタンプをファイル名に使用したい場合があった時に
便利なスクリプトです。特に複数ファイルまとめて処理しようとする場合に活躍するはず…。


#!/bin/sh
#######################################################################
# << 機能概要 >>
# バックアップしたファイル名に元ファイルのタイムスタンプを付与する
#
# <<変更履歴>>
# Version  変更日      変更者        変更内容
# --------+-----------+-------------+----------------------------------
#     1.0  2011/xx/xx  tanyao        対象ファイルリスト読込み
#######################################################################

FILE_LIST=file_list.txt
LOG_FILE=log_add_timestamp.log

# リストファイル存在チェック
if [ ! -f $FILE_LIST ]; then
    echo "ERORR: $FILE_LIST is not exist."
    exit 1
fi


i=0
while read line
do
    cp_target[$i]="$line"

    # コピー対象ファイル存在チェック
    if [ -f ${cp_target[$i]} ]; then
        timestamp=`ls -lrt --time-style='+%Y%m%d' ${cp_target[$i]} | awk '{print $6}'`
        cp -p ${cp_target[$i]} ${cp_target[$i]}.${timestamp} > /dev/null 2>&1
        ls -l ${cp_target[$i]} ${cp_target[$i]}.${timestamp} >> ${LOG_FILE}
    else
        echo "ERORR: ${cp_target[$i]} is not exist." >> ${LOG_FILE}
#        continue
    fi

    i=`expr $i + 1`
done < ${FILE_LIST}

echo "" >> ${LOG_FILE}

exit 0


■以下、補足説明

このシェルスクリプト(add_timestamp.sh)はコピー対象のファイルパスが記載された
file_list.txtというファイルを同階層にご準備ください。
[root@tanyao ~]# cat file_list.txt
/tmp/test01.txt
/tmp/test02.txt
/tmp/test03.txt
/tmp/test04.txt

コピー対象ファイルのあるディレクトリの状況はこんな感じ。
[root@tanyao ~]# ll /tmp/test*
-rw-r--r-- 1 root root 132  2月  2  2002 /tmp/test01.txt
-rw-r--r-- 1 root root 132  6月  6  2006 /tmp/test02.txt
-rw-r--r-- 1 root root 132  6月  6  2006 /tmp/test02.txt.20060606
-rw-r--r-- 1 root root 132 12月 21 15:29 /tmp/test04.txt
※すでに複製後のファイルが存在していても上書きする仕様です。

スクリプトを実行すると同階層にログファイルが出力され、期待通り
タイムスタンプ名入りのコピーファイルが作成されたか確認できます。
[root@tanyao ~]# ./add_timestamp.sh
[root@tanyao ~]# cat log_add_timestamp.log
-rw-r--r-- 1 root root 132  2月  2  2002 /tmp/test01.txt
-rw-r--r-- 1 root root 132  2月  2  2002 /tmp/test01.txt.20020202
-rw-r--r-- 1 root root 132  6月  6  2006 /tmp/test02.txt
-rw-r--r-- 1 root root 132  6月  6  2006 /tmp/test02.txt.20060606
ERORR: /tmp/test03.txt is not exist.
-rw-r--r-- 1 root root 132 12月 21 15:29 /tmp/test04.txt
-rw-r--r-- 1 root root 132 12月 21 15:29 /tmp/test04.txt.20111221

[root@tanyao ~]# 

ちなみに、ファイルのタイムスタンプを変更するには、
[root@tanyao ~]# touch -t 200202021751 /tmp/test01.txt


こちらの情報が何かのお役に立てましたら幸いです。

2011年10月15日土曜日

Windows7にPowerCLIインストール

■ダウンロード
http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli
ログイン画面を経由して下記へ
http://www.vmware.com/downloads/eula.do
vSphere PowerCLI - installer (約91MB)
Download and install an easy-to-use PowerShell interface to manage and monitor vSphere.

Use Web Browser を選択してインストーラ(VMware-PowerCLI-5.0.0-435426.exe)をPCに保存。

※PowerShellはWindows7には同梱されているのでインストール不要。
※Windows7またはWindowsServer2008以外は下記URLからインストーラをDL
 http://support.microsoft.com/kb/968929


■インストールパス
C:\ProgramFiles2\VMware\Infrastructure\vSphere PowerCLI\


■PowerCLI起動
VMware vSphere PowerCLIショートカットアイコンを普通にダブルクリックして起動
-------------------------------------------------------------
スクリプトの実行がシステムで無効になっているため、ファイル C:\ProgramFiles2\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1 を読み込めません。詳細については、「get-help about_signing」と入力してヘルプを参照してください。
発生場所 行:1 文字:2
+ . <<<<  "C:\ProgramFiles2\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvir
onment.ps1"
    + CategoryInfo          : 未指定: (:) []、PSSecurityException
    + FullyQualifiedErrorId : RuntimeException
-------------------------------------------------------------

スクリプトの実行を有効化しようとしたが…。
-------------------------------------------------------------
PS C:\ProgramFiles2\VMware\Infrastructure\vSphere PowerCLI> Set-ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution
policy might expose you to the security risks described in the about_Execution_Policies help topic.
 Do you want to change the execution policy?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): Y
Set-ExecutionPolicy : レジストリ キー 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\
Microsoft.PowerShell' へのアクセスが拒否されました。
発生場所 行:1 文字:20
+ Set-ExecutionPolicy <<<<  RemoteSigned
    + CategoryInfo          : 未指定: (:) [Set-ExecutionPolicy]、UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.Set
   ExecutionPolicyCommand

PS C:\ProgramFiles2\VMware\Infrastructure\vSphere PowerCLI>
-------------------------------------------------------------

アイコンを右クリックし、「管理者として実行」から起動するとスクリプトの実行を有効化できる。


■再びPowerCLI起動しESXiサーバに接続
-------------------------------------------------------------
          Welcome to the VMware vSphere PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

       Copyright (C) 1998-2011 VMware, Inc. All rights reserved.


PowerCLI C:\ProgramFiles2\VMware\Infrastructure\vSphere PowerCLI> cd /
PowerCLI C:\> Connect-VIServer -User root -Password kamehame8 192.168.xxx.xxx
警告: There were one or more problems with the server certificate:

* The X509 chain could not be built up to the root certificate.

* The certificate's CN name does not match the passed value.


Name                           Port  User
----                           ----  ----
192.168.xxx.xxx                 443   root


PowerCLI C:\> get-vm

Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
rails02              PoweredOn  1        768
files01              PoweredOn  1        1024
windows7             PoweredOn  1        1024
backup01             PoweredOff 1        512
web01                PoweredOn  1        1024
rails01              PoweredOn  1        768


PowerCLI C:\>
-------------------------------------------------------------

2011年10月1日土曜日

Ruby1.9.2p290にRedmine1.2.1インストールしてみたが…

■前提
OS: CentOS5.7(64bit)
Ruby: 1.9.2p290
MySQL: 5.0.77(OSバンドルのものを使用)
Apache: 2.2.3(OSバンドルのものを使用)
passenger: 3.0.9


■Redmineを実行するために必要なgemパッケージおよびそのバージョンをインストール
⇒Rack 1.1.1、rake 0.8.7、i18n 0.4.2 (最新バージョンだと動かないため)
⇒バージョン確認
[root@redmine02 ~]# gem list | grep -e rack -e rake -e i18n
i18n (0.6.0)
rack (1.3.3)
rack-cache (1.0.3)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rake (0.9.2, 0.8.7)

⇒Rack 1.1.1インストール
[root@redmine02 ~]# gem install rack -v=1.1.1 --no-rdoc --no-ri
Successfully installed rack-1.1.1
1 gem installed
[root@redmine02 ~]#

⇒i18n 0.4.2
[root@redmine02 ~]# gem install i18n -v=0.4.2 --no-rdoc --no-ri
Successfully installed i18n-0.4.2
1 gem installed
[root@redmine02 ~]#


■MySQLのデフォルトキャラクタセットをutf8に設定
[root@redmine02 ~]# mysql --version
mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1

[root@redmine02 ~]# cat /etc/my.cnf
[root@redmine02 ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

# 20110930 for redmine		←追記
default-character-set=utf8	←追記

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# 20110930 for redmine		←追記
[mysql]				←追記
default-character-set=utf8	←追記
[root@redmine02 ~]#

⇒MySLQ再起動
[root@redmine02 ~]# /etc/init.d/mysqld restart
MySQL を停止中:                                            [  OK  ]
MySQL を起動中:                                            [  OK  ]

⇒キャラクタセット設定確認
[root@redmine02 ~]# mysql -u root
mysql> show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)


■MySQLデータベース準備
⇒匿名ユーザー削除
mysql> use mysql
Database changed
mysql> delete from user where user = '';
Query OK, 2 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

⇒Redmine用データベースとユーザーの作成
mysql> create database db_redmine default character set utf8;
Query OK, 1 row affected (0.06 sec)

mysql> grant all on db_redmine.* to user_redmine identified by 'ienaiyo';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

⇒自動起動設定
[root@redmine02 ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@redmine02 ~]# chkconfig mysqld on
[root@redmine02 ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off


■Redmineのダウンロード
http://rubyforge.org/frs/?group_id=1850
上記サイトよりredmine-1.2.1.tar.gzをダウンロード
/home/public/src/に配置


■Redmineの配置先のディレクトリに解凍
[root@redmine02 ~]# tar -zxf /home/public/src/redmine-1.2.1.tar.gz -C /rails_projects/
[root@redmine02 ~]# cd /rails_projects/redmine-1.2.1/


■Redmine設定
⇒database.ymlの設定
[root@redmine02 redmine-1.2.1]# vi config/database.yml
[root@redmine02 redmine-1.2.1]# cat config/database.yml
production:
  adapter: mysql2
  database: db_redmine
  host: localhost
  username: user_redmine
  password: ienaiyo
  encoding: utf8
[root@redmine02 redmine-1.2.1]#

⇒configuration.ymlの設定
[root@redmine02 redmine-1.2.1]# cp config/configuration.yml.example config/configuration.yml
[root@redmine02 redmine-1.2.1]# vi config/configuration.yml
[root@redmine02 redmine-1.2.1]# tail -11 config/configuration.yml
production:
  email_delivery:		←追記
    delivery_method: :smtp	←追記
    smtp_settings:		←追記
      address: "localhost"	←追記
      port: 25			←追記
      domain: 'dynalias.net'	←追記(環境により異なる)

# specific configuration options for development environment
# that overrides the default ones
development:
[root@redmine02 redmine-1.2.1]#

⇒Redmineの初期設定とデータベースのテーブル作成
[root@redmine02 redmine-1.2.1]# rake generate_session_store
(in /rails_projects/redmine-1.2.1)

[root@redmine02 redmine-1.2.1]# rake db:migrate RAILS_ENV=production
(in /rails_projects/redmine-1.2.1)
rake aborted!
undefined method `map' for nil:NilClass
/usr/local/lib/ruby/1.9.1/rubygems.rb:228:in `activate'
/usr/local/lib/ruby/1.9.1/rubygems.rb:1119:in `try_activate'
:32:in `rescue in require'
:29:in `require'
/rails_projects/redmine-1.2.1/vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `block in require'
/rails_projects/redmine-1.2.1/vendor/rails/activesupport/lib/active_support/dependencies.rb:547:in `new_constants_in'
/rails_projects/redmine-1.2.1/vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `require'


■エラー対応
最新バージョンをアンインストール
[root@redmine02 ~]# gem uninstall rack

Select gem to uninstall:
 1. rack-1.1.1
 2. rack-1.3.3
 3. All versions
> 2

You have requested to uninstall the gem:
        rack-1.3.3
sprockets-2.0.0 depends on [rack (~> 1.0)]
actionpack-3.1.0 depends on [rack (~> 1.3.2)]
rack-mount-0.8.3 depends on [rack (>= 1.0.0)]
passenger-3.0.9 depends on [rack (>= 0)]
rack-test-0.6.1 depends on [rack (>= 1.0)]
rack-ssl-1.3.2 depends on [rack (>= 0)]
rack-cache-1.0.3 depends on [rack (>= 0.4)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  y
Successfully uninstalled rack-1.3.3

[root@redmine02 redmine-1.2.1]# gem uninstall i18n

Select gem to uninstall:
 1. i18n-0.4.2
 2. i18n-0.6.0
 3. All versions
> 2

You have requested to uninstall the gem:
        i18n-0.6.0
mail-2.3.0 depends on [i18n (>= 0.4.0)]
actionpack-3.1.0 depends on [i18n (~> 0.6)]
activemodel-3.1.0 depends on [i18n (~> 0.6)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  y
Successfully uninstalled i18n-0.6.0
[root@redmine02 redmine-1.2.1]#

⇒environment.rbに追記
[root@redmine02 redmine-1.2.1]# head -30 config/environment.rb
# Be sure to restart your web server when you modify this file.

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

# add 20110930
if Gem::VERSION >= "1.3.6"
    module Rails
        class GemDependency
            def requirement
                r = super
                (r == Gem::Requirement.default) ? nil : r
            end
        end
    end
end

# Load Engine plugin if available
begin
  require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')
rescue LoadError
  # Not available
end


⇒エラー解消せず。(T-T)
結局Redmine1.2.1は現時点で最新のruby1.9.2には対応していないことが原因の模様。

2011年9月27日火曜日

Redmineとgitの連携

■クライアントPCおよびRedmineの両方からアクセスできるように所有者変更
[root@redmine01 git_repos]# chown -R public:apache sample


■configuration.yml設定
⇒gitモジュールのパス確認
[root@redmine01 ~]# ll /usr/local/bin/git
-rwxr-xr-x 109 root root 4977962  9月 25 14:56 /usr/local/bin/git

⇒configuration.yml設定
[root@redmine01 ~]# vi /opt/redmine-1.2.1/config/configuration.yml
[root@redmine01 ~]# grep -n git /opt/redmine-1.2.1/config/configuration.yml
116:  # scm_git_command:        /usr/local/bin/git                        # (default: git)
122:  scm_git_command: /usr/local/bin/git	←修正
[root@redmine01 ~]#


■Redmine画面から設定
⇒gitの使用可能確認
管理 > 設定 > リポジトリタブ
使用するバージョン管理システム: gitのバージョンが表示され使用可能になっている

⇒gitリポジトリ設定
プロジェクト選択 > 設定 > リポジトリ
バージョン管理システム: Git
リポジトリのパス: /opt/git_repos/sample
→プロジェクトに"リポジトリ"タブが表示される。

2011年9月26日月曜日

CentOS5.7にgit1.7.6.1インストール

■インストーラダウンロード
https://github.com/git/git/downloads

[root@redmine01 ~]# ll /usr/local/
合計 80
drwxr-xr-x 2 root root 4096  9月 25 00:19 bin
drwxr-xr-x 2 root root 4096  5月 11 20:58 etc
drwxr-xr-x 2 root root 4096  5月 11 20:58 games
drwxr-xr-x 2 root root 4096  5月 11 20:58 include
drwxr-xr-x 3 root root 4096  9月 24 23:27 lib
drwxr-xr-x 2 root root 4096  5月 11 20:58 lib64
drwxr-xr-x 2 root root 4096  5月 11 20:58 libexec
drwxr-xr-x 2 root root 4096  5月 11 20:58 sbin
drwxr-xr-x 4 root root 4096  9月 24 05:19 share
drwxr-xr-x 2 root root 4096  5月 11 20:58 src

[root@redmine01 ~]# cd /home/public/src/
[root@redmine01 src]# tar -zxf git-git-v1.7.6.1-0-gccef604.tar.gz
[root@redmine01 src]# cd git-git-ce54b9b/

⇒./configureがないので、いきなりmake
[root@redmine01 git-git-ce54b9b]# make prefix=/usr/local
GIT_VERSION = 1.7.6.1
    * new build flags or prefix
    CC daemon.o
    * new link flags
    CC abspath.o
(中略)
    GEN bin-wrappers/test-svn-fe
    GEN bin-wrappers/test-treap
[root@redmine01 git-git-ce54b9b]#

⇒make install
[root@redmine01 git-git-ce54b9b]# make prefix=/usr/local install
    * new build flags or prefix
    CC daemon.o
    CC abspath.o
(中略)
                cp "$execdir/git-remote-http" "$execdir/$p" || exit; \
        done && \
        ./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
[root@redmine01 git-git-ce54b9b]#


■bareリポジトリ(共有リポジトリ)作成
[root@redmine01 ~]# mkdir -p /opt/git_repos/sample
[root@redmine01 ~]# cd /opt/git_repos/sample
[root@redmine01 sample]# git init --bare --shared=true
Initialized empty shared Git repository in /opt/git_repos/sample/
[root@redmine01 sample]# git branch
[root@redmine01 sample]#
※作成直後はブランチは存在しない。

⇒所有者変更
[root@redmine01 ~]# chown -R public: /opt/git_repos/sample
[root@redmine01 ~]# ll /opt/git_repos/sample
合計 32
-rw-rw-r-- 1 public public   23  9月 25 21:35 HEAD
drwxrwsr-x 2 public public 4096  9月 25 21:35 branches
-rw-rw-r-- 1 public public  126  9月 25 21:35 config
-rw-rw-r-- 1 public public   73  9月 25 21:35 description
drwxrwsr-x 2 public public 4096  9月 25 21:35 hooks
drwxrwsr-x 2 public public 4096  9月 25 21:35 info
drwxrwsr-x 4 public public 4096  9月 25 21:35 objects
drwxrwsr-x 4 public public 4096  9月 25 21:35 refs
[root@redmine01 ~]#


-----------------------------------------------------------
◆クライアントPC(Windows7)にて、msysgitインストール
⇒msysgitダウンロード
http://code.google.com/p/msysgit/downloads/list
Git-1.7.6-preview20110708.exe 

⇒インストール
ウィザードに従ってインストール。選択肢は下記を選択
・Use Git Bash only
・Ceckout Windows-style, commit Unix-style line endings


◆クライアントPC(Windows7)にて、msysgitを利用し対象ディレクトリをバージョン管理する
Welcome to Git (version 1.7.6-preview20110708)


Run 'git help git' to display the help index.
Run 'git help ' to display help for specific commands.

admin@TANYAO-PC /E/git_reops/test

⇒対象ディレクトリをgitでソース管理
$ git init
Initialized empty Git repository in e:/git_reops/test/.git/

admin@TANYAO-PC /E/git_reops/test (master)

⇒リモートの共有リポジトリをoriginという名前で定義
$ git remote add origin ssh://public@192.168.1.15/opt/git_repos/sample

admin@TANYAO-PC /E/git_reops/test (master)

⇒ユーザ名とメールアドレスを設定
$ git config --global user.name "tanyao"

admin@TANYAO-PC /E/git_reops/test (master)
$ git config --global user.email admin@tanyao.dynalias.net

admin@TANYAO-PC /E/git_reops/test (master)

⇒全ファイルをステージングに追加
$ git add .
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Gemfile.
(後略)

admin@TANYAO-PC /E/git_reops/test (master)

⇒コミット
$ git commit -m "initial import"
[master (root-commit) 40b0767] initial import
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Gemfile.
The file will have its original line endings in your working directory.
(後略)

admin@TANYAO-PC /E/git_reops/test (master)

⇒共有リポジトリにプッシュ
$ git push origin master
public@192.168.1.15's password:
Counting objects: 87, done.
Compressing objects: 100% (74/74), done.
Writing objects: 100% (87/87), 29.65 KiB, done.
Total 87 (delta 2), reused 0 (delta 0)
To ssh://public@192.168.1.15/opt/git_repos/sample
 * [new branch]      master -> master

admin@TANYAO-PC /E/git_reops/test (master)
-----------------------------------------------------------


■クライアントPC(Windows7)からpush後、再確認
[root@redmine01 sample]# git branch
* master
[root@redmine01 sample]# ll
合計 32
-rw-rw-r--  1 public public   23  9月 25 21:35 HEAD
drwxrwsr-x  2 public public 4096  9月 25 21:35 branches
-rw-rw-r--  1 public public  126  9月 25 21:35 config
-rw-rw-r--  1 public public   73  9月 25 21:35 description
drwxrwsr-x  2 public public 4096  9月 25 21:35 hooks
drwxrwsr-x  2 public public 4096  9月 25 21:35 info
drwxrwsr-x 79 public public 4096  9月 25 21:46 objects ←ファイルが増えている
drwxrwsr-x  4 public public 4096  9月 25 21:35 refs
[root@redmine01 sample]# ll objects/
合計 308
drwxrwsr-x 2 public public 4096  9月 25 21:46 04
drwxrwsr-x 2 public public 4096  9月 25 21:46 05
drwxrwsr-x 2 public public 4096  9月 25 21:46 08
drwxrwsr-x 2 public public 4096  9月 25 21:46 0a
drwxrwsr-x 2 public public 4096  9月 25 21:46 11
(後略)


■devブランチ作成
[root@redmine01 sample]# git branch dev
[root@redmine01 sample]# git branch
  dev
* master
[root@redmine01 sample]# git checkout dev
fatal: This operation must be run in a work tree
[root@redmine01 sample]#
※bareリポジトリではmaster以外のブランチに移動できないようだ。


-----------------------------------------------------------
◆クライアントPC(Windows7)にて、共有リポジトリをプル
$ git pull
public@192.168.1.15's password:
From ssh://192.168.1.15/opt/git_repos/sample
 * [new branch]      dev        -> origin/dev
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull  ').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:
    [branch "master"]
    remote = 
    merge = 

    [remote ""]
    url = 
    fetch = 

See git-config(1) for details.

admin@TANYAO-PC /E/git_reops/test (master)

⇒リモートブランチからローカルブランチを生成
$ git branch -a
* master
  remotes/origin/dev
  remotes/origin/master

admin@TANYAO-PC /E/git_reops/test (master)
$ git checkout -b dev origin/dev
Branch dev set up to track remote branch dev from origin.
Switched to a new branch 'dev'

admin@TANYAO-PC /E/git_reops/test (dev)
$ git branch -a
* dev
  master
  remotes/origin/dev
  remotes/origin/master

admin@TANYAO-PC /E/git_reops/test (dev)

2011年9月25日日曜日

Redmine1.2.1構築メモ(4)

■構成情報
・OS:    CentOS5.7(64bit)
・MySQL:   5.0.77(OSバンドル)
・Ruby:   1.8.7(Ruby Enterprise Editionを利用)
 ・rack:  1.1.1
 ・rake:  0.8.7
 ・i18n:  0.4.2
・Apache:  2.2.3(OSバンドル)
・Passenger: 3.0.9
・Redmine:  1.2.1
(4) ApacheにPassengerを組み込み

■パッケージを準備
[root@redmine01 ~]# rpm -q httpd-devel
パッケージ httpd-devel はインストールされていません。
[root@redmine01 ~]# yum -y install httpd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd-devel.i386 0:2.2.3-53.el5.centos.1 set to be updated
--> Processing Dependency: httpd = 2.2.3-53.el5.centos.1 for package: httpd-devel
--> Processing Dependency: apr-util-devel for package: httpd-devel
--> Processing Dependency: apr-devel for package: httpd-devel
---> Package httpd-devel.x86_64 0:2.2.3-53.el5.centos.1 set to be updated
--> Running transaction check
---> Package apr-devel.x86_64 0:1.2.7-11.el5_6.5 set to be updated
---> Package apr-util-devel.x86_64 0:1.2.7-11.el5_5.2 set to be updated
--> Processing Dependency: httpd = 2.2.3-53.el5.centos for package: mod_ssl
--> Processing Dependency: httpd = 2.2.3-53.el5.centos for package: httpd-manual
---> Package httpd.x86_64 0:2.2.3-53.el5.centos.1 set to be updated
--> Running transaction check
---> Package httpd-manual.x86_64 0:2.2.3-53.el5.centos.1 set to be updated
---> Package mod_ssl.x86_64 1:2.2.3-53.el5.centos.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================
 Package                               Arch                Version                        Repository                 Size
==========================================================================================================================
Installing:
 httpd-devel                           i386                2.2.3-53.el5.centos.1          updates                   151 k
 httpd-devel                           x86_64              2.2.3-53.el5.centos.1          updates                   151 k
Installing for dependencies:
 apr-devel                             x86_64              1.2.7-11.el5_6.5               base                      238 k
 apr-util-devel                        x86_64              1.2.7-11.el5_5.2               base                       53 k
Updating for dependencies:
 httpd                                 x86_64              2.2.3-53.el5.centos.1          updates                   1.2 M
 httpd-manual                          x86_64              2.2.3-53.el5.centos.1          updates                   815 k
 mod_ssl                               x86_64              1:2.2.3-53.el5.centos.1        updates                    94 k

Transaction Summary
==========================================================================================================================
Install       4 Package(s)
Upgrade       3 Package(s)

Total download size: 2.7 M
Downloading Packages:
(1/7): apr-util-devel-1.2.7-11.el5_5.2.x86_64.rpm                                                       |  53 kB     00:00
(2/7): mod_ssl-2.2.3-53.el5.centos.1.x86_64.rpm                                                         |  94 kB     00:00
(3/7): httpd-devel-2.2.3-53.el5.centos.1.x86_64.rpm                                                     | 151 kB     00:00
(4/7): httpd-devel-2.2.3-53.el5.centos.1.i386.rpm                                                       | 151 kB     00:00
(5/7): apr-devel-1.2.7-11.el5_6.5.x86_64.rpm                                                            | 238 kB     00:00
(6/7): httpd-manual-2.2.3-53.el5.centos.1.x86_64.rpm                                                    | 815 kB     00:00
(7/7): httpd-2.2.3-53.el5.centos.1.x86_64.rpm                                                           | 1.2 MB     00:00
---------------------------------------------------------------------------------------------------------------------------
Total                                                                                          1.2 MB/s | 2.7 MB     00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : httpd                                                                                              1/10
  Installing     : apr-devel                                                                                          2/10
  Updating       : mod_ssl                                                                                            3/10
  Installing     : apr-util-devel                                                                                     4/10
  Updating       : httpd-manual                                                                                       5/10
  Installing     : httpd-devel                                                                                        6/10
  Installing     : httpd-devel                                                                                        7/10
  Cleanup        : httpd-manual                                                                                       8/10
  Cleanup        : httpd                                                                                              9/10
  Cleanup        : mod_ssl                                                                                           10/10

Installed:
  httpd-devel.i386 0:2.2.3-53.el5.centos.1   httpd-devel.x86_64 0:2.2.3-53.el5.centos.1

Dependency Installed:
  apr-devel.x86_64 0:1.2.7-11.el5_6.5        apr-util-devel.x86_64 0:1.2.7-11.el5_5.2

Dependency Updated:
  httpd.x86_64 0:2.2.3-53.el5.centos.1       httpd-manual.x86_64 0:2.2.3-53.el5.centos.1     mod_ssl.x86_64 1:2.2.3-53.el5.centos.1

Complete!
[root@redmine01 ~]#


■Passengerのインストール
[root@redmine01 ~]# gem install passenger --no-rdoc --no-ri
Fetching: fastthread-1.0.7.gem (100%)
Building native extensions.  This could take a while...
Fetching: daemon_controller-0.2.6.gem (100%)
Fetching: passenger-3.0.9.gem (100%)
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-0.2.6
Successfully installed passenger-3.0.9
3 gems installed
[root@redmine01 ~]#


■PassengerのApache用モジュールのインストール
[root@redmine01 ~]# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.9.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 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++
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/local/bin/rake
 * rack... found
 * Apache 2... found at /usr/sbin/httpd
 * Apache 2 development headers... found at /usr/sbin/apxs
 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config

--------------------------------------------
Compiling and installing Apache 2 module...
cd /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9
/usr/local/bin/ruby /usr/local/bin/rake apache2:clean apache2 RELEASE=yes
(中略)

--------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9
   PassengerRuby /usr/local/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.


--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

   
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      
   

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9/doc/Users guide Apache.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.
[root@redmine01 ~]#


■Apacheの設定
⇒worker MPMに切り替える
[root@redmine01 ~]# vi /etc/sysconfig/httpd
[root@redmine01 ~]# grep httpd.worker /etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker
HTTPD=/usr/sbin/httpd.worker ←追記

⇒passnger.conf作成
[root@redmine01 ~]# vi /etc/httpd/conf.d/passnger.conf
[root@redmine01 ~]# cat /etc/httpd/conf.d/passnger.conf
# output of "passenger-install-apache2-module"
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9
PassengerRuby /usr/local/bin/ruby

# rails settings
RailsBaseURI /redmine

# Passengerが追加するHTTPヘッダを削除するための設定
Header always unset "X-Powered-By"
Header always unset "X-Rack-Cache"
Header always unset "X-Content-Digest"
Header always unset "X-Runtime"

# 必要に応じてPassengerのチューニングのための設定を追加。
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 3600
PassengerUseGlobalQueue on
PassengerHighPerformance on
PassengerStatThrottleRate 10
RailsSpawnMethod smart
RailsAppSpawnerIdleTime 86400
RailsFrameworkSpawnerIdleTime 0
[root@redmine01 ~]#

⇒Apache自動起動設定
[root@redmine01 ~]# chkconfig --list httpd
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@redmine01 ~]# chkconfig httpd on

⇒Redmineディレクトリの所有者変更
[root@redmine01 ~]# chown -R apache: /opt/redmine-1.2.1

⇒サブディレクトリでRedmineを実行(シンボリックリンク作成)
[root@redmine01 ~]# ln -s /opt/redmine-1.2.1/public /var/www/html/redmine

⇒Apacheを起動
[root@redmine01 ~]# /etc/init.d/httpd configtest
Syntax OK
[root@redmine01 ~]# /etc/init.d/httpd graceful
httpd not running, trying to start
[root@redmine01 ~]#

⇒ブラウザからアクセス
http://192.168.1.15/redmine/
ログイン:admin/admin

お手数をおかけして恐縮ですが、広告サイトクリックにご協力いただけるとありがたいです。m(_ _)m

2011年9月24日土曜日

Redmine1.2.1構築メモ(3)

■構成情報
・OS:    CentOS5.7(64bit)
・MySQL:   5.0.77(OSバンドル)
・Ruby:   1.8.7(Ruby Enterprise Editionを利用)
 ・rack:  1.1.1
 ・rake:  0.8.7
 ・i18n:  0.4.2
・Apache:  2.2.3(OSバンドル)
・Passenger: 3.0.9
・Redmine:  1.2.1
(3) Redmineインストール

■インストーラダウンロード&解凍
http://rubyforge.org/frs/?group_id=1850
redmine-1.2.1.tar.gzをダウンロードしてサーバにUP

⇒/optに解凍
[root@redmine01 src]# tar -zxf redmine-1.2.1.tar.gz -C /opt

■Redmine関連ファイル設定
[root@redmine01 ~]# cd /opt/redmine-1.2.1/

⇒database.yml作成
[root@redmine01 redmine-1.2.1]# vi config/database.yml
[root@redmine01 redmine-1.2.1]# cat config/database.yml
production:
  adapter: mysql
  database: db_redmine
  host: localhost
  username: user_redmine
  password: ienaiyo
  encoding: utf8
[root@redmine01 redmine-1.2.1]#

⇒configuration.ymlの設定
[root@redmine01 redmine-1.2.1]# cp config/configuration.yml.example config/configuration.yml
[root@redmine01 redmine-1.2.1]# vi config/configuration.yml
[root@redmine01 redmine-1.2.1]# tail -11 config/configuration.yml
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: "localhost"
      port: 25
      domain: 'foo.com'

# specific configuration options for development environment
# that overrides the default ones
development:
[root@redmine01 redmine-1.2.1]#

⇒Redmineの初期設定とデータベースのテーブル作成
[root@redmine01 redmine-1.2.1]# rake generate_session_store
(in /opt/redmine-1.2.1)
[root@redmine01 redmine-1.2.1]# rake db:migrate RAILS_ENV=production
(in /opt/redmine-1.2.1)
==  Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
   -> 0.0072s
-- create_table("auth_sources", {:force=>true})
(中略)

==  AddRepositoriesExtraInfo: migrating =======================================
-- add_column(:repositories, :extra_info, :text)
   -> 0.0092s
==  AddRepositoriesExtraInfo: migrated (0.0095s) ==============================

[root@redmine01 redmine-1.2.1]#



2011年9月23日金曜日

Redmine1.2.1構築メモ(2)

■構成情報
・OS:    CentOS5.7(64bit)
・MySQL:   5.0.77(OSバンドル)
・Ruby:   1.8.7(Ruby Enterprise Editionを利用)
 ・rack:  1.1.1
 ・rake:  0.8.7
 ・i18n:  0.4.2
・Apache:  2.2.3(OSバンドル)
・Passenger: 3.0.9
・Redmine:  1.2.1
(2) Ruby Enterprise Edition インストール

■OSバンドルのRuby有無確認
[root@redmine01 ~]# rpm -qa | grep ruby
[root@redmine01 ~]#
⇒既存Rubyは存在しないのでOK!

■インストーラダウンロード&解凍
http://www.rubyenterpriseedition.com/download.html
ruby-enterprise-1.8.7-2011.03.tar.gzをダウンロードしてサーバにUP

[root@redmine01 ~]# cd /home/public/src/
[root@redmine01 src]# tar -zxf ruby-enterprise-1.8.7-2011.03.tar.gz

■インストール
[root@redmine01 src]# ruby-enterprise-1.8.7-2011.03/installer --dont-install-useful-gems --no-dev-docs
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.7-2011.03.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.

You can expect this from the installation process:

  1. Ruby Enterprise Edition will be compiled and optimized for speed for this
     system.
  2. Ruby on Rails will be installed for Ruby Enterprise Edition.
  3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
     Edition instead of regular Ruby.

Press Enter to continue, or Ctrl-C to abort.

Checking for required software...

 * C compiler... found at /usr/bin/gcc
 * C++ compiler... found at /usr/bin/g++
 * The 'make' tool... found at /usr/bin/make
 * The 'patch' tool... found at /usr/bin/patch
 * Zlib development headers... found
 * OpenSSL development headers... found
 * GNU Readline development headers... found
--------------------------------------------
Target directory

Where would you like to install Ruby Enterprise Edition to?
(All Ruby Enterprise Edition files will be put inside that directory.)

[/opt/ruby-enterprise-1.8.7-2011.03] : /usr/local ←インストール先を指定
--------------------------------------------
Compiling and optimizing the memory allocator for Ruby Enterprise Edition
In the mean time, feel free to grab a cup of coffee.
(中略)

--------------------------------------------
Installing useful libraries...
/usr/local/bin/ruby /usr/local/bin/gem sources --update
source cache successfully updated
Updating /usr/local/bin/irb...
Updating /usr/local/bin/gem...
Updating /usr/local/bin/ri...
Updating /usr/local/bin/erb...
Updating /usr/local/bin/testrb...
Updating /usr/local/bin/rdoc...
--------------------------------------------
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:

  /usr/local/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:

  /usr/local

If you have any questions, feel free to visit our website:

  http://www.rubyenterpriseedition.com

Enjoy Ruby Enterprise Edition, a product of Phusion (www.phusion.nl) :-)
[root@redmine01 src]# 

⇒/usr/localのインストール前
[root@redmine01 ~]# ll /usr/local/
合計 80
drwxr-xr-x 2 root root 4096  5月 11 20:58 bin
drwxr-xr-x 2 root root 4096  5月 11 20:58 etc
drwxr-xr-x 2 root root 4096  5月 11 20:58 games
drwxr-xr-x 2 root root 4096  5月 11 20:58 include
drwxr-xr-x 2 root root 4096  5月 11 20:58 lib
drwxr-xr-x 2 root root 4096  5月 11 20:58 lib64
drwxr-xr-x 2 root root 4096  5月 11 20:58 libexec
drwxr-xr-x 2 root root 4096  5月 11 20:58 sbin
drwxr-xr-x 4 root root 4096  9月 24 05:19 share
drwxr-xr-x 2 root root 4096  5月 11 20:58 src

⇒/usr/localのインストール後
[root@redmine01 ~]# ll /usr/local/
合計 80
drwxr-xr-x 2 root root 4096  9月 24 23:27 bin
drwxr-xr-x 2 root root 4096  5月 11 20:58 etc
drwxr-xr-x 2 root root 4096  5月 11 20:58 games
drwxr-xr-x 2 root root 4096  5月 11 20:58 include
drwxr-xr-x 3 root root 4096  9月 24 23:27 lib
drwxr-xr-x 2 root root 4096  5月 11 20:58 lib64
drwxr-xr-x 2 root root 4096  5月 11 20:58 libexec
drwxr-xr-x 2 root root 4096  5月 11 20:58 sbin
drwxr-xr-x 4 root root 4096  9月 24 05:19 share
drwxr-xr-x 2 root root 4096  5月 11 20:58 src


■gemパッケージのインストール
⇒Rack 1.1.1のインストール
[root@redmine01 ~]# gem install rack -v=1.1.1 --no-rdoc --no-ri
Fetching: rack-1.1.1.gem (100%)
Successfully installed rack-1.1.1
1 gem installed
[root@redmine01 ~]#

⇒rake 0.8.7のインストール
[root@redmine01 ~]# gem install rake -v=0.8.7 --no-rdoc --no-ri
Fetching: rake-0.8.7.gem (100%)
Successfully installed rake-0.8.7
1 gem installed
[root@redmine01 ~]#

⇒i18n 0.4.2のインストール
[root@redmine01 ~]# gem install i18n -v=0.4.2 --no-rdoc --no-ri
Fetching: i18n-0.4.2.gem (100%)
Successfully installed i18n-0.4.2
1 gem installed
[root@redmine01 ~]#

⇒Ruby用MySQLドライバのインストール
[root@redmine01 ~]# gem install mysql --no-rdoc --no-ri
Fetching: mysql-2.8.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
[root@redmine01 ~]#

⇒確認
[root@redmine01 ~]# gem list

*** LOCAL GEMS ***

i18n (0.4.2)
mysql (2.8.1)
rack (1.1.1)
rake (0.8.7)
[root@redmine01 ~]#

2011年9月22日木曜日

Redmine1.2.1構築メモ(1)

■構成情報
・OS:    CentOS5.7(64bit)
・MySQL:   5.0.77(OSバンドル)
・Ruby:   1.8.7(Ruby Enterprise Editionを利用)
 ・rack:  1.1.1
 ・rake:  0.8.7
 ・i18n:  0.4.2
・Apache:  2.2.3(OSバンドル)
・Passenger: 3.0.9
・Redmine:  1.2.1
(1) MySQLの準備

■OSバンドルのmysqlモジュール確認
[root@redmine01 ~]# mysql --version
mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
[root@redmine01 ~]# rpm -qa | grep mysql
libdbi-dbd-mysql-0.8.1a-1.2.2
mysql-5.0.77-4.el5_6.6
mysql-server-5.0.77-4.el5_6.6
mysql-5.0.77-4.el5_6.6
mysql-connector-odbc-3.51.26r1127-1.el5
⇒mysql-develがない!

■mysql-develインストール
[root@redmine01 ~]# yum -y install mysql-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-devel.i386 0:5.0.77-4.el5_6.6 set to be updated
---> Package mysql-devel.x86_64 0:5.0.77-4.el5_6.6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================
 Package                    Arch          Version                 Repository       Size
========================================================================================
Installing:
 mysql-devel                i386          5.0.77-4.el5_6.6        base            2.4 M
 mysql-devel                x86_64        5.0.77-4.el5_6.6        base            2.5 M

Transaction Summary
========================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)

Total download size: 4.9 M
Downloading Packages:
(1/2): mysql-devel-5.0.77-4.el5_6.6.i386.rpm                              | 2.4 MB  00:01
(2/2): mysql-devel-5.0.77-4.el5_6.6.x86_64.rpm                            | 2.5 MB  00:00
------------------------------------------------------------------------------------------
Total                                                            2.2 MB/s | 4.9 MB  00:02
警告: rpmts_HdrFromFdno: ヘッダ V3 DSA signature: NOKEY, key ID e8562897
base/gpgkey                                                               | 1.5 kB  00:00
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) " from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : mysql-devel                                                                                      1/2
  Installing     : mysql-devel                                                                                      2/2

Installed:
  mysql-devel.i386 0:5.0.77-4.el5_6.6                       mysql-devel.x86_64 0:5.0.77-4.el5_6.6

Complete!
[root@redmine01 ~]#


■データベース初期化
[root@redmine01 ~]# /etc/init.d/mysqld start
MySQL データベースを初期化中:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h rails02.daynalias.net password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [  OK  ]
MySQL を起動中:                                            [  OK  ]

⇒起動確認
[root@redmine01 ~]# mysqlshow
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+


■自動起動設定
[root@redmine01 ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@redmine01 ~]# chkconfig mysqld on
[root@redmine01 ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off


■MySQLのデフォルトキャラクタセットをutf8に設定
[root@redmine01 ~]# cp -p /etc/my.cnf /etc/my.cnf.20110510
[root@redmine01 ~]# vi /etc/my.cnf
[root@redmine01 ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

# 20110924 for redmine		←追記
default-character-set=utf8	←追記

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# 20110924 for redmine		←追記
[mysql]				←追記
default-character-set=utf8	←追記
[root@redmine01 ~]#

⇒キャラクタセット設定確認
[root@redmine01 ~]# /etc/init.d/mysqld restart
MySQL を停止中:                                            [  OK  ]
MySQL を起動中:                                            [  OK  ]
[root@redmine01 ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)


■Redmine用データベース準備
⇒匿名ユーザー削除
mysql> use mysql
Database changed
mysql> delete from user where user = '';
Query OK, 2 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

⇒Redmine用データベースとユーザーの作成
mysql> create database db_redmine default character set utf8;
Query OK, 1 row affected (0.06 sec)

mysql> grant all on db_redmine.* to user_redmine identified by 'ienaiyo';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

2011年9月21日水曜日

apacheにpassenger組み込み

■前提
CentOS5.7バンドルのapacheを利用する。


■現在組み込まれているパッケージの確認
[root@rails01 ~]# rpm -qa | grep -e httpd- -e apr-
httpd-2.2.3-53.el5.centos
apr-1.2.7-11.el5_6.5
apr-1.2.7-11.el5_6.5
apr-util-1.2.7-11.el5_5.2
apr-util-1.2.7-11.el5_5.2
httpd-manual-2.2.3-53.el5.centos
system-config-httpd-1.3.3.3-1.el5
⇒passengerインストールに必要そうなhttpd-devel、apr-develがない!


■passengerコマンドに必要なパッケージを準備
[root@rails01 ~]# yum -y install httpd-devel apr-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package apr-devel.i386 0:1.2.7-11.el5_6.5 set to be updated
---> Package apr-devel.x86_64 0:1.2.7-11.el5_6.5 set to be updated
---> Package httpd-devel.i386 0:2.2.3-53.el5.centos.1 set to be updated
--> Processing Dependency: httpd = 2.2.3-53.el5.centos.1 for package: httpd-devel
--> Processing Dependency: apr-util-devel for package: httpd-devel
---> Package httpd-devel.x86_64 0:2.2.3-53.el5.centos.1 set to be updated
--> Running transaction check
---> Package apr-util-devel.x86_64 0:1.2.7-11.el5_5.2 set to be updated
--> Processing Dependency: httpd = 2.2.3-53.el5.centos for package: mod_ssl
--> Processing Dependency: httpd = 2.2.3-53.el5.centos for package: httpd-manual
---> Package httpd.x86_64 0:2.2.3-53.el5.centos.1 set to be updated
--> Running transaction check
---> Package httpd-manual.x86_64 0:2.2.3-53.el5.centos.1 set to be updated
---> Package mod_ssl.x86_64 1:2.2.3-53.el5.centos.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                          Arch                     Version                                    Repository                 Size
======================================================================================================================================
Installing:
 apr-devel                        i386                     1.2.7-11.el5_6.5                           base                      233 k
 apr-devel                        x86_64                   1.2.7-11.el5_6.5                           base                      238 k
 httpd-devel                      i386                     2.2.3-53.el5.centos.1                      updates                   151 k
 httpd-devel                      x86_64                   2.2.3-53.el5.centos.1                      updates                   151 k
Installing for dependencies:
 apr-util-devel                   x86_64                   1.2.7-11.el5_5.2                           base                       53 k
Updating for dependencies:
 httpd                            x86_64                   2.2.3-53.el5.centos.1                      updates                   1.2 M
 httpd-manual                     x86_64                   2.2.3-53.el5.centos.1                      updates                   815 k
 mod_ssl                          x86_64                   1:2.2.3-53.el5.centos.1                    updates                    94 k

Transaction Summary
======================================================================================================================================
Install       5 Package(s)
Upgrade       3 Package(s)

Total download size: 2.9 M
Downloading Packages:
(1/8): apr-util-devel-1.2.7-11.el5_5.2.x86_64.rpm                                                              |  53 kB     00:00
(2/8): mod_ssl-2.2.3-53.el5.centos.1.x86_64.rpm                                                                |  94 kB     00:00
(3/8): httpd-devel-2.2.3-53.el5.centos.1.x86_64.rpm                                                            | 151 kB     00:00
(4/8): httpd-devel-2.2.3-53.el5.centos.1.i386.rpm                                                              | 151 kB     00:00
(5/8): apr-devel-1.2.7-11.el5_6.5.i386.rpm                                                                     | 233 kB     00:00
(6/8): apr-devel-1.2.7-11.el5_6.5.x86_64.rpm                                                                   | 238 kB     00:00
(7/8): httpd-manual-2.2.3-53.el5.centos.1.x86_64.rpm                                                           | 815 kB     00:00
(8/8): httpd-2.2.3-53.el5.centos.1.x86_64.rpm                                                                  | 1.2 MB     00:00
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                 1.3 MB/s | 2.9 MB     00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : httpd                                                                                                         1/11
  Installing     : apr-devel                                                                                                     2/11
  Updating       : mod_ssl                                                                                                       3/11
  Installing     : apr-util-devel                                                                                                4/11
  Updating       : httpd-manual                                                                                                  5/11
  Installing     : httpd-devel                                                                                                   6/11
  Installing     : httpd-devel                                                                                                   7/11
  Installing     : apr-devel                                                                                                     8/11
  Cleanup        : httpd-manual                                                                                                  9/11
  Cleanup        : httpd                                                                                                        10/11
  Cleanup        : mod_ssl                                                                                                      11/11

Installed:
  apr-devel.i386 0:1.2.7-11.el5_6.5              apr-devel.x86_64 0:1.2.7-11.el5_6.5     httpd-devel.i386 0:2.2.3-53.el5.centos.1
  httpd-devel.x86_64 0:2.2.3-53.el5.centos.1

Dependency Installed:
  apr-util-devel.x86_64 0:1.2.7-11.el5_5.2

Dependency Updated:
  httpd.x86_64 0:2.2.3-53.el5.centos.1     httpd-manual.x86_64 0:2.2.3-53.el5.centos.1     mod_ssl.x86_64 1:2.2.3-53.el5.centos.1

Complete!
[root@rails01 ~]#

■Passengerのインストール
[root@rails01 ~]# gem install passenger
Building native extensions.  This could take a while...
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-0.2.6
Successfully installed passenger-3.0.9
3 gems installed
Installing ri documentation for fastthread-1.0.7...
Installing ri documentation for daemon_controller-0.2.6...
Installing ri documentation for passenger-3.0.9...
Installing RDoc documentation for fastthread-1.0.7...
Installing RDoc documentation for daemon_controller-0.2.6...
Installing RDoc documentation for passenger-3.0.9...


■Apacheモジュールのビルドとインストール
[root@rails01 ~]# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.9.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 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++
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/local/bin/rake
 * rack... found
 * Apache 2... found at /usr/sbin/httpd
 * Apache 2 development headers... found at /usr/sbin/apxs
 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config

--------------------------------------------
Compiling and installing Apache 2 module...
cd /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
(中略)

--------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
   PassengerRuby /usr/local/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.


--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

   
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      
   

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/doc/Users guide Apache.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.
[root@rails01 ~]#

■passenger.confの作成
[root@rails01 ~]# vi /etc/httpd/conf.d/passenger.conf
[root@rails01 ~]# cat /etc/httpd/conf.d/passenger.conf
# 20110920 output ob "passenger-install-apache2-module"
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
PassengerRuby /usr/local/bin/ruby

# rails settings
RailsBaseURI /sample


⇒VirtualHostは使用せずにシンボリックリンクで対応。
[root@rails01 ~]# cd /var/www/html/
[root@rails01 html]# ln -s /root/rails_projects/sample/public sample

⇒apacheアカウントでアクセスできるようchange owner
[root@rails01 ~]# chown -R apache: /root/rails_projects/sample

⇒httpd再起動
[root@rails01 ~]# /etc/init.d/httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]


■ブラウザで確認
http://192.168.1.12/sample

Forbidden
You don't have permission to access /sample on this server.
------------------------------------------------------------------
Apache/2.2.3 (CentOS) Server at 192.168.1.12 Port 80

⇒apacheアカウントにowner変更しても/rootディレクトリ以下にはアクセスできないようだ…。


■Rubyプロジェクトディレクトリの変更
[root@rails01 ~]# cp -pr /root/rails_projects /

⇒シンボリックリンクも貼り直し
[root@rails01 ~]# cd /var/www/html/
[root@rails01 html]# rm sample
rm: remove シンボリックリンク `sample'? y
[root@rails01 html]# ln -s /rails_projects/sample/public sample

⇒httpd再起動し、ブラウザで確認
http://192.168.1.12/sample

passengerのエラー画面が表示される
Ruby on Rails application could not be started
Error message:
Unknown database 'sample_production' (Mysql2::Error)

デフォルトではproductionデータベースにアクセスしているようなので、passenger.confを修正
ちなみに、WEBrickで起動すれば問題なくアクセス可能
http://192.168.1.12:3000/

[root@rails01 ~]# vi /etc/httpd/conf.d/passenger.conf
[root@rails01 ~]# cat /etc/httpd/conf.d/passenger.conf
# 20110920 output ob "passenger-install-apache2-module"
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
PassengerRuby /usr/local/bin/ruby

# rails settings
RailsBaseURI /sample
RailsEnv development
[root@rails01 ~]#

⇒httpd再起動し、ブラウザで確認
http://192.168.1.12/sample →デフォルトページ(Welcome aboard)が表示される
http://192.168.1.12/sample/tbl_vms →前回scaffoldで作成したページが表示される

2011年9月20日火曜日

scaffoldでサンプル作成

■テーブル定義
テーブル名:tbl_vms
 VM名:vm_name:string
 備考:remarks:text
 所有者ID:owner_id:integer

■scaffold実施
[root@rails01 ~]# cd rails_projects/sample/
[root@rails01 sample]# rails g scaffold tbl_vms vm_name:string remarks:text owner_id:integer
Plural version of the model detected, using singularized version. Override with --force-plural.
      invoke  active_record
      create    db/migrate/20110919145646_create_tbl_vms.rb
      create    app/models/tbl_vm.rb
      invoke    test_unit
      create      test/unit/tbl_vm_test.rb
      create      test/fixtures/tbl_vms.yml
       route  resources :tbl_vms
      invoke  scaffold_controller
      create    app/controllers/tbl_vms_controller.rb
      invoke    erb
      create      app/views/tbl_vms
      create      app/views/tbl_vms/index.html.erb
      create      app/views/tbl_vms/edit.html.erb
      create      app/views/tbl_vms/show.html.erb
      create      app/views/tbl_vms/new.html.erb
      create      app/views/tbl_vms/_form.html.erb
      invoke    test_unit
      create      test/functional/tbl_vms_controller_test.rb
      invoke    helper
      create      app/helpers/tbl_vms_helper.rb
      invoke      test_unit
      create        test/unit/helpers/tbl_vms_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/tbl_vms.js.coffee
      invoke    scss
      create      app/assets/stylesheets/tbl_vms.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss
[root@rails01 sample]#

■テーブル作成
[root@rails01 sample]# rake db:migrate
(in /root/rails_projects/sample)
==  CreateTblVms: migrating ===================================================
-- create_table(:tbl_vms)
   -> 0.0400s
==  CreateTblVms: migrated (0.0405s) ==========================================

[root@rails01 sample]#

⇒mysql上で確認
mysql> show tables;
+------------------------------+
| Tables_in_sample_development |
+------------------------------+
| schema_migrations            |
| tbl_vms                      |
+------------------------------+
2 rows in set (0.00 sec)

mysql> desc tbl_vms;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | int(11)      | NO   | PRI | NULL    | auto_increment |
| vm_name    | varchar(255) | YES  |     | NULL    |                |
| remarks    | text         | YES  |     | NULL    |                |
| owner_id   | int(11)      | YES  |     | NULL    |                |
| created_at | datetime     | YES  |     | NULL    |                |
| updated_at | datetime     | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

■ブラウザで確認
http://192.168.1.14:3000/tbl_vms/

2011年9月19日月曜日

CentOS5.7にRuby1.9.2インストール

■OSバンドルのRuby有無確認
[root@rails01 ~]# rpm -qa | grep ruby
[root@rails01 ~]#
⇒既存Rubyは存在しないのでOK!


■インストーラダウンロード
ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
smb経由でサーバのsrcディレクトリにアップロード。


■インストール
[root@rails01 ~]# cd /home/public/src/
[root@rails01 src]# tar -zxf ruby-1.9.2-p290.tar.gz
[root@rails01 src]# cd ruby-1.9.2-p290
[root@rails01 ruby-1.9.2-p290]# ./configure --prefix=/usr/local
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
(中略)
ruby library version = 1.9.1
configure: creating ./config.status
config.status: creating Makefile

[root@rails01 ruby-1.9.2-p290]# make
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initiali                                    zers -Wno-long-long -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT   -o main.o -c main.c
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initiali                                    zers -Wno-long-long -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT   -o dln.o -c dln.c
(中略:10分くらい)
Generating file member index...
Generating page index...
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb  -e 'File.open("doc/capi/.timestamp", "w"){|f| f.puts(Time.now)}'

[root@rails01 ruby-1.9.2-p290]# make install
(中略)
installing manpages:          /usr/local/ruby/share/man/man1
installing default gems:      /usr/local/ruby/lib/ruby/gems/1.9.1 (cache, doc, gems, specifications)
                              rake 0.8.7
                              rdoc 2.5.8
                              minitest 1.6.0
⇒バージョン確認
[root@rails01 ~]# ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
[root@rails01 ~]# gem -v
1.3.7


■Railsインストール
[root@rails01 ~]# gem install rails
Building native extensions.  This could take a while...
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed multi_json-1.0.3
Successfully installed activesupport-3.1.0
Successfully installed builder-3.0.0
Successfully installed i18n-0.6.0
Successfully installed bcrypt-ruby-3.0.1
Successfully installed activemodel-3.1.0
Successfully installed rack-1.3.3
Successfully installed rack-cache-1.0.3
Successfully installed rack-test-0.6.1
Successfully installed rack-mount-0.8.3
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.0.0
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.1.0
Successfully installed arel-2.2.1
Successfully installed tzinfo-0.3.29
Successfully installed activerecord-3.1.0
Successfully installed activeresource-3.1.0
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.2
Successfully installed treetop-1.4.10
Successfully installed mail-2.3.0
Successfully installed actionmailer-3.1.0
Successfully installed thor-0.14.6
Successfully installed rack-ssl-1.3.2
Successfully installed rdoc-3.9.4
Successfully installed railties-3.1.0
Successfully installed bundler-1.0.18
Successfully installed rails-3.1.0
30 gems installed
Installing ri documentation for multi_json-1.0.3...
Installing ri documentation for activesupport-3.1.0...
Installing ri documentation for builder-3.0.0...
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping
Installing ri documentation for i18n-0.6.0...
Installing ri documentation for bcrypt-ruby-3.0.1...
Installing ri documentation for activemodel-3.1.0...
Installing ri documentation for rack-1.3.3...
Installing ri documentation for rack-cache-1.0.3...
Installing ri documentation for rack-test-0.6.1...
Installing ri documentation for rack-mount-0.8.3...
Installing ri documentation for hike-1.2.1...
Installing ri documentation for tilt-1.3.3...
Installing ri documentation for sprockets-2.0.0...
Installing ri documentation for erubis-2.7.0...
Installing ri documentation for actionpack-3.1.0...
Installing ri documentation for arel-2.2.1...
Installing ri documentation for tzinfo-0.3.29...
Installing ri documentation for activerecord-3.1.0...
Installing ri documentation for activeresource-3.1.0...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.2...
Installing ri documentation for treetop-1.4.10...
Installing ri documentation for mail-2.3.0...
Installing ri documentation for actionmailer-3.1.0...
Installing ri documentation for thor-0.14.6...
Installing ri documentation for rack-ssl-1.3.2...
Installing ri documentation for rdoc-3.9.4...
Installing ri documentation for railties-3.1.0...
Installing ri documentation for bundler-1.0.18...
Installing ri documentation for rails-3.1.0...
file 'lib' not found
Installing RDoc documentation for multi_json-1.0.3...
Installing RDoc documentation for activesupport-3.1.0...
Installing RDoc documentation for builder-3.0.0...
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping
unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping
Installing RDoc documentation for i18n-0.6.0...
Installing RDoc documentation for bcrypt-ruby-3.0.1...
Installing RDoc documentation for activemodel-3.1.0...
Installing RDoc documentation for rack-1.3.3...
Installing RDoc documentation for rack-cache-1.0.3...
Installing RDoc documentation for rack-test-0.6.1...
Installing RDoc documentation for rack-mount-0.8.3...
Installing RDoc documentation for hike-1.2.1...
Installing RDoc documentation for tilt-1.3.3...
Installing RDoc documentation for sprockets-2.0.0...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for actionpack-3.1.0...
Installing RDoc documentation for arel-2.2.1...
Installing RDoc documentation for tzinfo-0.3.29...
Installing RDoc documentation for activerecord-3.1.0...
Installing RDoc documentation for activeresource-3.1.0...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.2...
Installing RDoc documentation for treetop-1.4.10...
Installing RDoc documentation for mail-2.3.0...
Installing RDoc documentation for actionmailer-3.1.0...
Installing RDoc documentation for thor-0.14.6...
Installing RDoc documentation for rack-ssl-1.3.2...
Installing RDoc documentation for rdoc-3.9.4...
Installing RDoc documentation for railties-3.1.0...
Installing RDoc documentation for bundler-1.0.18...
Installing RDoc documentation for rails-3.1.0...
file 'lib' not found

⇒バージョン確認
[root@rails01 ~]# rails --version
Rails 3.1.0


■サンプルプロジェクト作成
[root@rails01 ~]# mkdir rails_projects
[root@rails01 ~]# cd rails_projects/
[root@rails01 rails_projects]# rails new sample -d mysql
      create
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching source index for http://rubygems.org/
Installing rake (0.9.2)
Using multi_json (1.0.3)
Using activesupport (3.1.0)
Using bcrypt-ruby (3.0.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.0)
Using erubis (2.7.0)
Using rack (1.3.3)
Using rack-cache (1.0.3)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.0)
Using actionpack (3.1.0)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.0)
Using arel (2.2.1)
Using tzinfo (0.3.29)
Using activerecord (3.1.0)
Using activeresource (3.1.0)
Installing ansi (1.3.0)
Using bundler (1.0.18)
Installing coffee-script-source (1.1.2)
Installing execjs (1.2.6)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.9.4)
Using thor (0.14.6)
Using railties (3.1.0)
Installing coffee-rails (3.1.1)
Installing jquery-rails (1.0.14)
Installing mysql2 (0.3.7) with native extensions
Using rails (3.1.0)
Installing sass (3.1.7)
Installing sass-rails (3.1.2)
Installing turn (0.8.2)
Installing uglifier (1.0.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
[root@rails01 rails_projects]#


■データベース準備
[root@rails01 ~]# /etc/init.d/mysqld start
MySQL を起動中:                                            [  OK  ]

⇒プロジェクトディレクトリに移動してデータベース作成
[root@rails01 ~]# cd /root/rails_projects/sample/
[root@rails01 sample]# rake db:create
(in /root/rails_projects/sample)
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.6/lib/execjs/runtimes.rb:46:in `autodetect'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.6/lib/execjs.rb:5:in `'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.2.6/lib/execjs.rb:4:in `'
(中略)
/usr/local/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/local/bin/rake:31:in `
' ⇒上記エラー対応のためGemfile修正 [root@rails01 sample]# vi Gemfile [root@rails01 sample]# head Gemfile source 'http://rubygems.org' gem 'rails', '3.1.0' # add 20110919 gem 'therubyracer' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' [root@rails01 sample]# bundle update Fetching source index for http://rubygems.org/ (中略) Installing therubyracer (0.9.4) with native extensions Using turn (0.8.2) Using uglifier (1.0.3) Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed. ⇒再びデータベース作成 [root@rails01 sample]# rake db:create (in /root/rails_projects/sample) rake aborted! uninitialized constant Rake::DSL /usr/local/lib/ruby/1.9.1/rake.rb:2482:in `const_missing' (後略) ⇒上記エラー対応のためGemfile修正 [root@rails01 sample]# vi Gemfile [root@rails01 sample]# head Gemfile source 'http://rubygems.org' gem 'rails', '3.1.0' # add 20110919 gem 'therubyracer' gem 'rake', '0.8.7' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' [root@rails01 sample]# bundle update Fetching source index for http://rubygems.org/ Using rake (0.8.7) Using multi_json (1.0.3) (後略) ⇒再びデータベース作成 [root@rails01 sample]# rake db:create (in /root/rails_projects/sample) [root@rails01 sample]# mysqlshow +--------------------+ | Databases | +--------------------+ | information_schema | | mysql | | sample_development | | sample_test | | test | +--------------------+ データベースが作成された!! ■Webサーバ起動 [root@rails01 sample]# rails s => Booting WEBrick => Rails 3.1.0 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2011-09-19 22:43:01] INFO WEBrick 1.3.1 [2011-09-19 22:43:01] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux] [2011-09-19 22:43:01] INFO WEBrick::HTTPServer#start: pid=12327 port=3000 または、 [root@rails01 sample]# rails s > log/WEBrick.log & [1] 25595 ■ブラウザで確認 http://192.168.1.14:3000/