<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/wginoh/">
    <title>徒然に備忘録を記す</title>
    <link>http://w.atwiki.jp/wginoh/</link>
    <atom:link href="https://w.atwiki.jp/wginoh/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>徒然に備忘録を記す</description>

    <dc:language>ja</dc:language>
    <dc:date>2012-11-18T21:10:11+09:00</dc:date>
    <utime>1353240611</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/14.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/29.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/19.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/28.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/123.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/1.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/35.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/17.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/23.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/wginoh/pages/2.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/14.html">
    <title>開発環境の構築</title>
    <link>https://w.atwiki.jp/wginoh/pages/14.html</link>
    <description>
      * 更新履歴

|2011/0429|ver1作成|
|2011/05/15|仮想OSのインストールを追記|
|2012/11/18|システム構成は削除、homebrewのインストール方法更新|

#contents()

* &amp;font(u){概要}
自分の開発環境の構築について書いておく

* Macを利用する上での注意点
** &amp;font(u,red){Macの大文字・小文字の区別について}
結構、自分で忘れてしまっていることが多いが、Macを標準でそのまま利用していると、ファイル名の大文字と小文字は区別されない。CUIで作業していると困ることがある。

一応、HDフォーマット時に、区別するように指定もできるみたいだが、それをやると、Macのアプリケーションが、大文字と小文字は区別されないことが前提だったりして動かなくなることもあるみたいだ。

なので、基本は区別せずに自分で気をつけることにする。

** &amp;font(u,red){Macの64bit対応について}
ソフトウェアをインストールするときなど、i386やx86_64などと書かれたものが分かれていたりするが
簡単にいうと、&amp;font(blue){32bit対応}か&amp;font(blue){64bit対応}の違いらしい。

現在、利用しているMac OS X 10.6(snow leopard)は64bitに対応している。

しかし、標準では32bitモードで起動しているみたい。

