LoginSignup
6
2

More than 5 years have passed since last update.

NGINX UnitでWordpressを動かしてみたけど動かなかった

Posted at

アプリケーションサーバ「Nginx Unit」がリリースされたのでWordpressを動かして,ついでにパフォーマンス計測でもしてみようと思った。

けど

  1. Binary PackageはPOSTが扱えなくてWordpressがセットアップできない (2017-09-08 16:00現在)
  2. ソースからコンパイルすればPOSTが扱えるようになりセットアップが完了するものの,トップページがリダイレクトループになる
  3. 力尽きた ← イマココ

トップページのリダイレクトループをどうにかしないと先に進めない。


以下作業メモ

動かしてみる

とりあえずCentOS 7でやってみた。バイナリのインストールは公式の手順通りにやればOK。依存関係の問題でphpのバージョンは5.4を強制される。

Unitの起動

unitdをstartするだけ

root# sudo systemctl start unitd

Unitの設定

これもドキュメントに書いてある通りでOK

user$ cat /etc/unit/wordpress.json
{
     "listeners": {
         "*:8300": {
             "application": "wordpress"
         }
     },
     "applications": {
         "wordpress": {
             "type": "php",
              "workers": 20,
              "root": "/var/www/wordpress",
              "index": "index.php"
         }
     }
}

socketは/run/control.unit.sockに作成されているので

root# curl -X PUT -d @/etc/unit/wordpress.json --unix-socket /run/control.unit.sock http://localhost/

と流し込む。ちなみに設定は永続化されてないので再起動したりすると揮発する。カナシイ。

phpinfoの確認

root# echo '<?php phpinfo();' > /var/www/wordpress/index.php
root# lynx http://127.0.0.1:8300/

Server APIがunitになっているのが確認できる。

wordpressのインストール

必要なパッケージをインストール

root# yum install -y php-mysqlnd mariadb-server

wpのインストールの方法はいろんなところにあるので割愛

/wp-admin/setup-config.php?step=2"Table Prefix" must not be empty.と言われて先に進めない。
$_POSTをdumpしてみるとNULLという悲しい事実。POSTが扱えないらしい。

リポジトリを見るとPHP POSTに関するコミットがあるのでmasterをコンパイルすれば大丈夫な気がする。

Unitのコンパイル

公式の手順で大体大丈夫
ついでなのでPHP 7.1にする。

root# yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
root# yum --enablerepo remi-php71 install -y git gcc make php-devel php-embedded 
root# git clone https://github.com/nginx/unit /tmp/unit
root# cd /tmp/unit
root# ./configure --prefix=/opt/unit
root# ./configure php
root# make
root# make install
root# make php-install

unitの起動は /opt/unit/sbin/unitd でOK

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2