OpenPNEのディレクトリを移動する

2011 年 4 月 4 日 – 1:55 PM

SNSサイトを構築するためのエンジン、OpenPNE。

現在、安定版として3.4がリリースされているが、開発版の3.6beta8もある。

3.6からは、テーブル名にプレフィックスが付与できるようになるようだ。
レンタルサーバでDBが一つしか使用できない場合に便利かなと思って3.6bataを試してみることにした。

レンタルサーバ上で実際に試し、既存のテーブルを壊しては大変なので、一旦ローカル環境に構築し、手動でレンタルサーバ上にアップしてみようなかと。

ダウンロードしたファイルの中にある手順書に従ってインストールは問題なく完了。
これを、別のディレクトリにコピーし、DBもダンプしたものを別のDBにインポート、OpenPNE.yml等も設定しなおして動作させようとした。

事象

  •  ブラウザからアクセスしても何も表示されなかった
  • apacheのログには次の記録があった
    [error] [client x.x.x.x] PHP Fatal error: Cannot instantiate abstract class opAuthAdapter in /(コピー元のディレクトリ名)/lib/user/opAdaptableUser.class.php on line 99

 

原因

cacheディレクトリ内の様々なファイルにはコピー元のディレクトリ名が書かれていた。

対処

symfonyのあるディレクトリに移動してsymfonyを起動してキャッシュをクリアする。

[root@example openpne]# ./symfony cc

 

 

Linux起動時にBIG FAT WARNING!!

2008 年 4 月 4 日 – 11:27 AM

Vine Linux 4.1を某社PCにインストールし、完了後の起動で発見した事例。

事象

  • インストール完了後の再起動時にBIG FAT WARNING!! Failed to translate “/dev/sde3″ into a device id.と表示される。
    (dmesgにも記録されている)
BIG FAT WARNING!! Failed to translate "/dev/sde3" into a device id.

If you want to use the current suspend image, reboot and try
again with the same kernel that you suspended from. If you want
to forget that image, continue and the image will be erased.
Press SPACE to reboot or C to continue booting with this kernel

Default action if you don't select one in 25 seconds is: continue booting.
Suspend2 2.2.5: Missing or invalid storage location (resume2= parameter).
 Please correct and rerun lilo (or equivalent) before suspending.
kjournald starting.  Commit interval 5 seconds

/dev/sde3に関してはdmesg中に次の内容が記録されていた。

Kernel command line: ro root=LABEL=/ resume2=swap:/dev/sde3 vga=0x314
Suspend2 2.2.5: Missing or invalid storage location (resume2= parameter).
Please correct and rerun lilo (or equivalent) before suspending.

原因

/etc/grub.conf(/etc/grub.confは/boot/grub/grub.confへのリンク)を調べるとその内容は以下のようになっており、swapには/dev/sde3が指定されていた。

# menu.lst generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sde2
# initrd /initrd-version.img
#boot=/dev/sde
default=0
timeout=5title Vine Linux (Current kernel)
root (hd0,0)
kernel /vmlinuz ro root=LABEL=/ resume2=swap:/dev/sde3 vga=0×314
initrd /initrd.imgtitle Vine Linux (Previous kernel)
root (hd0,0)
kernel /vmlinuz.old ro root=LABEL=/ resume2=swap:/dev/sde3 vga=0×314
initrd /initrd.old.img

/etc/fstabを調べるとその内容は以下のようになっており、swapにはsde3というラベルがつけられていた。

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=SWAP-sde3 swap swap defaults 0 0

dmesgで調べても/dev/sde3は存在していない。

fdiskで/dev/sdaの領域テーブルを参照すると次のようになっており、/と同一のデバイスにswap領域(swapのIdは82)は作成されていた。

デバイス Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 796 6289447+ 83 Linux
/dev/sda3 797 1050 2040255 82 Linux swap / Solaris
/dev/sda4 1051 38913 304134547+ 83 Linux

Vine Linuxのインストール時点の自動パーティション設定で「このインストールに使用するドライブの選択」のときSATAドライブをsdeと認識していたがそのままインストールを継続したためと思われる。
インストール完了後のSATAの認識では/のデバイスはsdaとなり不整合が発生したようだ。

また、インストール時に自動パーティション設定ではなくDisk Druidを使用してもsdeとして認識されているため同様の事象となると思われる。

対処