[[Mac OS X v10.6：64 ビットのカーネルを使う Mac&gt;http://support.apple.com/kb/HT3770?viewlocale=ja_JP]]

そもそも、プロセッサが対応しているかは、

[[Intel ベースの Mac のプロセッサが 32 ビットか 64 ビットかを識別する方法&gt;http://support.apple.com/kb/HT3696?viewlocale=ja_JP&amp;locale=ja_JP]]

起動するカーネルを自分で選択する場合は、

[[Mac OS X v10.6：32 ビットまたは 64 ビットカーネルで起動する&gt;http://support.apple.com/kb/HT3773?viewlocale=ja_JP]]

まあ、今のところは他のアプリなどに影響が出ると嫌なので、デフォルトの32bitにしておく。(2011/05)

* &amp;font(u){基本のセットアップ}
** パッケージ管理ソフトをいれる
パッケージをいれるのに管理ソフトがあると便利のためパッケージ管理ソフトを導入。将来的にはAppStoreに統一されていくんだろうか。
以前はMacportsが有名だったが、現在はHomebrewが主流のようだ。

&amp;font(red){今のMacbookでインストールするために方法を変更}

参考：
[[[Mac] Mountain Lionへパッケージ管理「Homebrew」をインストールする手順のメモ&gt;http://tools4hack.santalab.me/howto-mountainlion-install-homebrew.html]]

- javaをインストールする。
#highlight(shell){{
$
}}
- XCodeをインストール
以前はダウンロードしてきてインストールしていたが、今はAppStoreから手に入る。便利！
- Homebrewをインストールする。
#highlight(shell){{
 $ ruby -e &quot;$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)&quot;  
}}

利用方はmanコマンドで確認したほうが早いが、主に

#highlight(shell){{
$ brew command　[options] [formula]
}}

という形式。　&amp;font(b){formula}というのはいわゆるパッケージのことだと思えばよい。。。と思う。

|command|内容|
|install|インストールする|
|options|インストール時に指定できるオプションを見る。オプションは、brew install [option] formula といった形で利用する。|
|search|formulaを探す|
|info|formulaの情報を表示|
|list|インストールされているformulaのリスト|
|update|Homebrewのアップデートを行う|

** &amp;font(u){MySQLのインストール}

MySQLはデフォルトでは入ってないのでインストールの必要がある。

ここで方法としては、下記のものがある。

**** &amp;font(u){1.パッケージをダウンロードして、インストールする。}

[[MySQL::Download&gt;http://www-jp.mysql.com/downloads/mysql/]]

Mac OS X　のタイプをダウンロードする。DMGパッケージのものがtar.gzのタイプより楽でいいと思う。

このタイプだとシステム環境設定から起動などをGUIから制御できるみたい。

**** &amp;font(u){2.brewパッケージ管理ソフトからコマンドラインでインストールする。}

今回はこちらの方法でインストールを行う。

#highlight(shell){{
$ brew install mysql

--ここまで依存関係のダウンロードなどで結構時間がかかった--

Set up databases to run AS YOUR USER ACCOUNT with:
    unset TMPDIR
    mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp

To set up base tables in another folder, or use a differnet user to run
mysqld, view the help for mysqld_install_db:
    mysql_install_db --help

and view the MySQL documentation:
  * http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
  * http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html

To run as, for instance, user &quot;mysql&quot;, you may need to `sudo`:
    sudo mysql_install_db ...options...

Start mysqld manually with:
    mysql.server start

A &quot;/etc/my.cnf&quot; from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To launch on startup:
 * if this is your first install:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/Cellar/mysql/5.5.10/com.mysql.mysqld.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

 * if this is an upgrade and you already have the com.mysql.mysqld.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
    cp /usr/local/Cellar/mysql/5.5.10/com.mysql.mysqld.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

You may also need to edit the plist to use the correct &quot;UserName&quot;.

Warning: m4 macros were installed to &quot;share/aclocal&quot;.
Homebrew does not append &quot;/usr/local/share/aclocal&quot;
to &quot;/usr/share/aclocal/dirlist&quot;. If an autoconf script you use
requires these m4 macros, you&#039;ll need to add this path manually.
==&gt; Summary
/usr/local/Cellar/mysql/5.5.10: 6232 files, 219M, built in 5.9 minutes

$ mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp


mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp
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/local/Cellar/mysql/5.5.10/bin/mysqladmin -u root password &#039;new-password&#039;
/usr/local/Cellar/mysql/5.5.10/bin/mysqladmin -u root -h (machine name).local password &#039;new-password&#039;

Alternatively you can run:
/usr/local/Cellar/mysql/5.5.10/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/local/Cellar/mysql/5.5.10 ; /usr/local/Cellar/mysql/5.5.10/bin/mysqld_safe &amp;

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/Cellar/mysql/5.5.10/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/Cellar/mysql/5.5.10/scripts/mysqlbug script!
}}
上記に書かれている内容から以下の内容をやった。

#highlight(shell){{
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp
$ mysql.server start
}}

#highlight(shell){{
$ mysql -uroot

Can’t connect to local MySQL server through socket &#039;/tmp/mysql.sock&#039;
}}

となってエラーがでた。このエラーが出た場合の可能性としては、次の可能性がある。

- &amp;font(u){可能性１}
そもそもmysqlが起動していない。起動していないときはエラーがでる。psコマンドで確認してみる。

- &amp;font(u){可能性2}

MySQLサーバとクライアントで、利用しているソケットファイルのパスが違う。

MySQLサーバのソケットファイルの位置は、インストール時に指定していなければ &#039;&#039;/tmp/mysql.sock&#039;&#039;

また、次のコマンドで知ることもできる。

#highlight(shell) {{
$ mysql_config --socket
}}

このソケットファイルの位置をサーバとクライアントであわせる必要がある。

- &amp;font(u){可能性3}

何らかの影響でsocketファイルが存在しない場合。このような場合は再起動をかけると、
ソケットファイルが復元される。

