mac環境

以前、Mac OS X LeopardにmacportsでインストールにたMySQLでの文字化け対策は「MySQL コマンドラインでインポート」を参照してください。。

今回もまた文字化けが発生したので、同じ対処法を・・・とおもったけど、/opt/local/etc/mysql5/my.cnf がない!

そういえば、設定ファイルなにもしてなかったorz

参考サイト:PHPとMySQLの個人的まとめ

前回インストールしたPHP5.3.3では、cakePHPやCMSなどまだまだ対応できていないものが多く、開発には何かと不便。

と、いうことで、PHP5.2系を入れ直すことに。

まずは、前回インストールしたPHP5.3.3をアンインストール。

それからPHP5.2系をインストールしていきます。

参考サイト:MacPortsでphp5-mysqlがインストールできない問題の解決方法

参考サイト:MacPortsでPHP5.2+apache2+mysql5環境構築

言語環境はだいぶ整ってきましたので、次はIDEをインストール。

Eclipseのsubversionでプロジェクトのバージョン管理をすることが前提。

あと、PHP、rubyなどのweb開発をするので、それらのプラグインをインストール予定。

まずはEclipse本体のインストールから。

http://www.eclipse.org/downloads/

上記Eclipseダウンロードサイトから、cocoa版Eclipse IDE for Java EE Developersをダウンロード。

Eclipse Downloads.png

解凍したeclipseフォルダをアプリケーションフォルダに移動させて、本体のインストール完了。

eclipse.appをダブルクリックして起動してみる。(workspaceはサイトフォルダの中に入れておくと実行確認のときに便利。)→OK

参考サイト:Mac OS X LeopardでEclipse(javaとPHP)開発環境を整える(basic認証がかかっていますが、キャンセルで閲覧可能→アクセス制限をかけたいのか、単なる設定ミスかは不明。アクセス制限をかけたい場合はご連絡いただけますとリンク削除します。)

macports での最後のインストールになります。

バージョン管理システム「Git」。subversionも最初に入れたけど、これからはgitも使えるようになんなきゃね。ってことでインストールしてみることに。

デフォルトではgitは入っていないので、portsの確認から。

$ port search git
・・・
git-core @1.7.3.2 (devel)
    A fast version control system

git-flow @0.4 (devel)
    Git extensions for Vincent Driessen branching.

GitX @0.7.1 (devel)
    GitX is a git GUI specifically for Mac OS X
・・・

git-coreをインストールしたらいいのかな?

こんなときはgoogle先生に。

cogitoとgit-coreらしい。しかし、cogitoなるものは引っかかってこなかった。。とりあえず、git-coreのオプション確認。

$ port variants git-core
git-core has the variants:
   bash_completion: Completion support for bash
[+]doc: Install HTML and plaintext documentation
   gitweb: Install gitweb.cgi
   svn: Bi-directional subversion repository support

gitweb と svn を追加してインストール

$ sudo port install git-core +gitweb +svn

無事インストールされたみたい。

$ git --version
git version 1.7.3.2

参考サイト:MacPortsを使ってgitをインストールしてみた

そのうちGitXもインストールしようかな。。

pythonフレームワークのDjangoをインストール。

portsの確認

$ port search django
・・・
py27-django @1.2.3 (python, www)
    Django is a high-level Python Web framework

インストール

$ sudo port install py27-django

問題なくインストールできました。

参考サイト:MacPortsを使って、Pythonの開発環境を整えてみた

お次はpython。ってpython使ったことないんだけどね。。

これを機に使いたいねって思って。まずはデフォルトのバージョン確認

$ python
Python 2.6.1 (r261:67515, Dec 17 2009, 00:59:15) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

pythonを終了させるには「exit()」コマンドをタイプすればOK。

portsの確認

$ port search python
・・・
python24 @2.4.6 (lang)
    An interpreted, object-oriented programming language

python24-doc @2.4.4 (lang)
    HTML documentation for Python 2.4

python25 @2.5.5 (lang)
    An interpreted, object-oriented programming language

python25-doc @2.5.2 (lang)
    HTML documentation for Python 2.5

python26 @2.6.6 (lang)
    An interpreted, object-oriented programming language

python26-doc @2.6.4 (lang)
    HTML documentation for Python 2.6

python27 @2.7 (lang)
    An interpreted, object-oriented programming language

python31 @3.1.2 (lang)
    An interpreted, object-oriented programming language

python32 @3.2a3 (lang)
    An interpreted, object-oriented programming language

python_select @0.3 (sysutils)
    Switch the default python interpreter
・・・

いっぱいあるね〜。

とりあえず3.2系をインストールしてpython_selectで切り替えられるようにしておけば何とかなるかな?ってことで、インストール

