Mac初心者のボクがMacBook上でRailsを動かせるようになるまで
かなり遠回りした感じもある!少しずつ上手になっていくといいですね.Railsと関係のない部分も多々あるよ.
Mac OS X 10.5.1 の話です.
bashからzshへ
> chsh Changing shell for june29. Password for june29:
そしたらファイルの編集が始まるから
# Changing user information for june29. # Use "passwd" to change the password. ## # Open Directory: /Local/Default ## Shell: /bin/zsh Full Name: june29 Office Location: Office Phone: Home Phone:
Shellのところをzshへのパスにする.
自分リポジトリからdotfilesを持ってくる
http://d.hatena.ne.jp/june29/20070515/1179213618
に書いた感じで.Macでは/Users/USERNAMEがホームディレクトリになる.ここはFinderでもちょくちょく開く場所なので,あまり散らかしたくないなぁと思いました.ファイル名がドットで始まるファイルはFinderには表示されないようなので(表示させることもできるのかな),細かいファイルはそうしておくとよさそう.
> cd > mkdir .dotfiles > svn co http://path/to/repos/dotfiles .dotfiles
シンボリックリンクを張っておしまい.
lsコマンドのオプション
いつものaliasだと怒られた.
# alias ls="ls -aFh --color=auto --show-control-chars" alias ls="ls -aFGh"
表示結果を色付けするには G オプションで.
Xcode 3.0
http://developer.apple.com/tools/download/
からダウンロードしようとしてDMGへのリンクをクリックしたら「No error」とだけ表示された.テラシュール.その後,3種類くらいのエラーメッセージっぽいものと対面して,そして諦めた.
先輩マカーの人たちに聞いてみると「1.1GBもあるファイルをダウンロードするもんじゃないよ!OSのインストールディスクから入れなさい」とのことでした.アドバイスありがとうございます.DVD ! DVD !
なぜかここだけスクリーンショットを撮った.Optional Installsディレクトリの中にXcode Toolsってのがあるので,中身を引っ張りだしてやりました.ついでだと思って
- XcodeTools.mpkg
- Dashcode.mpkg
- WebObjects.mpkg
3つ全部を入れた.XcodeToolsのインストールには20分くらいかかった.あとの2つはすぐ終わる.
これでCコンパイラなど,開発に使いそうな基本的なものが入ったのだと思います.
MacPortsのインストールと最初のお仕事
参考 : http://d.hatena.ne.jp/hakobe932/20061208/1165646618
http://svn.macosforge.org/repository/macports/downloads/MacPorts-1.5.0/
から MacPorts-1.5.0-10.5.dmg をダウンロードしてきて中に入っているインストーラを起動した.次へ次へと進めるとすんなりとインストールが完了したよ.
インストールが終わったら /opt/local にパスを通しておきましょう.続いてアップデートとリストの更新です.
> sudo port -d selfupdate > sudo port -d sync DEBUG: Synchronizing ports tree(s) Synchronizing from rsync://rsync.macports.org/release/ports/ DEBUG: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/ports/ /opt/local/var/macports/sources/rsync.macports.org/release/ports receiving file list ... done devel/gmp/ lang/gcc42/ sent 74 bytes received 288582 bytes 3773.28 bytes/sec total size is 16009564 speedup is 55.46
gemのアップデートとRailsのバージョンアップ
> sudo gem apdate Gems: [capistrano, cgi_multipart_eof_fix, daemons, fastthread, ferret, gem_plugin, highline, libxml-ruby, mongrel] updated > sudo gem install rails --include-dependencies Successfully installed rails-1.2.5
これで大丈夫かな.
MySQLのインストール
MacPortsさんにはいきなり働いてもらいます.
参考 : http://www.fraction.jp/log/archives/2007/10/31/install_mysql_to_leopard
> port search mysql gauche-dbd-mysql databases/gauche-dbd-mysql 0.2.1 Gauche database driver for MySQL mysql3 databases/mysql3 3.23.58 Multithreaded SQL database server mysql4 databases/mysql4 4.1.22 Multithreaded SQL database server mysql5 databases/mysql5 5.0.45 Multithreaded SQL database server mysql5-devel databases/mysql5-devel 5.1.22-rc Multithreaded SQL database server mysqltcl databases/mysqltcl 3.02 Simple API for Mysql-Database and Tcl scripting language. mysqlxx databases/mysqlxx 1.7.35 C++ wrapper for MySQL's C API mysql-connector-java java/mysql-connector-java 5.0.7 MySQL Official JDBC connector for MySQL database. p5-class-dbi-mysql perl/p5-class-dbi-mysql 1.00 Extensions to Class::DBI for MySQL p5-dbd-mysql perl/p5-dbd-mysql 4.005 Perl5 Database Interface to the MySQL database py-mysql python/py-mysql 1.2.2 Python interface to mysql py25-mysql python/py25-mysql 1.2.2 Python interface to mysql rb-dbd-mysql ruby/rb-dbd-mysql 0.0.23 Ruby DBI driver for Mysql. OBSOLETE: please use dbd_mysql variant of rb-dbi rb-mysql ruby/rb-mysql 2.7.3 Ruby API for the Mysql database > sudo port install mysql5
これで無事にインストールできましたが,どうやらvariantsのserverを付加した方が良さそうです.アンインストールはuninstallです.
> port --help Supported commands ------------------ activate, archive, build, cat, cd, checksum, clean, compact, configure, contents, deactivate, dependents, deps, destroot, dir, distcheck, dmg, dpkg, echo, ed, edit, exit, extract, fetch, file, gohome, help, info, install, installed, list, livecheck, location, mirror, mpkg, outdated, patch, pkg, provides, quit, rpm, search, selfupdate, srpm, submit, sync, test, trace, unarchive, uncompact, uninstall, upgrade, url, usage, variants, version, work > sudo port uninstall mysql5 > port variants mysql5 universal darwin_8 server > sudo port install mysql5 +server ---> Fetching mysql5 ---> Verifying checksum(s) for mysql5 ---> Extracting mysql5 ---> Applying patches to mysql5 ---> Configuring mysql5 ---> Building mysql5 with target all ---> Staging mysql5 into destroot ---> Creating launchd control script ########################################################### # A startup item has been generated that will aid in # starting mysql5 with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist ########################################################### ---> Installing mysql5 5.0.45_3+server ****************************************************** * In order to setup the database, you might want to run * sudo -u mysql mysql_install_db5 * if this is a new install ****************************************************** ---> Activating mysql5 5.0.45_3+server ---> Cleaning mysql5
きちんとインストールされたか確認してみる.
> port installed The following ports are currently installed: mysql5 @5.0.45_3+server (active) openssl @0.9.8g_0 (active) zlib @1.2.3_1 (active)
OpenSSLとzlibも一緒に入っています.いらっしゃい!次は,上のログにもある通り,実行しろと言われている処理があるので命令に従う.
> sudo -u mysql mysql_install_db5 Installing MySQL system tables... 071118 22:55:02 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK Filling help tables... 071118 22:55:03 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive 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: /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin -u root -h 13.0.168.192.in-addr.arpa password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com
OK OK と言っているから大丈夫でしょう.そのまま設定ファイルの編集に移ります.
> sudo cp /opt/local/share/mysql5/mysql/my-small.cnf /opt/local/etc/mysql5/my.cnf > emacs /opt/local/etc/mysql5/my.cnf # 以下の1行を追加 default-character-set = utf8
2007-12-04 追記
MySQLの文字コードの設定はややこしくて,上記の作業だけじゃ上手くいきません!誤解を与える書き方をしてしまってすみませんでした.
ヽ( ・∀・)ノくまくまー(2006-10-11)に書いてある話をよく読んで設定すると上手くいくと思います!
MySQLの起動と停止
- server付きでインストールしたことにより,launchctlが使えます.
# 起動 > sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist # 停止 > sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql5.plist
Railsのdatabase.ymlに書くこと
development: adapter: mysql database: DATABASE username: USERNAME password: PASSWORD socket: /opt/local/var/run/mysql5/mysqld.sock encoding: utf8 host: localhost test: (略) production: (略)
よし
これでRailsアプリを開発できるようになったよ!
はてなブックマークの本欲しい!
キャンペーンですね,はてなブックマークの本欲しい!
でもよく考えたら買ったけど読んでいない本がちょっとたまっているな.最近になって,本を読む習慣が薄れつつある.移動中は考え事をすることが多くなった.
MailにGmailのアカウントを追加
今日からMac OSXの設定日記が始まるのです!早速,先日から始まったIMAPを利用してGmailのメールをMailで読もう.
http://mail.google.com/support/bin/answer.py?answer=77663
上記URLを参照すれば大丈夫だね.アカウントを追加するときに「自動的にアカウントを設定」にチェックが入っていると,デフォルトのPOPで話が進むようなので気をつけよう.
アカウントの種類 : IMAP
受信用メールサーバ : imap.gmail.com
ユーザ名 : Googleアカウント名
パスワード : Googleアカウントのパスワード
送信用メールサーバ : smtp.gmail.com
ActiveRecordを使うときにはテーブルのカラム名に気を付けよう
カラム名に「type」を使用して怒られました.使ってはいけないもの一覧を貼っておきましょう.
参考 : 保護者の方へ
silence_stream schema_format before_validation_on_update readonly! save_with_validation! __send__ save! before_update update methods colorize_logging decode_b attributes_before_type_cast valid? instance_values save_with_transactions! taint primary_key_prefix_type before_save toggle! after_validation_on_update readonly? subclasses_of clear_aggregation_cache save_without_validation! singleton_methods hash after_update update_attribute_with_validation_skipping update_attribute encode64 initialize send connection instance_exec save_without_transactions! display instance_of? after_save nil? unloadable id_before_type_cast suppress validate clear_association_cache protected_methods default_timezone update_with_callbacks tainted? instance_eval to_param returning untaint kind_of? table_name_prefix create_or_update_with_callbacks valid_with_callbacks? locking_enabled? dclone equal? quote_with_deprecation attributes_from_column_definition_with_lock update_attributes! save private_methods update_without_callbacks increment ` attribute_present? b64encode quote with_options create_without_timestamps is_a? configurations valid_without_callbacks? freeze attribute_names eql? quoted_id require_library_or_gem load before_destroy extended_by id update_attributes attributes_from_column_definition destroy_with_transactions allow_concurrency before_validation public_methods daemonize has_attribute? id= update_with_timestamps extend table_name_suffix before_create save_with_validation require_gem require after_destroy reload update_with_lock copy_instance_variables_from type to_yaml to_yaml_style method destroy_without_transactions increment! instance_variables lock! after_validation frozen? decrement to_json errors update_without_timestamps to_a after_create blank? record_timestamps destroy_with_callbacks class silence_warnings update_attribute_without_validation_skipping to_yaml_properties gem save_with_transactions transaction object_id instance_variable_get enable_warnings validate_on_create generate_read_methods before_validation_on_create == attributes respond_to_without_attributes? === new_record? to_s pluralize_table_names create_with_callbacks create_or_update verification_timeout attributes= save_without_validation create_with_timestamps destroy_without_callbacks initialize_with_callbacks taguri clone destroy column_for_attribute save_without_transactions to_query decrement! =~ instance_variable_set silence_stderr after_validation_on_create lock_optimistically validate_on_update remove_subclasses_of toggle taguri= __id__ to_xml logger inspect [] decode64 create respond_to? extend_with_included_modules_from []= dup
追記
コメント欄にてid:ujihisaさんよりご指摘をいただきまして,ソートしたものを載せることにしました! ujihisa++
== === =~ [] []= __id__ __send__ ` after_create after_destroy after_save after_update after_validation after_validation_on_create after_validation_on_update allow_concurrency attribute_names attribute_present? attributes attributes= attributes_before_type_cast attributes_from_column_definition attributes_from_column_definition_with_lock b64encode before_create before_destroy before_save before_update before_validation before_validation_on_create before_validation_on_update blank? class clear_aggregation_cache clear_association_cache clone colorize_logging column_for_attribute configurations connection copy_instance_variables_from create create_or_update create_or_update_with_callbacks create_with_callbacks create_with_timestamps create_without_timestamps daemonize dclone decode64 decode_b decrement decrement! default_timezone destroy destroy_with_callbacks destroy_with_transactions destroy_without_callbacks destroy_without_transactions display dup enable_warnings encode64 eql? equal? errors extend extend_with_included_modules_from extended_by freeze frozen? gem generate_read_methods has_attribute? hash id id= id_before_type_cast increment increment! initialize initialize_with_callbacks inspect instance_eval instance_exec instance_of? instance_values instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? kind_of? load lock! lock_optimistically locking_enabled? logger method methods new_record? nil? object_id pluralize_table_names primary_key_prefix_type private_methods protected_methods public_methods quote quote_with_deprecation quoted_id readonly! readonly? record_timestamps reload remove_subclasses_of require require_gem require_library_or_gem respond_to? respond_to_without_attributes? returning save save! save_with_transactions save_with_transactions! save_with_validation save_with_validation! save_without_transactions save_without_transactions! save_without_validation save_without_validation! schema_format send silence_stderr silence_stream silence_warnings singleton_methods subclasses_of suppress table_name_prefix table_name_suffix taguri taguri= taint tainted? to_a to_json to_param to_query to_s to_xml to_yaml to_yaml_properties to_yaml_style toggle toggle! transaction type unloadable untaint update update_attribute update_attribute_with_validation_skipping update_attribute_without_validation_skipping update_attributes update_attributes! update_with_callbacks update_with_lock update_with_timestamps update_without_callbacks update_without_timestamps valid? valid_with_callbacks? valid_without_callbacks? validate validate_on_create validate_on_update verification_timeout with_options
これでいいかな!
XKeymacsを導入
といっても一部の「カーソル移動」「消去、編集」のキーだけを使用する設定.一部,キーの競合が発生しているからまた調整が必要だ.
テーマカスタマイズの記録3
ページの表示を早くするために検討すべきWordPressの13のタグ | コリスを見ながら,テンプレートタグをガシガシと静的HTMLに置き換えていく簡単な作業をした(静的な意味で).
before | after |
---|---|
<?php bloginfo('html_type'); ?> | text/html |
<?php bloginfo('charset'); ?> | UTF-8 |
<?php bloginfo('version'); ?> | ME2.2.3 |
<?php bloginfo('name'); ?> | cameraLady |
<?php bloginfo('stylesheet_url'); ?> | http://june29.jp/wp-content/themes/72class/style.css |
<?php bloginfo('stylesheet_directory'); ?> | http://june29.jp/wp-content/themes/72class/ |
<?php bloginfo('rss2_url'); ?> | http://june29.jp/feed/ |
<?php bloginfo('rss_url'); ?> | http://june29.jp/feed/rss/ |
<?php bloginfo('atom_url'); ?> | http://june29.jp/feed/atom/ |
<?php bloginfo('pingback_url'); ?> | http://june29.jp/xmlrpc.php |
<?php bloginfo('description'); ?> | My life is still a stage of the draft |