2010/02/24 (Wed)

Setting of Share Folder

フォルダ共有

共有するフォルダを作成し、ゲストOSの設定からデバイス>共有フォルダから追加する。

カーネルのインストール

# yum install kernel-devel

ゲストOSの設定からデバイス>Guest Additionsのインストールを選択し、マウントする。

# cd /mnt/
# mkdir /cdrom
# mount /dev/cdrom /mnt/cdrom

VBoxLinuxAdditions-x86.runを実行する。

# cd /mnt/cdrom
# ./VBoxLinuxAdditions-x86.run

共有フォルダをマウントする。

# mkdir /mnt/share
# mount -t vboxsf VBoxShare /mnt/share

起動時にマウントするように設定する。

# vi /etc/rc.local

マウントポイントを追加する

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# 
mount -t vboxsf share /mnt/share

Setting of Network

ネットワークアダプタ

ゲストOSの設定>ネットワークからネットワークアダプタの設定をし、 ホストとゲスト間の通信を許可し、ゲストから外部への通信を許可する設定を行う。

  • アダプタ1に「ホストオンリーネットワーク」を割り当てる。
  • アダプタ2に「NAT」を割り当てる。

IPアドレスを固定する

アダプタの設定

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPを固定にする

DEVICE=eth0
BOOTPROTO=static
HWADDR=08:00:27:2C:06:13
ONBOOT=yes
IPADDR=192.168.56.102
NETMASK=255.255.255.0

アダプタの再起動

# ifdown eth0
# ifup eth0

2009/06/17 (Wed)

RedMine環境の構築

Ruby のインストール

# yum install ruby-devel ruby-rdoc ruby-irb
# yum install rubygems

# gem update --system
# gem install rubygems-update
# update_rubygems
# gem install rake

ImageMagick のインストール

新しいのが必要なので、yumだと古かった。

$ tar xzvf ImageMagick.tar.gz 
$ cd ImageMagick-6.4.2
$ ./configure
$ make 
# make install

# gem install rmagick

MySQLのインストール

# yum install mysql-server

Rails のインストール

# gem install -v=2.2.2 rails
# gem install mysql -- --with-mysql-dir=/usr/lib/mysql --with-mysql-config

RedMineのインストール

$ svn co http://redmine.rubyforge.org/svn/trunk redmine

設定のファイルを修正

config/database.yml

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: 
  encoding: utf8
  socket: /var/lib/mysql/mysql.sock

MySQLにRedMineアカウントを追加

mysql> GRANT ALL PRIVILEGES ON *.* TO 'redmine'@'%';
    -> IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'redmine'@'localhost';
    -> IDENTIFIED BY 'password' WITH GRANT OPTION;

DBの移行

$ mysqladmin create --default-character-set=utf8 redmine
$ mysql -u redmine -p redmine < redmine.dump.sql

DBのmigrate

$ rake db:migrate RAILS_NEW="production"

fileの移行

$ scp from.localnet:~redmine/redmine/files/* ./files/

起動テスト

$ ruby script/server -e production

w3m http://localhost:3000/

Internal Server Error とか出たら、log/production.log を確認
config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" }
を config/environment.rb に設定しろとか書いてあったりする。

Passenger のインストール

$ gem install passenger
 2. fastthread 1.0.1 (ruby)

$ export PATH=$PATH:/usr/local/apache2/bin
$ export APXS2=/usr/local/apache2/bin/apxs
$ export APR_CONFIG=/usr/local/apache2/bin/apr-1-config
$ passenger-install-apache2-module
  1. The Apache 2 module will be installed for you. 足りないものを入れる。gppとか

Apache の設定

  LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.2
   PassengerRuby /usr/bin/ruby
   <VirtualHost *:80>
      ServerName redmine.xxxxxxxx.jp
      DocumentRoot /opt/redmine/redmine/public
   </VirtualHost>

Apache2 の 403とかだと Deny from allをチェック

2009/03/31 (Tue)

SELinuxの無効化

SELinuxの状態確認

# getenforce
Enforcing

SELinux無効化

# setenforce 0

# getenforce
Permissive

SELinux設定ファイル編集

# vi /etc/sysconfig/selinux
SELINUX=enforcing
↓
SELINUX=disabled

iptables の停止

# /etc/init.d/iptables stop

iptables を停止せず、httpを通す設定を追加する場合。 /etc/sysconfig/iptables を編集

-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

真ん中の行を追加する。

Apacheの起動スクリプト

#!/bin/sh
# chkconfig: 345 98 20
# description: This shell script tabke care of starting and stopping httpd.
# processname: httpd
#
# httpd         This shell script takes care of starting and stopping
#               httpd.
#
# 

RETVAL=0
prog="/usr/local/apache2/bin/apachectl"

# See how we were called.
case "$1" in
  start)
        $prog startssl
        RETVAL=$?
        ;;
  stop)
        $prog stop
        RETVAL=$?
        ;;
  status)
        $prog status
        RETVAL=$?
        ;;
  restart|reload)
        $prog restart
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit $RETVAL

chkconfigで自作の起動スクリプトを登録

# chkconfig: 345 98 20
# description: This shell script tabke care of starting and stopping httpd.
# processname: httpd

起動スクリプトのヘッダにchkconfig用の記述をする。 上から、ランレベル、起動優先順位、停止優先順位

/sbin/chkconfig --add httpd
/sbin/chkconfig --level 345 httpd on
/sbin/chkconfig --list