wordpress+staticpressでbugに当たったお話

業務上でwordpress+staticpressの環境が必要になったのだが、
バグに当たったりして大変だったので覚え書き。

まずは

CentOS6のEC2をAWSで立てます。
試験環境なので、これでよし。

ハマり始める。

・何度かテストしていると、コンテンツがS3に反映されない
  → どうやら、サーバローカルのstatic指定フォルダを見ているようなので、S3に同期する前にstaticフォルダを綺麗に削除すると同期できた
・サイトレイアウトが全然違う
  → phpが組み込まれているようなテーマを回避した
CSSが機能せず、画面が崩れる
  → 結論:PHPのバグでした。以下に備忘録として対応を記す。

環境

CentOS6.3
PHP5.3.3

バグについて

CSSファイルのmime-typeをphpで出力すると、こうなっている。
なので、S3へ転送したときに「text/x-c」で出力してMeta-Dataを設定しているのでおかしくなっている。


[root@ip-10-2-18-219 nocss]# php mime.php
text/x-c; charset=us-ascii
[root@ip-10-2-18-219 nocss]#
mime.phpはここを参考にした → PHP: finfo_open - Manual

やった対策

yum update php

PHPをアップデート
yum updateでPHPを5.3から5.4にアップデート
php5.3.3 -> 5.4.24


[root@ip-10-2-18-219 nocss]# yum --enablerepo=epel,remi,rpmforge info php
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: mirror.nus.edu.sg
* epel: kartolo.sby.datautama.net.id
* extras: mirror.nus.edu.sg
* remi: mirror.smartmedia.net.id
* rpmforge: mirror.oscc.org.my
* updates: mirror.nus.edu.sg
remi | 2.9 kB 00:00
remi/primary_db | 654 kB 00:00
Installed Packages
Name : php
Arch : x86_64
Version : 5.3.3
Release : 27.el6_5
Size : 3.5 M
Repo : installed
From repo : updates
Summary : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
License : PHP
Description : PHP is an HTML-embedded scripting language. PHP attempts to make
: it easy for developers to write dynamically generated webpages.
: PHP also offers built-in database integration for several
: commercial and non-commercial database management systems, so
: writing a database-enabled webpage with PHP is fairly simple. The
: most common use of PHP coding is probably as a replacement for CGI
: scripts.
:
: The php package contains the module which adds support for the PHP
: language to Apache HTTP Server.

Available Packages
Name : php
Arch : x86_64
Version : 5.4.24
Release : 1.el6.remi
Size : 2.7 M
Repo : remi
Summary : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
License : PHP and Zend and BSD
Description : PHP is an HTML-embedded scripting language. PHP attempts to make
: it easy for developers to write dynamically generated web pages.
: PHP also offers built-in database integration for several
: commercial and non-commercial database management systems, so
: writing a database-enabled webpage with PHP is fairly simple. The
: most common use of PHP coding is probably as a replacement for CGI
: scripts.
:
: The php package contains the module (often referred to as mod_php)
: which adds support for the PHP language to Apache HTTP Server.

yumで詰まる


[root@ip-10-2-18-219 nocss]# yum --enablerepo=epel,remi,rpmforge update php
...
...
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56:
Userid : Remi Collet
Package: remi-release-6.4-1.el6.remi.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Killed
[root@ip-10-2-18-219 nocss]# yum --enablerepo=epel,remi,rpmforge update php

yum cleanもNG


[root@ip-10-2-18-219 nocss]# yum clean all
rpmdb: Thread/process 11771/140081896781568 failed: Thread died in Berkeley DB l ibrary
error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run d atabase recovery
error: cannot open Packages index using db3 - (-30974)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@ip-10-2-18-219 nocss]#

対処

yumのエラーと言うことで、google先生に聞いた。yumやrpmコマンド実行時にエラーが出たときの対処 | Pocketstudio.jp log3を参考にした。


[root@ip-10-2-18-219 nocss]# cd /var/lib/rpm
[root@ip-10-2-18-219 rpm]# ll *db.00*

  • rw-r--r--. 1 root root 24576 Feb 10 01:44 __db.001
  • rw-r--r--. 1 root root 229376 Feb 10 01:44 __db.002
  • rw-r--r--. 1 root root 1318912 Feb 10 01:44 __db.003
  • rw-r--r--. 1 root root 753664 Feb 10 01:44 __db.004

[root@ip-10-2-18-219 rpm]# mv *db.00* /var/tmp
[root@ip-10-2-18-219 rpm]# yum clean all
Loaded plugins: fastestmirror, presto
Cleaning repos: base epel extras rpmforge updates
Cleaning up Everything
Cleaning up list of fastest mirrors
1 delta-package files removed, by presto
[root@ip-10-2-18-219 rpm]#

 → updateがやっぱりNG

色々やってみた

結論: httpdとmysqldのプロセスをstopした上でyum updateする → OK


service httpd stop
service mysqld stop
yum --enablerepo=epel,remi,rpmforge update php
service httpd start
service mysqld start

update後


[root@ip-10-2-18-219 nocss]# php mime.php
text/plain; charset=us-ascii
[root@ip-10-2-18-219 static]# php --version
PHP 5.4.24 (cli) (built: Jan 9 2014 07:32:12)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[root@ip-10-2-18-219 static]#