$ sudo port install python32
Password:
・・・
--->  Fetching python26
--->  Attempting to fetch Python-2.6.6.tar.bz2 from http://distfiles.macports.org/python26
--->  Verifying checksum(s) for python26
--->  Extracting python26
--->  Applying patches to python26
--->  Configuring python26
--->  Building python26
--->  Staging python26 into destroot
--->  Installing python26 @2.6.6_0+no_tkinter
--->  Activating python26 @2.6.6_0+no_tkinter

To fully complete your installation and make python 2.6 the default,  please
run:
 	sudo port install python_select
 	sudo python_select python26
・・・
--->  Fetching python32
--->  Attempting to fetch Python-3.2a3.tar.bz2 from http://distfiles.macports.org/python32
--->  Verifying checksum(s) for python32
--->  Extracting python32
--->  Applying patches to python32
--->  Configuring python32
--->  Building python32
Error: Target org.macports.build returned: shell command failed
Log for python32 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python32/main.log
Error: Status 1 encountered during processing.
To report a bug, see 

なんかたくさんインストールされた。。2.6系もインストールされたっぽい。

そしてpython_selectをインストールせよと。

最後の最後でpython32ビルドできなかったって(T_T)

インストールされたものを確認。

$ port installed
・・・
python26 @2.6.6_0+no_tkinter (active)
・・・

とりあえず、python_selectをインストールしてみることに。

$ sudo port install python_select

よくよく考えてみると、3.2系はまだdjangoがない。ということで、2.7系をインストールしてみる。

$ sudo port install python27

今度は無事インストールされたみたい^^

python_select で2.7系に変更

$ sudo python_select python27
Selecting version "python27" for python

ターミナルを再起動してバージョン確認。

$ python
Python 2.7 (r27:82500, Nov  6 2010, 18:41:20) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

参考サイト:MacPortsを使って、Pythonの開発環境を整えてみた

rubyのフレームワークrailsをgemsからインストールします。

$ sudo gem install rails
Password:
・・・
24 gems installed
Installing ri documentation for activesupport-3.0.1...
Installing ri documentation for builder-2.1.2...
ERROR:  While generating documentation for builder-2.1.2
... MESSAGE:   Unhandled special: Special: type=17, text=""
... RDOC args: --ri --op /opt/local/lib/ruby/gems/1.8/doc/builder-2.1.2/ri --title Builder -- Easy XML Building --main README --line-numbers --quiet lib CHANGES Rakefile README doc/releases/builder-1.2.4.rdoc doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.rdoc --title builder-2.1.2 Documentation
・・・
File not found: lib

なんだかエラーがでましたね。。

とりあえず、インストールされたものたちを確認してみることに

$ gem search

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.1)
actionpack (3.0.1)
activemodel (3.0.1)
activerecord (3.0.1)
activeresource (3.0.1)
activesupport (3.0.1)
arel (1.0.1)
builder (2.1.2)
bundler (1.0.3)
erubis (2.6.6)
i18n (0.4.2)
mail (2.2.9)
mime-types (1.16)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (3.0.1)
railties (3.0.1)
rake (0.8.7)
thor (0.14.4)
treetop (1.4.8)
tzinfo (0.3.23)

rails3.0.1がインストールされています。

documentationがインストールできなかっただけのようですので、ま、いっか。

rails の確認

$ rails -v
Rails 3.0.1

RubyGemsは、Ruby の標準パッケージ管理システムになります。

RubyのライブラリはRubyGemsでインストールしますので、macportsではRubyGemsをインストールします。

まずはデフォルトのgemバージョンの確認

$ gem -v
1.3.5

portsの確認

$ port search gems
・・・
rb-rubygems @1.3.7 (ruby, devel)
    a package management framework for Ruby

インストール

$ sudo port install rb-rubygems

ターミナルを再起動してバージョン確認

$ gem -v
1.3.7

お次はruby。

いつものようにデフォルトバージョン確認。

$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

portsの確認

$ port search ruby
・・・
ruby @1.8.7-p302 (lang, ruby)
    Powerful and clean object-oriented scripting language

ruby186 @1.8.6-p399 (lang, ruby)
    Powerful and clean object-oriented scripting language

ruby19 @1.9.2-p0 (lang, ruby)
    Powerful and clean object-oriented scripting language
・・・

今回は1.8.7系をインストールしたい。(デフォルトで入ってたのと同じバージョン)でもmacportsで管理したいから、あえてインストールすることに。

関連モジュールはと。

$ port variants ruby
ruby has the variants:
   mactk: enable MacTk (Tk.framework without X11) support
     * conflicts with tk
   no_doc: do not install rdoc documents
[+]thread_hooks: apply Apple's thread_hooks patch
   tk: enable tk support
     * conflicts with mactk
   universal: Build for multiple architectures

