最近、ノートパソコン片手に喫茶店とかで遊ぶ事が多いのですが、そんな時に困るのが開発環境です。
回線が強ければ、自宅サーバやさくらVPS繋げば良いのですが、回線が弱い所だとリモートの開発環境繋いでの作業が辛かったりします。
そんな時に便利なローカル開発環境についての構築メモです。((何回か同じ様な事を聞かれたので多少は需要あるのかな?というか俺得メモ))
- 欲しいもの
- 持ち運べる開発環境
- 仮想マシンで作ると他の環境に移行とかもラクチンで良いかも
- OSはCentOSかな
- パッケージはRPMで管理したい
- パッケージは出来るだけ最新のバージョンを使いたい
材料
ハードウエア
name | type |
---|---|
Lenovo ThinkPad X201 | |
CPU | Intel Core i5 M520 @2.4GHz |
Memory | DDR3 @8GB |
SSD | Intel X25-M @80GB(C:) + Wintec ExpressCard @48GB(D:) |
ソフトウエア
- Windows 7 Home Premium (64bit)
- VMware Player 3.1.3 build-324285
- Tera Term 4.67
作る物
- CentOS
# cat /etc/redhat-release
CentOS release 5.5 (Final)
# uname -a
Linux localhost.localdomain 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:52:25 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
- Apache
# /usr/sbin/httpd -v
Server version: Apache/2.2.3
Server built: Aug 30 2010 12:28:40
- MySQL
# mysql --version
mysql Ver 14.14 Distrib 5.5.8, for Linux (x86_64) using readline 5.1
- PHP
# php -v
PHP 5.3.5 (cli) (built: Jan 7 2011 18:52:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
- Ruby
# ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
- Git
# git --version
git version 1.7.3
- Subversion
# svn --version
svn, version 1.4.2 (r22196)
compiled Aug 10 2009, 17:54:46
事前準備
VMware Playerのセットアップファイルを入手
- VMware PlayerはVMware内の公式サイトからダウンロードする事が出来ます。
- ページ下部にあるVMware Player のダウンロードをクリックし、
ユーザ登録すればダウンロードページに移動しますので、そのままダウンロードします。 - ちなみに自分がダウンロードしたのはVMware-player-3.1.3-324285.exeです。
CentOS 5.5 x86_64のISOファイルを入手
- CentOS 5.5 x86_64はCentO公式サイトのダウンロードページから
お好きなミラーサイトを選んでダウンロードする事ができます。 - 今回はIIJさんのミラーサイトからnetinstallタイプのISOをダウンロードさせてもらいます。
- [http://ftp.iij.ad.jp/pub/linux/centos/5.5/isos/x86_64/CentOS-5.5-x86_64-netinstall.iso]
VMware Playerのインストール
VMware Playerのインストールは特に説明する事がありません。
ダンロードしたexeファイルをダブルクリックして起動しあとは、ウィザードに沿って行けばインストール完了です。
CentOSをインストール(Netinstallでセットアップ)
- インストールが完了するとこの様な画面が立ち上がるので「新規仮想マシンの作成(N)」をクリック

- 「新規仮想マシン作成ウィザードへようこそ」が立ち上がるので「インストーラディスク イメージファイル(M) (iso):」の項目で「参照(R)…」から
ダウンロードしたCentOS 5.5 x86_64のISOファイルを選択し「次へ(N)>」をクリック

- 「ゲストOSの選択」では、ラジオボタンで「Linux(L)」を選択し、「バージョン(V)」の項目で「CentOS 64ビット」を選択し「次へ(N) >」をクリック

- 「仮想マシンの名前」では、「仮想マシン名(V):」と「格納場所(L):」を適当に入力し「次へ(N) >」をクリック
- 自分は以下の通り設定
- 仮想マシン名 : CentOS_55_64bit
- 格納場所 : 専用に作成したDドライブ配下

- 「ディスクの容量の指定」では、「ディスクの最大サイズ(S) (GB):」が決められますが、とりあえずデフォルトの20GBに設定し「次へ(N) >」をクリック
-仮にここで1TBとか指定しても、仮想マシン内部で実際に使用されている容量のみ消費するため心配ありません。
インストール直後のHDD使用サイズは約6GBです。

- 「仮想マシンを作成する準備完了」となったら、「完了」をクリックして準備完了です。

- ちょっと待ってるとCentOSのインストーラが起動してくるので、ターミナル内にフォーカスを合わせて「Enterキー」を押します
- ターミナル内に合わせたフォーカスを解除するには「Ctrlキー+Altキー」を押します。

- 言語選択画面になるので、使用する言語を選択します。
- 自分はの場合は英語を使用するので、「English」を選択して「OK」を選択し「Enterキー」を押します。

- キーボード選択画面になるので、使用するキーボードを選択します。
- 自分の場合は英字キーボードを使用するので、「us」を選択して「OK」を選択し「Enterキー」を押します
- 日本語キーボードの場合は「jp106」を選択

- インストール方法を選択する画面になるので、「HTTP」を選択して「OK」を選択し「Enterキー」を押します。
- ネットワークの選択画面になるのでデフォルトのまま「OK」を選択し「Enterキー」を押します。
- インストール元のサイトを入力する画面になるので、次の通り設定し「Enterキー」を押します。
- Web Site name : ftp.iij.ad.jp
- CnetOS directory : /pub/linux/centos/5.5/os/x86_64/

- しばらくするとセットアップウィザードが立ち上がるので「Next」をクリック

- HDD内のデータ消すけど良いかい?と聞いてくので「Yes」をクリック
- ここで削除されるのはVMwarePlayer用に作成した領域なので心配なし

- インストールするパーティションサイズの変更が出来ますが、デフォルトのまま使うので「Next」をクリック
- 本当にHDD内のデータ消すけど良いか再確認してくるので「Yes」をクリック
- ネットワークの設定もデフォルトのまま使うので「Next」をクリック
- 時間設定は「Asia/Tokyo」を選択し「Next」をクリック
- 管理者権限のパスワードを設定します、適当なパスワードを2回入力し「Next」をクリック
- パッケージ選択画面になるのでラジオボタンで「Customize now」を選択し「Next」をクリック

- 初期構成としてインストールするパッケージを選択する画面になるので以下のパッケージ以外全てチェックを外し、「Next」をクリック
- Base System 内の Base

- これでインストール設定は完了なので「Next」をクリック

- しばらく放置すると完了するので、VMware Playerの「インストールを完了しました」をクリックの上、コンソール内の「Reboot」をクリック


CentOSの設定
FirewallとSELinuxを無効にする
- 再起動後、Setup Agentの画面が開いたら「Firewall configuration」を選択して「Run Tool」を選択し「Enterキー」を押します

- Firewall configurationの画面が開くので以下の通り選択して、「OK」を選択し「Enterキー」を押します。
- Security Level : Disabled
- SELinux : Disabled
- 今回はローカルの開発環境を想定しているため、FWもSELinuxも外してしまいます。

- Setup Agentの画面に戻るので「Exit」を選択し「Enterキー」を押します。

作業用ユーザを作る
# useradd [作業用ユーザ名]<Enter>
# passwd [作業用ユーザ名]<Enter>
Changing password for user devuser.
New UNIX password: [作業用ユーザのパスワード]<Enter>
Retype new UNIX password: [もう一度作業用ユーザのパスワード]<Enter>
passwd: all authentication tokens updated successfully.
#

仮想マシンのIPアドレスを確認する
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:9C:EC:13
inet addr:[仮想マシンのIPアドレス] Bcast:192.168.230.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9c:ec13/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1564 errors:0 dropped:0 overruns:0 frame:0
TX packets:600 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:205938 (201.1 KiB) TX bytes:93554 (91.3 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:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:200 (200.0 b) TX bytes:200 (200.0 b)
#

TeraTermで作業ユーザとしてログイン
- Host:に先ほど確認した「仮想マシンのIPアドレス」を入力して「OK」をクリック

- 一番最初に繋いだ時だけセキュリティ警告が出ますが、「Continue」をクリック((このホスト本当に合ってる?みたいな事を聞いている))

- 認証画面になったら、User name:に先ほど設定した管理ユーザ名、Passphrease:に先ほど設定した「作業用ユーザのパスワード」を入力

- ログイン完了

管理者権限を取得
- 引き続きTeraTerm上から環境設定をしていくため、管理者権限を取得
$ su -
Password: [管理者権限のパスワード]
#
不要なデーモンを止める
- モバイル開発環境なのでバッテリーに優しく!不要なデーモンは止める((どれくらいバッテリー延命に効果があるのが不明ですがw))
# chkconfig acpid off
# chkconfig anacron off
# chkconfig atd off
# chkconfig autofs off
# chkconfig avahi-daemon off
# chkconfig bluetooth off
# chkconfig cpuspeed off
# chkconfig cups off
# chkconfig firstboot off
# chkconfig gpm off
# chkconfig haldaemon off
# chkconfig hidd off
# chkconfig hplip off
# chkconfig ip6tables off
# chkconfig iptables off
# chkconfig kudzu off
# chkconfig --level 12345 lvm2-monitor off
# chkconfig mcstrans off
# chkconfig mdmonitor off
# chkconfig microcode_ctl off
# chkconfig netfs off
# chkconfig nfslock off
# chkconfig pcscd off
# chkconfig portmap off
# chkconfig rawdevices off
# chkconfig readahead_early off
# chkconfig --level 5 readahead_later off
# chkconfig restorecond off
# chkconfig rpcgssd off
# chkconfig rpcidmapd off
# chkconfig sendmail off
# chkconfig smartd off
# chkconfig xfs off
# chkconfig yum-updatesd off
使わないデーモンを削除
# yum -y remove NetworkManager anacron autofs avahi firstboot-tui gpm irda-utils wpa_supplicant yum-updatesd
yum環境を構築
- 各種リポジトリをセットアップして便利な世界を構築する
Dagリポジトリ追加
# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt
# rm -f RPM-GPG-KEY.dag.txt
# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el5/en/$basearch/dag/ gpgcheck=1 enabled=0 #
EPELリポジトリ追加
# wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm
# rm -f epel-release-5-4.noarch.rpm
#
Remiリポジトリ追加
# wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# rpm --import RPM-GPG-KEY-remi
# rpm -Uvh remi-release-5.rpm
# rm -f RPM-GPG-KEY-remi remi-release-5.rpm
#
確認
- このCentOSから利用出来るyumリポジトリの一覧を表示する
# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: ftp.jaist.ac.jp
* base: ftp.jaist.ac.jp
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp
epel | 3.7 kB 00:00
epel/primary_db | 3.5 MB 00:00
repo id repo name status
addons CentOS-5 - Addons enabled: 0
base CentOS-5 - Base enabled: 3,434
c5-media CentOS-5 - Media disabled
centosplus CentOS-5 - Plus disabled
contrib CentOS-5 - Contrib disabled
dag Dag RPM Repository for Fedora Core disabled
epel Extra Packages for Enterprise Linux 5 - x86_64 enabled: 6,073
epel-debuginfo Extra Packages for Enterprise Linux 5 - x86_64 - Debug disabled
epel-source Extra Packages for Enterprise Linux 5 - x86_64 - Source disabled
epel-testing Extra Packages for Enterprise Linux 5 - Testing - x86_64 disabled
epel-testing-debuginfo Extra Packages for Enterprise Linux 5 - Testing - x86_64 - Debug disabled
epel-testing-source Extra Packages for Enterprise Linux 5 - Testing - x86_64 - Source disabled
extras CentOS-5 - Extras enabled: 303
remi Les RPM de remi pour Enterprise Linux 5 - x86_64 disabled
remi-test Les RPM de remi en test pour Enterprise Linux 5 - x86_64 disabled
updates CentOS-5 - Updates enabled: 1,135
repolist: 10,945
#
OSおよびパッケージを最新の状態に更新する
- yum updateでパッケージを最新版にして再起動!
# yum -y update
・
・だーっとログが流れる
・
Complete!
# shutdown -r now
vmware-toolsのインストール
- 再起動が完了したら、VMwareのドライバやユーティリティがパッケージされた「vmware-tools」をインストールする
-vmware-toolsには仮想マシンをVMwareに最適化するためのドライバ等が含まれており、インストールするだけでCPUの負荷を多少減らす事が出来る。 - VMwarePlayerのコンソール画面にてメニューの「仮想マシン」をクリックし、「VMware Toolsのインストール(T)…」をクリック

- コンソール画面からCentOSにログインしVMware Toolsの入ったドライブをマウントしインストールし、再起動
# mount /dev/cdrom /mnt
# cp -p /mnt/VMwareTools-8.4.5-32485.tar.gz ./
# tar zxf ./VMwareTools-8.4.5-32485.tar.gz
# ./vmware-tools-distrib/vmware-install.pl -d
・
・だーっとログが流れる
・
Found VMware Tools CDROM mounted at /mnt. Ejecting device /dev/cdrom ...
# rm -rf ./vmware-tools-distrib ./VMwareTools-8.4.5-32485.tar.gz
# shutdown -r now

ミドルウエアのインストール
- TeraTermでログインしてサクサクインストールと設定をしていく
Apacheのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install httpd.x86_64
# /usr/sbin/httpd -v
Server version: Apache/2.2.3
Server built: Aug 30 2010 12:28:40
MySQLのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install mysql.x86_64 mysql-server.x86_64
# mysql --version
mysql Ver 14.14 Distrib 5.5.8, for Linux (x86_64) using readline 5.1
PHPのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install php.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-pear.noarch
# php -v
PHP 5.3.5 (cli) (built: Jan 7 2011 18:52:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Rubyのインストール
コンパイルに必要なパッケージをインストール
# yum --enablerepo=remi-test,remi,epel,dag,rpmforge install gcc.x86_64 zlib-devel.x86_64 rpm-build.x86_64 openssl-devel.x86_64 readline-devel.x86_64
chekinstall(RPM作成ツール)をインストール
- chekinstallの総本山からRPMパッケージを入手してインストールする
# wget http://packages.sw.be/checkinstall/checkinstall-1.6.0-3.el4.rf.x86_64.rpm
# rpm -Uvh checkinstall-1.6.0-3.el4.rf.x86_64.rpm
# rm -f checkinstall-1.6.0-3.el4.rf.x86_64.rpm
# checkinstall -v
checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.
#
Rubyのインストール
- ソースの取得
# wget http://core.ring.gr.jp/archives/lang/ruby/ruby-1.8.7-p330.tar.gz
- ソースからRPMパッケージを作成してインストール
# tar zvf ruby-1.8.7-p330.tar.gz
# cd ruby-1.8.7-p330
# ./configure --prefix=/usr
・
・だーっとログが流れる
・
# make && make test
・
・だーっとログが流れる
・
# checkinstall --fstrans=no
・
・だーっとログが流れる
・
# rpm -Uvh /usr/src/redhat/RPMS/x86_64/ruby-1.8.7-p330-1.x86_64.rpm
# ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
# cd ../
# rm -rf ruby-1.8.7-p330 ruby-1.8.7-p330.tar.gz
RubyGemsのインストール
- ソースの取得
# wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
- ソースからRPMパッケージを作成してインストール
# tar zvf rubygems-1.3.7.tgz
# cd rubygems-1.3.7
# checkinstall -R "ruby setup.rb"
・
・だーっとログが流れる
・
# rpm -Uvh /usr/src/redhat/RPMS/x86_64/rubygems-1.3.7-1.x86_64.rpm
# gem -v
1.3.7
# cd ../
# rm -rf rubygems-1.3.7 rubygems-1.3.7.tgz
#
Git/Subversionのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install git.x86_64 subversion.x86_64
# git --version
git version 1.7.3
# svn --version
svn, version 1.4.2 (r22196)
compiled Aug 10 2009, 17:54:46
phpMyAdminのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install phpMyAdmin
# ls /etc/phpMyAdmin/
config.inc.php
#
設定
MySQLの設定
- MySQLの起動・初期化
# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
110117 1:07:34 [ERROR] Function 'archive' already exists
110117 1:07:34 [ERROR] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
OK
Filling help tables...
110117 1:07:34 [ERROR] Function 'archive' already exists
110117 1:07:34 [ERROR] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
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 localhost.localdomain 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 /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
#
- MySQLのrootユーザにパスワードを設定 ※hogehogeと設定してみた
# /usr/bin/mysqladmin -u root password 'hogehoge'
# /usr/bin/mysqladmin -u root -h localhost.localdomain password 'hogehoge'
#
- OS起動時に自動的に起動する様に設定
# chkconfig mysqld on
[root@localhost ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#
phpMyAdminの設定
- アクセス元IP制限を調整する。デフォルトのままだと開発機のWindows上からアクセス出来ない
# vi /etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from ::1
</Directory>
↓こんな感じに追記
<Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from ::1
allow from 192.168.
</Directory>
#
Apaceの設定
- Apacheの設定・起動
# vi /etc/httpd/conf/httpd.conf
#ServerName www.example.com:80
↓こんな感じに追記
#ServerName www.example.com:80
ServerName localhost:80
# service httpd start
Starting httpd: [ OK ]
#
- OS起動時に自動的に起動する様に設定
# chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#
動作確認
- 開発機のブラウザから仮想マシンのIPにアクセスしてみる
http://192.168.230.130/
- こんな画面が表示される

- phpMyAdminにアクセス
http://192.168.230.130/phpMyAdmin
- こんな画面が表示されるので、先ほど設定したMySQLのrootユーザのパスワードを入力するとログイン出来る

完成!
- 動作確認が完了したらあとは開発に専念するだけ!ワーイヽ(゚∀゚)ノワーイ
参考にさせていただいたサイト
Title: 「喫茶店プログラミング」のための環境構築(VMwarePlayer + CentOS5.5+Apache2.2.3+MySQL5.5.8+PHP5.3.5+Ruby1.8.7+おまけ)
Tags: CentOS, git, MySQL, php, Ruby, Subversion, VMware, VMwarePlyaer, 技術ネタ
最近、ノートパソコン片手に喫茶店とかで遊ぶ事が多いのですが、そんな時に困るのが開発環境です。
回線が強ければ、自宅サーバやさくらVPS繋げば良いのですが、回線が弱い所だとリモートの開発環境繋いでの作業が辛かったりします。
そんな時に便利なローカル開発環境についての構築メモです。((何回か同じ様な事を聞かれたので多少は需要あるのかな?というか俺得メモ))
- 欲しいもの
- 持ち運べる開発環境
- 仮想マシンで作ると他の環境に移行とかもラクチンで良いかも
- OSはCentOSかな
- パッケージはRPMで管理したい
- パッケージは出来るだけ最新のバージョンを使いたい
[TOC]
材料
ハードウエア
name | type |
---|---|
Lenovo ThinkPad X201 | |
CPU | Intel Core i5 M520 @2.4GHz |
Memory | DDR3 @8GB |
SSD | Intel X25-M @80GB(C:) + Wintec ExpressCard @48GB(D:) |
ソフトウエア
- Windows 7 Home Premium (64bit)
- VMware Player 3.1.3 build-324285
- Tera Term 4.67
作る物
- CentOS
# cat /etc/redhat-release
CentOS release 5.5 (Final)
# uname -a
Linux localhost.localdomain 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:52:25 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
- Apache
# /usr/sbin/httpd -v
Server version: Apache/2.2.3
Server built: Aug 30 2010 12:28:40
- MySQL
# mysql --version
mysql Ver 14.14 Distrib 5.5.8, for Linux (x86_64) using readline 5.1
- PHP
# php -v
PHP 5.3.5 (cli) (built: Jan 7 2011 18:52:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
- Ruby
# ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
- Git
# git --version
git version 1.7.3
- Subversion
# svn --version
svn, version 1.4.2 (r22196)
compiled Aug 10 2009, 17:54:46
事前準備
VMware Playerのセットアップファイルを入手
- VMware PlayerはVMware内の公式サイトからダウンロードする事が出来ます。
- ページ下部にあるVMware Player のダウンロードをクリックし、
ユーザ登録すればダウンロードページに移動しますので、そのままダウンロードします。 - ちなみに自分がダウンロードしたのはVMware-player-3.1.3-324285.exeです。
CentOS 5.5 x86_64のISOファイルを入手
- CentOS 5.5 x86_64はCentO公式サイトのダウンロードページから
お好きなミラーサイトを選んでダウンロードする事ができます。 - 今回はIIJさんのミラーサイトからnetinstallタイプのISOをダウンロードさせてもらいます。
- [http://ftp.iij.ad.jp/pub/linux/centos/5.5/isos/x86_64/CentOS-5.5-x86_64-netinstall.iso]
VMware Playerのインストール
VMware Playerのインストールは特に説明する事がありません。
ダンロードしたexeファイルをダブルクリックして起動しあとは、ウィザードに沿って行けばインストール完了です。
CentOSをインストール(Netinstallでセットアップ)
- インストールが完了するとこの様な画面が立ち上がるので「新規仮想マシンの作成(N)」をクリック

- 「新規仮想マシン作成ウィザードへようこそ」が立ち上がるので「インストーラディスク イメージファイル(M) (iso):」の項目で「参照(R)…」から
ダウンロードしたCentOS 5.5 x86_64のISOファイルを選択し「次へ(N)>」をクリック

- 「ゲストOSの選択」では、ラジオボタンで「Linux(L)」を選択し、「バージョン(V)」の項目で「CentOS 64ビット」を選択し「次へ(N) >」をクリック

- 「仮想マシンの名前」では、「仮想マシン名(V):」と「格納場所(L):」を適当に入力し「次へ(N) >」をクリック
- 自分は以下の通り設定
- 仮想マシン名 : CentOS_55_64bit
- 格納場所 : 専用に作成したDドライブ配下

- 「ディスクの容量の指定」では、「ディスクの最大サイズ(S) (GB):」が決められますが、とりあえずデフォルトの20GBに設定し「次へ(N) >」をクリック
-仮にここで1TBとか指定しても、仮想マシン内部で実際に使用されている容量のみ消費するため心配ありません。
インストール直後のHDD使用サイズは約6GBです。

- 「仮想マシンを作成する準備完了」となったら、「完了」をクリックして準備完了です。

- ちょっと待ってるとCentOSのインストーラが起動してくるので、ターミナル内にフォーカスを合わせて「Enterキー」を押します
- ターミナル内に合わせたフォーカスを解除するには「Ctrlキー+Altキー」を押します。

- 言語選択画面になるので、使用する言語を選択します。
- 自分はの場合は英語を使用するので、「English」を選択して「OK」を選択し「Enterキー」を押します。

- キーボード選択画面になるので、使用するキーボードを選択します。
- 自分の場合は英字キーボードを使用するので、「us」を選択して「OK」を選択し「Enterキー」を押します
- 日本語キーボードの場合は「jp106」を選択

- インストール方法を選択する画面になるので、「HTTP」を選択して「OK」を選択し「Enterキー」を押します。
- ネットワークの選択画面になるのでデフォルトのまま「OK」を選択し「Enterキー」を押します。
- インストール元のサイトを入力する画面になるので、次の通り設定し「Enterキー」を押します。
- Web Site name : ftp.iij.ad.jp
- CnetOS directory : /pub/linux/centos/5.5/os/x86_64/

- しばらくするとセットアップウィザードが立ち上がるので「Next」をクリック

- HDD内のデータ消すけど良いかい?と聞いてくので「Yes」をクリック
- ここで削除されるのはVMwarePlayer用に作成した領域なので心配なし

- インストールするパーティションサイズの変更が出来ますが、デフォルトのまま使うので「Next」をクリック
- 本当にHDD内のデータ消すけど良いか再確認してくるので「Yes」をクリック
- ネットワークの設定もデフォルトのまま使うので「Next」をクリック
- 時間設定は「Asia/Tokyo」を選択し「Next」をクリック
- 管理者権限のパスワードを設定します、適当なパスワードを2回入力し「Next」をクリック
- パッケージ選択画面になるのでラジオボタンで「Customize now」を選択し「Next」をクリック

- 初期構成としてインストールするパッケージを選択する画面になるので以下のパッケージ以外全てチェックを外し、「Next」をクリック
- Base System 内の Base

- これでインストール設定は完了なので「Next」をクリック

- しばらく放置すると完了するので、VMware Playerの「インストールを完了しました」をクリックの上、コンソール内の「Reboot」をクリック


CentOSの設定
FirewallとSELinuxを無効にする
- 再起動後、Setup Agentの画面が開いたら「Firewall configuration」を選択して「Run Tool」を選択し「Enterキー」を押します

- Firewall configurationの画面が開くので以下の通り選択して、「OK」を選択し「Enterキー」を押します。
- Security Level : Disabled
- SELinux : Disabled
- 今回はローカルの開発環境を想定しているため、FWもSELinuxも外してしまいます。

- Setup Agentの画面に戻るので「Exit」を選択し「Enterキー」を押します。

作業用ユーザを作る
# useradd [作業用ユーザ名]<Enter>
# passwd [作業用ユーザ名]<Enter>
Changing password for user devuser.
New UNIX password: [作業用ユーザのパスワード]<Enter>
Retype new UNIX password: [もう一度作業用ユーザのパスワード]<Enter>
passwd: all authentication tokens updated successfully.
#

仮想マシンのIPアドレスを確認する
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:9C:EC:13
inet addr:[仮想マシンのIPアドレス] Bcast:192.168.230.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9c:ec13/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1564 errors:0 dropped:0 overruns:0 frame:0
TX packets:600 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:205938 (201.1 KiB) TX bytes:93554 (91.3 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:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:200 (200.0 b) TX bytes:200 (200.0 b)
#

TeraTermで作業ユーザとしてログイン
- Host:に先ほど確認した「仮想マシンのIPアドレス」を入力して「OK」をクリック

- 一番最初に繋いだ時だけセキュリティ警告が出ますが、「Continue」をクリック((このホスト本当に合ってる?みたいな事を聞いている))

- 認証画面になったら、User name:に先ほど設定した管理ユーザ名、Passphrease:に先ほど設定した「作業用ユーザのパスワード」を入力

- ログイン完了

管理者権限を取得
- 引き続きTeraTerm上から環境設定をしていくため、管理者権限を取得
$ su -
Password: [管理者権限のパスワード]
#
不要なデーモンを止める
- モバイル開発環境なのでバッテリーに優しく!不要なデーモンは止める((どれくらいバッテリー延命に効果があるのが不明ですがw))
# chkconfig acpid off
# chkconfig anacron off
# chkconfig atd off
# chkconfig autofs off
# chkconfig avahi-daemon off
# chkconfig bluetooth off
# chkconfig cpuspeed off
# chkconfig cups off
# chkconfig firstboot off
# chkconfig gpm off
# chkconfig haldaemon off
# chkconfig hidd off
# chkconfig hplip off
# chkconfig ip6tables off
# chkconfig iptables off
# chkconfig kudzu off
# chkconfig --level 12345 lvm2-monitor off
# chkconfig mcstrans off
# chkconfig mdmonitor off
# chkconfig microcode_ctl off
# chkconfig netfs off
# chkconfig nfslock off
# chkconfig pcscd off
# chkconfig portmap off
# chkconfig rawdevices off
# chkconfig readahead_early off
# chkconfig --level 5 readahead_later off
# chkconfig restorecond off
# chkconfig rpcgssd off
# chkconfig rpcidmapd off
# chkconfig sendmail off
# chkconfig smartd off
# chkconfig xfs off
# chkconfig yum-updatesd off
使わないデーモンを削除
# yum -y remove NetworkManager anacron autofs avahi firstboot-tui gpm irda-utils wpa_supplicant yum-updatesd
yum環境を構築
- 各種リポジトリをセットアップして便利な世界を構築する
Dagリポジトリ追加
# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt
# rm -f RPM-GPG-KEY.dag.txt
# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el5/en/$basearch/dag/ gpgcheck=1 enabled=0 #
EPELリポジトリ追加
# wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm
# rm -f epel-release-5-4.noarch.rpm
#
Remiリポジトリ追加
# wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# rpm --import RPM-GPG-KEY-remi
# rpm -Uvh remi-release-5.rpm
# rm -f RPM-GPG-KEY-remi remi-release-5.rpm
#
確認
- このCentOSから利用出来るyumリポジトリの一覧を表示する
# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: ftp.jaist.ac.jp
* base: ftp.jaist.ac.jp
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp
epel | 3.7 kB 00:00
epel/primary_db | 3.5 MB 00:00
repo id repo name status
addons CentOS-5 - Addons enabled: 0
base CentOS-5 - Base enabled: 3,434
c5-media CentOS-5 - Media disabled
centosplus CentOS-5 - Plus disabled
contrib CentOS-5 - Contrib disabled
dag Dag RPM Repository for Fedora Core disabled
epel Extra Packages for Enterprise Linux 5 - x86_64 enabled: 6,073
epel-debuginfo Extra Packages for Enterprise Linux 5 - x86_64 - Debug disabled
epel-source Extra Packages for Enterprise Linux 5 - x86_64 - Source disabled
epel-testing Extra Packages for Enterprise Linux 5 - Testing - x86_64 disabled
epel-testing-debuginfo Extra Packages for Enterprise Linux 5 - Testing - x86_64 - Debug disabled
epel-testing-source Extra Packages for Enterprise Linux 5 - Testing - x86_64 - Source disabled
extras CentOS-5 - Extras enabled: 303
remi Les RPM de remi pour Enterprise Linux 5 - x86_64 disabled
remi-test Les RPM de remi en test pour Enterprise Linux 5 - x86_64 disabled
updates CentOS-5 - Updates enabled: 1,135
repolist: 10,945
#
OSおよびパッケージを最新の状態に更新する
- yum updateでパッケージを最新版にして再起動!
# yum -y update
・
・だーっとログが流れる
・
Complete!
# shutdown -r now
vmware-toolsのインストール
- 再起動が完了したら、VMwareのドライバやユーティリティがパッケージされた「vmware-tools」をインストールする
-vmware-toolsには仮想マシンをVMwareに最適化するためのドライバ等が含まれており、インストールするだけでCPUの負荷を多少減らす事が出来る。 - VMwarePlayerのコンソール画面にてメニューの「仮想マシン」をクリックし、「VMware Toolsのインストール(T)…」をクリック

- コンソール画面からCentOSにログインしVMware Toolsの入ったドライブをマウントしインストールし、再起動
# mount /dev/cdrom /mnt
# cp -p /mnt/VMwareTools-8.4.5-32485.tar.gz ./
# tar zxf ./VMwareTools-8.4.5-32485.tar.gz
# ./vmware-tools-distrib/vmware-install.pl -d
・
・だーっとログが流れる
・
Found VMware Tools CDROM mounted at /mnt. Ejecting device /dev/cdrom ...
# rm -rf ./vmware-tools-distrib ./VMwareTools-8.4.5-32485.tar.gz
# shutdown -r now

ミドルウエアのインストール
- TeraTermでログインしてサクサクインストールと設定をしていく
Apacheのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install httpd.x86_64
# /usr/sbin/httpd -v
Server version: Apache/2.2.3
Server built: Aug 30 2010 12:28:40
MySQLのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install mysql.x86_64 mysql-server.x86_64
# mysql --version
mysql Ver 14.14 Distrib 5.5.8, for Linux (x86_64) using readline 5.1
PHPのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install php.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-pear.noarch
# php -v
PHP 5.3.5 (cli) (built: Jan 7 2011 18:52:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Rubyのインストール
コンパイルに必要なパッケージをインストール
# yum --enablerepo=remi-test,remi,epel,dag,rpmforge install gcc.x86_64 zlib-devel.x86_64 rpm-build.x86_64 openssl-devel.x86_64 readline-devel.x86_64
chekinstall(RPM作成ツール)をインストール
- chekinstallの総本山からRPMパッケージを入手してインストールする
# wget http://packages.sw.be/checkinstall/checkinstall-1.6.0-3.el4.rf.x86_64.rpm
# rpm -Uvh checkinstall-1.6.0-3.el4.rf.x86_64.rpm
# rm -f checkinstall-1.6.0-3.el4.rf.x86_64.rpm
# checkinstall -v
checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.
#
Rubyのインストール
- ソースの取得
# wget http://core.ring.gr.jp/archives/lang/ruby/ruby-1.8.7-p330.tar.gz
- ソースからRPMパッケージを作成してインストール
# tar zvf ruby-1.8.7-p330.tar.gz
# cd ruby-1.8.7-p330
# ./configure --prefix=/usr
・
・だーっとログが流れる
・
# make && make test
・
・だーっとログが流れる
・
# checkinstall --fstrans=no
・
・だーっとログが流れる
・
# rpm -Uvh /usr/src/redhat/RPMS/x86_64/ruby-1.8.7-p330-1.x86_64.rpm
# ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
# cd ../
# rm -rf ruby-1.8.7-p330 ruby-1.8.7-p330.tar.gz
RubyGemsのインストール
- ソースの取得
# wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
- ソースからRPMパッケージを作成してインストール
# tar zvf rubygems-1.3.7.tgz
# cd rubygems-1.3.7
# checkinstall -R "ruby setup.rb"
・
・だーっとログが流れる
・
# rpm -Uvh /usr/src/redhat/RPMS/x86_64/rubygems-1.3.7-1.x86_64.rpm
# gem -v
1.3.7
# cd ../
# rm -rf rubygems-1.3.7 rubygems-1.3.7.tgz
#
Git/Subversionのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install git.x86_64 subversion.x86_64
# git --version
git version 1.7.3
# svn --version
svn, version 1.4.2 (r22196)
compiled Aug 10 2009, 17:54:46
phpMyAdminのインストール
# yum -y --enablerepo=remi-test,remi,epel,dag install phpMyAdmin
# ls /etc/phpMyAdmin/
config.inc.php
#
設定
MySQLの設定
- MySQLの起動・初期化
# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
110117 1:07:34 [ERROR] Function 'archive' already exists
110117 1:07:34 [ERROR] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
OK
Filling help tables...
110117 1:07:34 [ERROR] Function 'archive' already exists
110117 1:07:34 [ERROR] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
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 localhost.localdomain 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 /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
#
- MySQLのrootユーザにパスワードを設定 ※hogehogeと設定してみた
# /usr/bin/mysqladmin -u root password 'hogehoge'
# /usr/bin/mysqladmin -u root -h localhost.localdomain password 'hogehoge'
#
- OS起動時に自動的に起動する様に設定
# chkconfig mysqld on
[root@localhost ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#
phpMyAdminの設定
- アクセス元IP制限を調整する。デフォルトのままだと開発機のWindows上からアクセス出来ない
# vi /etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from ::1
</Directory>
↓こんな感じに追記
<Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from ::1
allow from 192.168.
</Directory>
#
Apaceの設定
- Apacheの設定・起動
# vi /etc/httpd/conf/httpd.conf
#ServerName www.example.com:80
↓こんな感じに追記
#ServerName www.example.com:80
ServerName localhost:80
# service httpd start
Starting httpd: [ OK ]
#
- OS起動時に自動的に起動する様に設定
# chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#
動作確認
- 開発機のブラウザから仮想マシンのIPにアクセスしてみる
http://192.168.230.130/
- こんな画面が表示される

- phpMyAdminにアクセス
http://192.168.230.130/phpMyAdmin
- こんな画面が表示されるので、先ほど設定したMySQLのrootユーザのパスワードを入力するとログイン出来る

完成!
- 動作確認が完了したらあとは開発に専念するだけ!ワーイヽ(゚∀゚)ノワーイ