今回は、調べたところ、プロセスはたちあがっていたが、ソケットファイルが存在しなかった。
そのため、mysqldを再起動をかける。
ちなみに、launchctlでロードしているplistファイルでOnDemandがfalseの場合、stopするとすぐに起動する。よってstopすると結果的に再起動となる。

#highlight(shell){{
$ launchctl stop com.mysql.mysqld.plist
}}

が、結局、sockファイルが作成されていなかったので、一度unloadした。

#highlight(shell){{
$ launchctl unload com.mysql.mysqld.plist
}}

この時点で残っていたプロセスは、killした。
mysql.server stopのほうがよかった気もする。


再び、launchctlでloadを行う
#highlight(shell){{
$ launchctl load com.mysql.mysqld.plist
}}

自動起動をしないようにする場合は、launchctlを利用せず、

#highlight(shell){{
$ mysql.server start
}}
でよいと思う

**** &amp;font(u){3.設定ファイルの準備}
最後に設定ファイルを準備する。
通常、設定ファイルの位置は、

参考：[[MySQL 5.1 リファレンスマニュアル&gt;http://dev.mysql.com/doc/refman/5.1/ja/option-files.html]]
|ファイル|目的|
|/etc/my.cnf|グローバルオプション|
|$MYSQL_HOME/my.cnf|サーバ固有のオプション|
|defaults-extra-file|--defaults-extra-file=pathで指定されたファイル(あれば)|
|~/.my.cnf|ユーザ固有のオプション|
#blockquote(){
MYSQL_HOMEはサーバ固有のファイルmy.cnfを含むディレクトリへのパスを含む環境変数です。

MYSQL_HOME がセットされていない状態で mysqld_safe プログラムを使ってサーバをスタートさせると、 mysqld_safe は次のように MYSQL_HOME をセットしようとします。

BASEDIR と DATADIR をそれぞれ、MySQLベースディレクトリとデータディレクトリのパスネームの代理に立てます。

DATADIRにはmy.cnfファイルが存在し、BASEDIRには存在しない場合、mysqld_safeはMYSQL_HOMEをDATADIRにセットします。

または、もしMYSQL_HOMEがセットされておらず、my.cnfファイルがDATADIRに存在しない場合、mysqld_safeはBASEDIRにMYSQL_HOMEをセットします。

MySQL 5.1ではDATADIRのmy.cnfファイルのロケーションとしての使用は認証されていません。BASEDIR の方が良い場所です。
}

ということらしい。

ちなみに、　

#blockquote()
{
一般的にDATADIRは/usr/local/mysql/dataでバイナリインストールに、または/usr/local/varでソースインストールに使用されます。これはコンフィグレーションタイムに特定されたデータディレクトリロケーションであって、mysqldが起動したときの--datadirオプションに呼応しているのではないということに注意してください。--datadirの起動時の使用はサーバがオプションファイルを探す際に何の影響ももたらしません。 これはサーバがオプションを処理する前にオプションファイルを探すからです。
}

らしい。最近まで勘違いしていた。

** &amp;font(u){Node.jsのインストール}

Windows or Macでインストールする場合、Node.jsが単一のバージョンのみでよいか、複数必要かで違ってくると思われる。

*** &amp;font(u){単一のバージョンのみでよい場合}
ネイティブのインストーラがおすすめ。インストーラをダウンロードしてきて実行するだけ。

[[node.js v0.8(2012/11現在安定版&gt;http://nodejs.jp/nodejs.org_ja/docs/v0.8/download/)]]

*** &amp;font(u){複数のバージョンをインストールする場合}

複数のバージョンをインストールして試す場合、nvm、nave、n、nodeenv、nodebrew　などがある。

個人的にzshを利用していて、相性が良さそうなのが nodebrewのようなのでこれを利用する。

簡単な比較などは下記リンク先で書かれていた。
[[node.js の環境管理ツール nodebrew - Block Rockin’ Codes &gt;http://d.hatena.ne.jp/Jxck/20120224/1330035058]]

nodebrewはgithubで公開されている。
[[hokaccha / nodebrew - github&gt;https://github.com/hokaccha/nodebrew]]

インストール方法はREADMEの通り。
#highlight(shell){{
$ curl https://raw.github.com/hokaccha/nodebrew/master/nodebrew | perl - setup

・
・
ずらずらとコンパイル
・
・

完了したら環境変数でパスを通す。
export PATH=$HOME/.nodebrew/current/bin:$PATH

$ source ~/.zshrc

$ nodebrew ls
v0.8.14

current: none

$ nodebrew use v0.8.14
use v0.8.14

$ node -v
v0.8.14

$ npm -v
1.1.65
}}    </description>
    <dc:date>2012-11-18T21:10:11+09:00</dc:date>
    <utime>1353240611</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/29.html">
    <title>ツール</title>
    <link>https://w.atwiki.jp/wginoh/pages/29.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T14:58:59+09:00</dc:date>
    <utime>1353218339</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/19.html">
    <title>開発言語</title>
    <link>https://w.atwiki.jp/wginoh/pages/19.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T14:56:54+09:00</dc:date>
    <utime>1353218214</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/28.html">
    <title>その他</title>
    <link>https://w.atwiki.jp/wginoh/pages/28.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T14:47:59+09:00</dc:date>
    <utime>1353217679</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/123.html">
    <title>backup</title>
    <link>https://w.atwiki.jp/wginoh/pages/123.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T01:31:19+09:00</dc:date>
    <utime>1353169879</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/1.html">
    <title>トップページ</title>
    <link>https://w.atwiki.jp/wginoh/pages/1.html</link>
    <description>
      基本的に勉強したこや、今、必要なことなどの個人的なメモ

勉強の情報源は書籍・雑誌が多い。

メモしたいことはたくさんあるが、できるところから少しずつ書いていく。

#contents()

** [[開発環境の構築]]

** [[Unix,Linux,Macコマンド]]

** [[開発言語]]

** [[データベース]]

** [[Webサービス]]

** [[ネットワーク]]

** [[その他]]

** [[セキュリティ]]

** [[資格の取得を目指す]]

** [[temporary]]

** [[backup]]    </description>
    <dc:date>2012-11-18T01:17:35+09:00</dc:date>
    <utime>1353169055</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/35.html">
    <title>資格の取得を目指す</title>
    <link>https://w.atwiki.jp/wginoh/pages/35.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T01:14:36+09:00</dc:date>
    <utime>1353168876</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/17.html">
    <title>temporary</title>
    <link>https://w.atwiki.jp/wginoh/pages/17.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T01:12:53+09:00</dc:date>
    <utime>1353168773</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/23.html">
    <title>Webサービス</title>
    <link>https://w.atwiki.jp/wginoh/pages/23.html</link>
    <description>
          </description>
    <dc:date>2012-11-18T00:49:11+09:00</dc:date>
    <utime>1353167351</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/wginoh/pages/2.html">
    <title>メニュー</title>
    <link>https://w.atwiki.jp/wginoh/pages/2.html</link>
    <description>
      **プロフィール

名前：wginoh

仕事：Web系エンジニア

ジョブ：開発したり、運用したり

経歴：

入社(知識なし)
　　↓
開発をやらせてもらう
　　↓
運用経験させてもらう
　　↓
2年目にして休職
　　↓
　復帰
　　↓
気がついたら開発にまたいた。


現在の開発機：
機種    ：MacbookAir 13inch(Mid 2012)
OS　   ：OS X 10.8.2
仮想OS : Windows8/Windows7

仮想OSのためにメモリは8GBに増設済み。
----

// リンクを張るには &quot;[&quot; 2つで文字列を括ります。
// &quot;&gt;&quot; の左側に文字、右側にURLを記述するとリンクになります


//**更新履歴
//#recent(20)

&amp;link_editmenu(text=ここを編集)    </description>
    <dc:date>2012-11-18T00:36:31+09:00</dc:date>
    <utime>1353166591</utime>
  </item>
  </rdf:RDF>