特にいらないね。

では。インストール。

$ sudo port install ruby

ターミナルを再起動してバージョン確認。

$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]

当然バージョンは一緒なんだけど、patchlevelが最新版にかわってますね^^

お次はperlをインストールします。

まずはデフォルトバージョンの確認

$ perl -v

This is perl, v5.8.9 built for darwin-2level

続いてmacportsの確認

$ port search perl
・・・
perl5 @5.8.9 (lang)
    Wrapper port for perl 5.x

perl5.10 @5.10.1 (lang)
    Perl 5.10.x - Practical Extraction and Report Language

perl5.12 @5.12.2 (lang)
    Perl 5.12.x - Practical Extraction and Report Language

perl5.8 @5.8.9 (lang)
    Perl 5.8.x - Practical Extraction and Report Language
・・・

とりあえず最新バージョンをインストールすることに。

関連モジュールの検索

$ port variants perl5.12
perl5.12 has the variants:
   dtrace: Build with DTrace probes
   mangle_names: mangle the installed names by appending -5.12 to avoid
                 conflicting with perl5.8 and perl5.10
   shared: Build shared perl library
   threads: Build with thread support
   universal: Build for multiple architectures

特にこれが必要!てのは無さそうなので、単体でインストールすることに。

$ sudo port install perl5.12
・・・
Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port.  Please deactivate this port first, or use 'port -f activate perl5.12' to force the activation.
Log for perl5.12 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_perl5.12/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

なんかエラーでた。

perl5.8 が port を使用中なので、そいつを停止させるか perl5.12 が使うように指示を出してください(?)

!!! そういえば、phpをインストールしたときにperlも一緒にインストールされていたような・・・。

mac の開発環境構築 〜PHP〜

やっぱり。。

念のため、今までにインストールされたパッケージを確認。

$ port installed
The following ports are currently installed:
  apache-ant @1.8.1_0 (active)
  apache2 @2.2.16_0+preforkmpm
  apache2 @2.2.17_0+preforkmpm (active)
  apr @1.4.2_1 (active)
  apr-util @1.3.9_2 (active)
  autoconf @2.68_0 (active)
  autoconf213 @2.13_1 (active)
  automake @1.11.1_0 (active)
  bzip2 @1.0.6_0 (active)
  curl @7.21.2_1+ssl (active)
  curl-ca-bundle @7.21.2_0 (active)
  cyrus-sasl2 @2.1.23_3+kerberos (active)
  db46 @4.6.21_6 (active)
  expat @2.0.1_1 (active)
  freetype @2.4.3_0 (active)
  gawk @3.1.8_0 (active)
  gettext @0.18.1.1_2 (active)
  gperf @3.0.4_0 (active)
  gsed @4.2.1_0 (active)
  help2man @1.38.2_0 (active)
  jpeg @8b_0 (active)
  libiconv @1.13.1_0 (active)
  libidn @1.19_0 (active)
  libmcrypt @2.5.8_1 (active)
  libpng @1.2.44_0 (active)
  libtool @2.4_0 (active)
  libxml2 @2.7.7_0 (active)
  m4 @1.4.15_0 (active)
  mhash @0.9.9.9_0 (active)
  mysql5 @5.1.51_0 (active)
  mysql5-server @5.1.51_0 (active)
  ncurses @5.7_1 (active)
  ncursesw @5.7_1 (active)
  neon @0.29.5_0 (active)
  openssl @1.0.0a_0
  openssl @1.0.0a_1 (active)
  p5-locale-gettext @1.05_3 (active)
  pcre @8.10_0 (active)
  perl5 @5.8.9_0 (active)
  perl5.12 @5.12.2_0
  perl5.8 @5.8.9_3 (active)
  php5 @5.3.3_2+apache2+pear (active)
  php5-curl @5.3.3_0 (active)
  php5-gd @5.3.3_0 (active)
  php5-mbstring @5.3.3_0 (active)
  php5-mcrypt @5.3.3_0 (active)
  php5-mysql @5.3.3_0+mysqlnd (active)
  php5-sqlite @5.3.3_0 (active)
  php5-tidy @5.3.3_0 (active)
  php5-zip @5.3.3_0 (active)
  phpmyadmin @3.3.5.1_0 (active)
  pkgconfig @0.25_1 (active)
  readline @6.1.002_0 (active)
  serf @0.7.0_0 (active)
  sqlite3 @3.7.3_0 (active)
  subversion @1.6.13_0 (active)
  tidy @20090325_0 (active)
  zlib @1.2.5_0 (active)

perl5.12もちゃんとインストールされたけどactiveじゃないよ。ってことだね。

とりあえずOKにしておきましょう。5.12が必要になったらそのときにactiveにすればヨシ。

参考サイト:PerlをMacPortsからインストールする