インストール時点でsdaと認識させる有効な方法がないものと思われることから、インストール完了後にgrub.confを修正することで対処する。

  • 現在のswapの状態を確認
    Vine Linuxにはswapinfoコマンドがないため、次のコマンドで代替して確認する。
    (現時点ではswapがない状態。)[root@example root]# top
    top – 14:33:29 up 7 min, 1 user, load average: 0.15, 0.65, 0.43
    Tasks: 80 total, 2 running, 78 sleeping, 0 stopped, 0 zombie
    Cpu(s): 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
    Mem: 2065580k total, 155604k used, 1909976k free, 8204k buffers
    Swap: 0k total, 0k used, 0k free, 52116k cached
    (Swapが0kとなっている)
     
    [root@example root]# cat /proc/swaps
    [root@example root]#
    (何も表示されない)
  • swapの設定と確認[root@example root]# mkswap -L SWAP-sda3 /dev/sda3 ←/dev/sda3をswap領域としてフォーマット(通常のインストールと同様にラベルをつける。)
    Setting up swapspace version 1, size = 2089213 kB
    LABEL=SWAP-sda3, UUID=d81dc64e-361b-4f49-822a-f9efecd03e88
    [root@example root]# swapon -L SWAP-sda3 ←スワップを有効化[root@example root]# top  ←topコマンドで確認
    top – 15:35:09 up 39 min, 1 user, load average: 0.35, 0.09, 0.03
    Tasks: 80 total, 1 running, 79 sleeping, 0 stopped, 0 zombie
    Cpu(s): 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
    Mem: 2065580k total, 157068k used, 1908512k free, 8560k buffers
    Swap: 2040244k total, 0k used, 2040244k free, 52540k cached
    (Swapが2040244k)

    [root@example root]# cat /proc/swaps  ←確認のためのコマンド
    Filename Type Size Used Priority
    /dev/sda3 partition 2040244 0 -1
    [root@example root]#
    (/dev/sda3が使用されている)

  • 再起動後のための設定/etc/grub.confを修正
    kernel /vmlinuz ro root=LABEL=/ resume2=swap:/dev/sde3 vga=0×314

    kernel /vmlinuz ro root=LABEL=/ resume2=swap:/dev/sda3 vga=0×314

    /etc/fstabを修正
    fstab上に記述してある「LABEL=SWAP-sde3」を「LABEL=SWAP-sda3」に変更する。

    LABEL=SWAP-sde3 swap swap defaults 0 0

    LABEL=SWAP-sda3 swap swap defaults 0 0

     

  • 再起動後、dmesgを確認し、「BIG FAT WARNING!!」がないことを確認する。また、 swapがsda3にあることを確認する。

    [root@example root]# dmesg|grep BIG
    Use CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.
    [root@example root]# dmesg|grep swap
    Kernel command line: ro root=LABEL=/ resume2=swap:/dev/sda3 vga=0×314
    Adding 2040244k swap on /dev/sda3. Priority:-1 extents:1 across:2040244k ←この行が表示されること
    [root@example root]#[root@example root]# top

    top – 15:40:09 up 1 min, 1 user, load average: 0.36, 0.16, 0.06
    Tasks: 80 total, 1 running, 79 sleeping, 0 stopped, 0 zombie
    Cpu(s): 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
    Mem: 2065580k total, 156928k used, 1908652k free, 8172k buffers
    Swap: 2040244k total, 0k used, 2040244k free, 52408k cached
    (Swapが2040244k)

    [root@example root]# cat /proc/swaps
    Filename Type Size Used Priority
    /dev/sda3 partition 2040244 0 -1
    [root@example root]#

php 短縮型タグが使えない

2008 年 4 月 4 日 – 11:17 AM

事象

phpの短縮型タグが使えない。

phpでphpコードを埋め込むタグは4種類ほどあるが、一般的には次のような記述が用いられる。
 <?php echo $hensu; ?>

html上に多数の変数の値を埋め込む場合、ソースの見やすさを考慮して短縮型のタグを使用することもできる。

 <?= $hensu ?>

原因

短縮型タグが使用できるか否かはphp.ini(/etc/php.ini)で定義されているshort_open_tagパラメータによって決められる。(Offだと使用できない)

[root@example root]# cat /etc/php.ini 
~省略~

; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = Off

 

対処

php.iniを修正し、apacheを再起動する。

..短縮型タグは推奨はされていないようだけど。

postfixadmin 「そのドメインは存在しません」

2008 年 4 月 4 日 – 11:01 AM

事象

  • postfixadminの画面からドメインの追加をしようとしても「そのドメインは存在しません」というエラーが表示される。
  • apacheのログに次のような記録がある

    [error] [client 192.xxx.xxx.xxx] PHP Warning: mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: A link to the server could not be established in /パス名/functions.inc.php on line 131, referer: http://192.xxx.xxx.xxx/url名/create-domain.php

原因

phpのmagic_quotes_gpcがオフになっている

  • Magic Quotes

マジッククオートは、PHPスクリプトに入力されるデータを 自動的にエスケープする機能。
オンの場合、全ての’ (シングルクオート), ” (ダブルクオート), \ (バックスラッシュ)およびNULL 文字がバックスラッシュで自動的にエスケープされる。 これは、addslashes() の機能と同じ。

3種類のマジッククオートディレクティブには..

magic_quotes_gpc HTTPリクエストデータ(GET, POST, そして COOKIE)に作用する。 実行時に設定することはできない。 PHPの出フォルトは、on。
magic_quotes_runtime 有効な場合、データベースやテキストファイルを含む 外部ソースからデータを返す関数の多くは、 バックスラッシュをクオートでエスケープする。 実行時に設定することができ、PHPでのデフォルトは
on。
magic_quotes_sybase 有効な場合、シングルクオートはバックスラッシュではなくシングルクオートで エスケープされる。 onの場合、 magic_quotes_gpc
の指定を完全に上書きする。 これら両方のディレクティブを有効にすると、シングルクオートは ”とエスケープされる。 ダブルクオートやNULLはそのままとなり、エスケープされない。

magic_quotes_gpcの設定を調べる

[root@example root]# cat /etc/php.ini |grep magic
; – magic_quotes_gpc = Off [Performance]
magic_quotes_gpc = Off 
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ‘ with ” instead of \’).
magic_quotes_sybase = Off
[root@example root]#

対処

magic_quotes_gpcを変更して他のAPに支障がないのなら、php.iniを修正し、apacheを再起動する。