macportsでphp5をupgradeしたらactivateでエラー

macportsでphp5をアップグレードした。
php5 @5.2.9_2+apache2+macosx+mysql5+pear+postgresql82+sqlite
 ↓
php5 @5.2.10_0+apache2+macosx+mysql5+pear+postgresql82+sqlite
すると、以下のエラー。
(追記: 後日、php5 @5.2.10_1が出たのでアップグレードしたら何の問題もなかった。)

$ sudo port upgrade php5
--->  Fetching php5
--->  Verifying checksum(s) for php5
--->  Extracting php5
--->  Applying patches to php5
--->  Configuring php5
--->  Building php5
--->  Staging php5 into destroot
Warning: php5 requests to install files outside the common directory structure!
--->  Deactivating php5 @5.2.9_2+apache2+macosx+mysql5+pear+postgresql82+sqlite
--->  Installing php5 @5.2.10_0+apache2+macosx+mysql5+pear+postgresql82+sqlite
--->  Activating php5 @5.2.10_0+apache2+macosx+mysql5+pear+postgresql82+sqlite
Error: Target org.macports.activate returned: Image error: /opt/local/lib/php/.registry/xml_util.reg already exists and does not belong to a registered port.  Unable to activate port php5.

最後のフェーズのactivateで失敗している。(ファイルのコピーでエラー)
-f オプションを付けて、強制的にactivateした。

$ sudo port -f activate php5 @5.2.10_0+apache2+macosx+mysql5+pear+postgresql82+sqlite
Password:
--->  Activating php5 @5.2.10_0+apache2+macosx+mysql5+pear+postgresql82+sqlite
Warning: File /opt/local/lib/php/.registry/xml_util.reg already exists.  Moving to: /opt/local/lib/php/.registry/xml_util.reg.mp_1246068080.
Warning: File /opt/local/lib/php/doc/XML_Util/examples/example.php already exists.  Moving to: /opt/local/lib/php/doc/XML_Util/examples/example.php.mp_1246068080.
Warning: File /opt/local/lib/php/doc/XML_Util/examples/example2.php already exists.  Moving to: /opt/local/lib/php/doc/XML_Util/examples/example2.php.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/AllTests.php already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/AllTests.php.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_apiVersion.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_apiVersion.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_attributesToString.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_attributesToString.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_collapseEmptyTags.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_collapseEmptyTags.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_createCDataSection.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_createCDataSection.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_createComment.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_createComment.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_createEndElement.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_createEndElement.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_createStartElement.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_createStartElement.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_createTag.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_createTag.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_createTagFromArray.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_createTagFromArray.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_getDocTypeDeclaration.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_getDocTypeDeclaration.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_getXmlDeclaration.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_getXmlDeclaration.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_isValidName.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_isValidName.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_raiseError.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_raiseError.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_replaceEntities.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_replaceEntities.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_reverseEntities.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_reverseEntities.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBasic_splitQualifiedName.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBasic_splitQualifiedName.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBug_4950.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBug_4950.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/test/XML_Util/tests/testBug_5392.phpt already exists.  Moving to: /opt/local/lib/php/test/XML_Util/tests/testBug_5392.phpt.mp_1246068080.
Warning: File /opt/local/lib/php/XML/Util.php already exists.  Moving to: /opt/local/lib/php/XML/Util.php.mp_1246068080.

mod_rewriteでフォワードされたリクエストにリクエストヘッダーを追加する

RewriteRuleのenvフラグで環境変数をセットしておき、RequestHeader append で使う。

  RewriteEngine on
  RewriteRule ^/(.*)$ http://appserver/$1 [P,L,QSA,env=ORG_REMOTE_ADDR:%{REMOTE_ADDR}]
  ProxyPassReverse / http://appserver/
  RequestHeader append X_ORG_REMOTE_ADDR %{ORG_REMOTE_ADDR}e env=ORG_REMOTE_ADDR
  RequestHeader append X-Forwarded-Proto https

mod_rewrite - Apache HTTP Server
たまねぎプログラマハマリ日記:Apache内のCGI環境変数をTomcatに渡す。 - livedoor Blog(ブログ)

findで検索した結果を削除したりgrepする方法

-exec command \;
  • 検索後、コマンドcommandを実行する。検索結果をcommandに引き渡すには、{}をもちいる。
  • \; の前に空白が必要。空白がないと、
    find: `-exec' に引数が見つかりません
    

    とか

    find: -exec: no terminating ";" or "+"
    

    というエラーになる。

例:

find ~ -name '*bak" -exec rm {} \;
  • 上記の例で-execにつづくrm {} \;が実行されるコマンド。最後の";"は-execのパラメタの終わりを示しており、その前の"\"は、";"がシェルに解釈されないようにエスケープする為のもの。

例:
ホームディレクトリ以下にある*~(emacsのバックアップファイル)を全て削除

$ find ~/ -name "*~" -exec rm {} \;

Subversionの作業コピーディレクトリから.svnディレクトリを全て削除する。

find . -name .svn -exec rm -rf {} \;

ディレクトリ配下のファイルをgrepする
(grepのオプション -H はファイル名表示、-n は行番号表示)

find ディレクトリ -type f -exec grep -nH 文字列 {} \;

You can't specify target table 'xxx' for update in FROM clause

MySQLでは、サブクエリ FROM 節と更新対象の両方に同じテーブルを使用することはでき
ない。

Source: MySQL :: MySQL 5.1 リファレンスマニュアル :: 12.2.8.9 サブクエリ エラー

mysql> delete from user \
    -> where user.id in \
    -> (select user.id from user \
    -> left join reserve_data on user.id = reserve_data.user_id where reserve_data.id is null);
ERROR 1093 (HY000): You can't specify target table 'user' for update in FROM clause

このような場合は、以下のようにする。

mysql> delete from user \
    -> where user.id in \
    -> (select x.id from \
    -> (select user.id from user left join reserve_data on user.id = reserve_data.user_id where reserve_data.id is null) \
    -> as x \
    -> );
Query OK, 350 rows affected (0.00 sec)

こうすると、暗黙的に一時テーブルが作成されるので、うまくいく。

Source: SQL Delete: can't specify target table for update in FROM clause - Stack Overflow