OpenPNE2系→OpenPNE3系へのアップデート
結論
情報がかなり少なくて悪戦苦闘
最終的には、2.14.9→3.6.5→3.8.10という順番でアップデートに成功した
手順
OpenPNE3.6.5にまずアップデート
OpenPNE2.14からのアップデートですよ
# wget https://github.com/openpne/OpenPNE3/archive/OpenPNE-3.6.5.tar.gz
# tar xvfz OpenPNE-3.6.5.tar.gz
# mv /usr/local/src/OpenPNE3-OpenPNE-3.6.5/ /usr/local/
# mv /usr/local/OpenPNE3-OpenPNE-3.6.5/ /usr/local/OpenPNE36
# mysql -uroot -p openpne < /usr/local/src/openpne2.sql
# cp /usr/local/OpenPNE36/config/ProjectConfiguration.class.php.sample /usr/local/OpenPNE36/config/ProjectConfiguration.class.php
# cp /usr/local/OpenPNE36/config/OpenPNE.yml.sample /usr/local/OpenPNE36/config/OpenPNE.yml
# vi /usr/local/OpenPNE36/config/OpenPNE.yml
# cp /usr/local/OpenPNE2/config.php /usr/local/OpenPNE36/config/config.OpenPNE2.php
※PEARのTar.phpが古くPluginインストール時にエラーになってしまうのでその対策
↓これは日記プラグインインストール時のエラーだけど、こういうエラーが大量に出る
# ./symfony opPlugin:install opDiaryPlugin -r 1.5.0
>> plugin installing plugin "opDiaryPlugin"
>> sfPearFrontendPlugin downloading opDiaryPlugin-1.5.0.tgz ...
>> sfPearFrontendPlugin Starting to download opDiaryPlugin-1.5.0.tgz (64,612 bytes)
>> sfPearFrontendPlugin .
>> sfPearFrontendPlugin .
...
>> sfPearFrontendPlugin .
>> sfPearFrontendPlugin ...done: 64,612 bytes
>> sfPearFrontendPlugin could not extract the package.xml file from
>> sfPearFrontendPlugin "/usr/local/OpenPNE38/cache/.pear/opDiaryPlugin-1.5.0.tgz"
>> sfPearFrontendPlugin Download of "http://get.openpne.jp/opDiaryPlugin-1.5.0.tgz"
>> sfPearFrontendPlugin succeeded, but it is not a valid package archive
>> sfPearFrontendPlugin Invalid or missing remote package file
Plugin "opDiaryPlugin" installation failed:
Tar.phpを新しくしておきます
# cd /usr/local/src/
# wget http://download.pear.php.net/package/Archive_Tar-1.3.11.tgz
# tar xvfz Archive_Tar-1.3.11.tgz
# mv /usr/local/OpenPNE36/lib/vendor/PEAR/Archive/Tar.php /usr/local/OpenPNE36/lib/vendor/PEAR/Archive/Tar.php.bk
# cp /usr/local/src/Archive_Tar-1.3.11/Archive/Tar.php /usr/local/openpne3/lib/vendor/PEAR/Archive/Tar.php
あとは、下記コマンドを実行後、httpd.conf、.htaccessなど変更してブラウザからアクセスできればOK
# ./symfony opPlugin:sync
OpenPNE3.8.10にアップデート
# wget https://codeload.github.com/openpne/OpenPNE3/legacy.zip/OpenPNE-3.8.10
# unzip OpenPNE-3.8.10
# mv /usr/local/src/openpne-OpenPNE3-7902757/ /usr/local/
# mv /usr/local/openpne-OpenPNE3-7902757/ /usr/local/OpenPNE38
# cp /usr/local/OpenPNE38/config/ProjectConfiguration.class.php.sample /usr/local/OpenPNE38/config/ProjectConfiguration.class.php
# cp /usr/local/OpenPNE38/config/OpenPNE.yml.sample /usr/local/OpenPNE38/config/OpenPNE.yml
# vi /usr/local/OpenPNE38/config/OpenPNE.yml
# cp /usr/local/OpenPNE36/config/databases.yml /usr/local/OpenPNE38/config/databases.yml
symfonyでインストール
# ./symfony doctrine:build-model
# ./symfony cc
# ./symfony plugin:publish-assets
ディレクトリ変更とかははぶいているので、このまま上から順番に打ち込んでいけばOKってわけではない
流れはこんな感じで大丈夫かと思うので自分の環境に合わせて適宜読み替えてください。
エラーもろもろ
さて、インストールしたはいいが、エラーが大量に出ていてこのままでは使い物にならない
opSkinClassicPlugin_loginでエラー
さて、インストール終わり♪さぁ動かそう♪と思ったら、トップページにこんなメッセージ
現在、サーバが混み合っているか、メンテナンス中です。
ご迷惑をおかけいたしますが、しばらく時間を空けて再度アクセスしてください。
Currently, our service is too busy or is under maintenance.
We're sorry and please retry accessing later.
ググってみると、同じようなエラーに悩まされている人が2人...たった2人!?
デバッグモードのようなものがあるらしく、
pc_frontend_dev.php
を見ろと書いてある。見てみると、こんな感じのメッセージ?これはApacheのログの方だったかな...
500 | Internal Server Error | sfConfigurationException
The route "opSkinClassicPlugin_login" does not exist.
調べてみても全然ひっかからない
そして3日ほど悩んだ。いやほんとに。
このプラグイン(opSkinClassicPlugin)をはずしてみても、このエラーが出る
これはDBが悪さをしているなーと思ったのでDBのdumpファイルで検索するとようやく発見。
mysql> select * from sns_config where name = 'external_pc_login_url';
+----+-----------------------+----------------------------+
| id | name | value |
+----+-----------------------+----------------------------+
| 49 | external_pc_login_url | @opSkinClassicPlugin_login |
+----+-----------------------+----------------------------+
1 row in set (0.00 sec)
どうやらexternal_pc_login_urlが指定されていると、ログインするときに強制的に読みにいっちゃう?のか?
消すのは不安なので、とりあえずUPDATEして様子を見る
mysql> update sns_config set name='_external_pc_login_url' where id=49;
そしてアクセスすると...
出た―!普通のログイン画面出た―!
ファイルの置き換え
さて、大きなエラーは消えたが、pc_frontend_dev.phpを見ると、色々エラーが出てることに気づく
どうやらPHP5.5&ログモードを厳しめで動かしていると、古いスクリプトがエラーになっちゃうみたい
エラーが出ているファイルをひたすら修正
/usr/local/OpenPNE38/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php:155
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
↓
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null);
/usr/local/OpenPNE38/lib/vendor/symfony/lib/exception/sfException.class.php:103
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
↓
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null);
/usr/local/OpenPNE38/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php:1152
return array_diff($componentsAfter, $componentsBefore);
↓
$diff = array();
foreach($componentsAfter as $key => $val) {
if(!isset($componentsBefore[$key])) {
$diff[$key] = $val;
} elseif(is_array($componentsBefore[$key]) && !is_array($val)) {
$diff[$key] = $val;
}
}
return $diff;
/usr/local/OpenPNE38/lib/vendor/symfony/lib/response/sfWebResponse.class.php
return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst(strtolower($name)), '_', '-'));
↓
strtr(ucfirst(strtolower($name)), '_', '-');
return str_replace(array('\'$1$3\'','\'$2$4\'','\'$1\'', '\'$2\'', '$1', '$2'),array('$matches[1].$matches[3]','$matches[2].$matches[4]','$matches[1]','$matches[2]','$matches[1]','$matches[2]'),$name);
/usr/local/OpenPNE38/lib/vendor/symfony/lib/util/sfToolkit.class.php:362
return preg_replace(array_keys($replacePairs), array_values($replacePairs), $search);
↓
foreach($replacePairs as $pattern => $replacement)
{
if (preg_match('/(.*)e$/', $pattern, $matches))
{
$pattern = $matches[1];
$search = preg_replace_callback($pattern, function ($matches) use ($replacement) {
preg_match("/('::'\.)?([a-z]*)\('\\\\([0-9]{1})'\)/", $replacement, $match);
return ($match[1]==''?'':'::').call_user_func($match[2], $matches[$match[3]]);
}, $search);
}
else
{
$search = preg_replace($pattern, $replacement, $search);
}
}
return $search;
こんなにたくさん勝手に書き換えていいのか??自己責任で...
まだあるのかもしれないけど、とりあえず動けばいい、の精神で
シンボリックリンク?エイリアス?
pc_frontend_dev.phpで画像が表示されないので、とりあえず張ってみた
ApacheのAlias指定の方がいいのかなぁ...
# ln -s /usr/local/OpenPNE38/lib/vendor/symfony/data/web/sf /usr/local/OpenPNE38/web/sf
opDiaryPluginインストール
さて、ログイン後、ホーム画面は表示されるんだけど、各種日記等の個別ページに行こうとするとなんか足りないと言われる
Fatal error: Class 'DiaryCommentForm' not found in ...
ググっても1件もない
私だけですか...色々やりすぎておかしくなっちゃったのかな
# ./symfony opPlugin:install opDiaryPlugin -r 1.5.0
プラグインを再インストール?してあげればOK
ちなみにTar.phpが古いと失敗するので、Tar.php新しくするのは必須
この時初めて知ったんだけど、OpenPNE3からは日記書くのもプラグインいれなきゃだめなのね
もっとマニュアルとかにガンガン書いておいてくれてもいいんじゃないかしら...
日記書くのなんて基本機能なんだからそのくらい付けておいてくれてもいいんじゃ...
大量のPHPエラー
Strict Standards: Non-static method Calendar_Engine_Factory::getEngine() should not be called statically, assuming $this from incompatible context in /usr/local/OpenPNE38/lib/vendor/PEAR/Calendar/Calendar.php on line 210
pc_frontend_dev.php見てるとこういうのが大量に出る
これはPHPのエラーレベルにE_DEPRECATEDが加わったためで、将来的にサポートされなくなる関数が使用されているときに出る警告らしい
場当たり的な対処かもしれないけれど、とりあえずエラーレベルを変更次のymlファイルを編集してエラーレベルを変更
/apps/pc_frontend/config/settings.yml
/apps/pc_backend/config/settings.yml
/apps/mobile_frontend/config/settings.yml
/apps/mobile_mail_frontend/config/settings.yml
dev:
.settings:
error_reporting: <?php echo (E_ERROR & ~E_NOTICE & ~E_PARSE)."\n" ?>
web_debug: true
cache: false
no_script_name: false
etag: false
てか、こんな対処するしかないのー!?
と、このあたりでOpenPNE導入はちょっと...やめたいなと思い始めてきた(こんなんだと全世界に公開、はナシかなぁ。社内SNSくらいなら...アリ?)
---
とりあえずここまで。
もう少し色々使ってみたらまた、かくかも
Apache2.2系でデータベースを使ったユーザ認証(mod_authn_mysql)
かなりはまった上、あんまり情報が見つからなかったので、メモがてら。
ApacheでのBasic認証といえば、.htpasswdファイルで設定するのが定番だけどDBを使って認証することもできる
今回は、MySQLで設定するべく環境を構築した
yumインストールでのインストール方法はよくあるみたいで引っかかるのだがソースからインストールしている人が全然いない
yumでインストールしたいのはやまやまなんだけど、ソースからしろということなので...結局3日くらい悩んだYO
mod_auth_mysqlインストール
環境
CentOS6
MySQL5.6.16 ソースインストール済み
Apache2.2.26 ソースインストール済み
PHP5.5.10 ソースインストール済み
ソースGET
3.0.0が最新版。最新版といっても2005-08-04のもの。今2014年なので10年近く前なんですけど...
枯れている技術なのか使わない方がいいのか分からんが、どれだけ探してもこれしかないのでしょうがなくダウンロード
# wget http://downloads.sourceforge.net/project/modauthmysql/modauthmysql/3.0.0/mod_auth_mysql-3.0.0.tar.gz
いざインストール
解凍したフォルダ内のBUILDファイルを見ると、
apxs -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
みたいなコマンドを打てと書いてある。パスを適切に書き換えて、インストールする...が、エラーが大量に出た
# tar xvfz mod_auth_mysql-3.0.0.tar.gz
# cd mod_auth_mysql-3.0.0
# /usr/local/apache2/bin/apxs -c -L/usr/local/mysql/lib -I/usr/local/mysql/include -lmysqlclient -lm -lz mod_auth_mysql.c
/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/mysql/include -c -o mod_auth_mysql.lo mod_auth_mysql.c && touch mod_auth_mysql.slo
mod_auth_mysql.c:591: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:595: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:599: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:603: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:607: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:611: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:615: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:619: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:623: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:627: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:631: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:635: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:639: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:643: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:651: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:655: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:659: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:663: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:667: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c:671: error: expected expression before 'mysql_auth_config_rec'
mod_auth_mysql.c: In function 'format_request':
mod_auth_mysql.c:947: warning: pointer/integer type mismatch in conditional expression
apxs:Error: Command failed with rc=65536
ググってみると、どうやらApache2.2用パッチがあるらしい
Apache2.2用パッチをあてる
これをあててから再度インストール
# wget http://sourceforge.net/p/modauthmysql/patches/_discuss/thread/efda3a06/c5a7/attachment/apache22.diff
# patch -p0 < apache22.diff
# /usr/local/apache2/bin/apxs -c -L/usr/local/mysql/lib -I/usr/local/mysql/include -lmysqlclient -lm -lz mod_auth_mysql.c
# /usr/local/apache2/bin/apxs -i mod_auth_mysql.la
エラーでなくなった。
無事に成功した模様。
httpd.confの設定
httpd.confにLoadModuleを追加
# vi /usr/local/apache2/conf/httpd.conf
動くかと思いきや失敗
# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Syntax error on line 54 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_auth_mysql.so into server: /usr/local/apache2/modules/mod_auth_mysql.so: symbol mysql_select_db, version libmysqlclient_18 not defined in file libmysqlclient.so.18 with link time reference
[FAILED]
うーん、ライブラリがちゃんとリンクしてないみたい
# ldd /usr/local/apache2/modules/mod_auth_mysql.so
libmysqlclient.so.18 => /usr/lib64/mysql/libmysqlclient.so.18
libmysqlclient.so.18が変なところ見てるなぁ...
誰かが yum install mysql した跡があるので、その時にはいったっぽい?
ソースからインストールしている人があまりいなくて半日ほどぐるぐる悩む...
ようやく http://d.hatena.ne.jp/natsumesouxx/20111126/1322339821 が引っかかった
ldconfigで一時的に探索パスを追加
# ldconfig /usr/local/mysql/lib
再度インストール作業やりなおし
無事正しいパスでインストールされた
# ldd /usr/local/apache2/modules/mod_auth_mysql.so
libmysqlclient.so.18 => /usr/local/mysql/lib/libmysqlclient.so.18
動くかな?
# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
やっと動いたー!お疲れ!
MySQLで認証用のテーブル作る
mysql> CREATE DATABASE auth_db;
mysql> USE auth_db;
mysql> CREATE TABLE users (user CHAR(32) NOT NULL,passwd CHAR(64) NOT NULL,PRIMARY KEY (user));
mysql> GRANT SELECT ON auth_db.users TO authuser@localhost IDENTIFIED BY 'PaSsW0Rd';
mysql> INSERT INTO users VALUES ('user_name', ENCRYPT('user_password'));
Query OK, 1 row affected (0.01 sec)
mysql> \q
この辺は情報も多いので特に悩まず...
暗号化方式何にしようかな?くらい
md5やsha1は古いらしいので、今ならcryptがよいらしい
参考:http://php.net/manual/ja/faq.passwords.php
httpd.confで認証設定
# vi /usr/local/apache2/conf/httpd.conf
下記記述を適当な位置に追加(一番最後とか)
<Directory /usr/local/apache2/htdocs/test_login>
AuthName "MySQL authenticated zone"
AuthType Basic
AuthMYSQLEnable on
AuthMySQLUser authuser
AuthMySQLPassword PaSsW0Rd
AuthMySQLDB auth_db
AuthMySQLUserTable users
AuthMySQLNameField user
AuthMySQLPasswordField passwd
require valid-user
</Directory>
Apache再起動してブラウザからアクセス
httpd://xxx.xxx.xxx.xxx/test_login/
ベーシック認証の表示がされる→認証OK
...となるはずがちゃんと動かない!!!!!
エラーログを見ると下記のようなエラーが出ている
# vi /usr/local/apache2/logs/error_log
[Fri Mar 28 10:56:45 2014] [error] [client xxx.xxx.xxx.xxx] AuthUserFile not specified in the configuration
グーグル検索でひっかかった下記を参考に、再度設定
<Directory /usr/local/apache2/htdocs/test_login>
AuthBasicAuthoritative off
AuthMySQLAuthoritative On
AuthUserFile /dev/null
AuthName "MySQL authenticated zone"
AuthType Basic
AuthMYSQLEnable on
AuthMySQLUser authuser
AuthMySQLPassword PaSsW0Rd
AuthMySQLDB auth_db
AuthMySQLUserTable users
AuthMySQLNameField user
AuthMySQLPasswordField passwd
require valid-user
</Directory>
太字部分が必要らしい
Apache再起動して、再度アクセス
→OK!お疲れ!