文系プログラマによるTIPSブログ

文系プログラマ脳の私が開発現場で学んだ事やプログラミングのTIPSをまとめています。

Yosemiteインストール後のhomebrew・apacheのエラー対応等

最近公開されたMacOSX Yosemiteですが、自宅だけでなく会社のmacbook airにインストールしました。

インストール後に色々困った事が起きたので、現象の内容と解決策についてまとめます。


f:id:treeapps:20170829002500p:plain

無線LANの設定が外れる

いつも指定していた無線LANのアクセスポイントの指定が外れていました。
指定し直すだけでOKでした。

Yosemiteのインストールが異常に遅かった

どうもYosemiteインストール時に、/usr/localをどこかに一旦退避するそうで、homebrew等を入れている人は/usr/localが肥大化しがちで、その退避がインストールの途中で行われるため、残り後1分なのにそこから2時間かかったりしたようです。

Yosemiteインストール前に/usr/localを事前に退避すると高速化できるようですが、無闇に移動してアプリに影響を与えるくらいなら、いっその事待った方がいいです。macbook air 2012で2時間くらいで終わりました。

homebrewが動かない

brewコマンドを実行すると以下のエラーが発生します。

tree-macbookair:etc tree$ brew update
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0

このエラーの原因はYosemiteになるとRubyのバージョンが1.8から2.0に強制アップデートされるためです。

tree-macbookair:etc tree$ ruby -version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

これを解消するために、まずhomebrewのbrew.rbの1行目を以下のように修正します。バージョン固定でなく、Currentを指定します。

vi /usr/local/Library/brew.rb

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0

修正後にbrewコマンドを実行すると、更に以下のエラーが発生します。

tree-macbookair:etc tree$ brew update
error: Your local changes to the following files would be overwritten by merge:
	Library/brew.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

これはbrew.rbがgitで管理されていて、コミットしろ!と怒られているのです。
なので、適当なコミットメッセージを指定してコミットします。

まずはステータスの確認。

cd /usr/local
tree-macbookair:local tree$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   Library/brew.rb

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	Library/Formula/subversion.rb.org

no changes added to commit (use "git add" and/or "git commit -a")

brew.rbが変更されている事が確認できました。
ではまずはステージします。

tree-macbookair:local tree$ git add Library/brew.rb

続いてコミットします。

tree-macbookair:local tree$ git commit -m 'update ruby v2.0'
[master a685892] update ruby v2.0
 1 file changed, 1 insertion(+), 1 deletion(-)

最後にbrew updateしようとするとまたコミットメッセージを求められるので、適当に入力して完了です。

brew update

apacheが動かない

apacheを起動してみると、以下のエラーが発生しました。

httpd: Syntax error on line 38 of /hoge-project/infra/local/apache/conf/httpd.conf: Cannot load modules/mod_authn_default.so into server: dlopen(/etc/httpd/modules/mod_authn_default.so, 10): image not found
httpd: Syntax error on line 42 of /hoge-project/infra/local/apache/conf/httpd.conf: Cannot load modules/mod_authz_default.so into server: dlopen(/etc/httpd/modules/mod_authz_default.so, 10): image not found
AH00526: Syntax error on line 3 of /hoge-project/infra/local/apache/conf/httpd.conf:
Invalid command 'User', perhaps misspelled or defined by a module not included in the server configuration

???と思ったので、一旦バージョンを確認。

tree-macbookair:etc tree$ apachectl -version
Server version: Apache/2.4.9 (Unix)
Server built:   Sep  9 2014 14:48:20

バージョンが2.4になってる!!

これはイカンやつですわ。
もう初期インストールのapacheはそのままにして、別途apache2.2をインストールしましょう。
homebrewでインストールすれば、2.2と2.4が共存でき、簡単に起動の切り替えができます。
zlibはhttpd22の依存ライブラリなので、一緒にインストールします。

brew install zlib homebrew/apache/httpd22

linuxでyumでインストールした時の構成を簡単に再現しておきます。

cd /etc
sudo mkdir -pv httpd
cd httpd
sudo mkdir -pv logs conf
sudo ln -sf /usr/local/Cellar/httpd22/2.2.29/libexec /etc/httpd/modules

以下のapachectlはv2.4のものです。

tree-macbookair:httpd tree$ which apachectl
/usr/local/bin/apachectl

homebrewでインストールしたv2.2のapachectlは以下にあります。

/usr/local/Cellar/httpd22/2.2.29/bin/apachectl

なので、

/usr/local/Cellar/httpd22/2.2.29/bin/apachectl -f /hoge-project/infra/local/apache/conf/httpd.conf -k start

とすればapacheをv2.2で起動できますし、

/usr/local/bin/apachectl -f /hoge-project/infra/local/apache/conf/httpd.conf -k start

とすればapacheをv2.4で起動でき、両バージョンを切り替えられます。

USB有線LANが認識しなくなった


mavericksの時にこのプラネックスのUE-1000T-U3を、ドライバのインストール無しで動かして使っていました。しかしyosemiteインストール後に認識されなくなりました。

対応は簡単で、以下のドライバをインストールすると、無事動くようになりました。
ダウンロード|UE-1000T-U3|プラネックス
説明には「Mac OSX 10.8/10.7/10.6版」と書いており、v10.10であるyosemiteが対象外に見えますが、インストールでき、yosemiteで動作します。

雑感


marvericksのインストール後も/etc/httpdが勝手に削除されたり、/var/log配下のフォルダが勝手に削除されたりしたなあ


勝手に削除されるのは困るよなあ。

しかしもうmarvericksの時に同じ事を経験済みだから耐性がついてしまったな


こういう時に自力で直せるかどうかが試されるな。

ここで自力で直せる人はインフラがイケる人、直せない人はイケない人かな


macを使うと必ずローカルのapacheを触る事になるから、嫌でもミドルとかインフラとか覚えないといけない。しかしそれを機に色々覚える事ができるから、macはある意味おすすめだ