1  2  3  4  5  6  7  8  9

前回、Apacheをインストールしたときにユーザーディレクトリを有効にしました。

mac の開発環境構築 〜Apache〜

今回はユーザーディレクトリ内の設定をします。

設定ファイル:/opt/local/apache2/conf/extra/httpd-userdir.conf を開いて以下の内容に修正するだけ。

$ sudo vi /opt/local/apache2/conf/extra/httpd-userdir.conf

<Directory "/Users/*/Sites">
#    AllowOverride FileInfo AuthConfig Limit Indexes
#    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
AllowOverride All
Options All

開発環境だからすべてOKにしちゃいました。

apache再起動

$ sudo /opt/local/apache2/bin/apachectl restart

以前、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が最新版にかわってますね^^

1  2  3  4  5  6  7  8  9