CentOS 7 で WordPress のプラグインを手早く試す

概要

調査や評価などの目的で WordPress のプラグインを試したい時のために、VirtualBox で手早く環境を構築する手順をまとめた。
コンソールで WordPress を操作する WP-CLI を利用し、コンソール上で WordPress 本体およびプラグインのインストールを実施する。

構築環境例

  • VirtualBox 5.1.22
    • CentOS 7.3.1611 (minimal)
      • Apache 2.4.6
      • PHP 5.4.16
      • MariaDB 5.5.52
      • WP-CLI 1.2.0
      • WordPress 4.7.5

インストール

Apache / PHP / MariaDB

yum -y install php{,-gd,-mbstring,-mysqlnd} mariadb-server
sed -i.org 's|;date.timezone =|date.timezone = Asia/Tokyo|' /etc/php.ini
systemctl start httpd mariadb && systemctl enable httpd mariadb
firewall-cmd --add-service=http{,s} --permanent && firewall-cmd --reload

WP-CLI

curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp && chmod +x /usr/local/bin/wp
curl https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash -o /etc/profile.d/wp-completion.sh
source /etc/profile.d/wp-completion.sh

WordPress

cd /var/www/html
wp core download --locale=ja
mysqladmin create wordpress --default-character-set=utf8mb4
wp core config --dbname=wordpress --dbuser=root
wp core install --url=192.168.56.101 --title="Plugin Test" --admin_user=test_admin --admin_password=P@ssw0rd --admin_email=admin@example.com
chown -R apache. *

プラグインの管理

wp plugin status
3 installed plugins:
  I akismet            3.3.2
  I hello              1.6
  I wp-multibyte-patch 2.8.1

Legend: I = Inactive

プラグインの一覧

wp plugin list
+--------------------+----------+--------+---------+
| name               | status   | update | version |
+--------------------+----------+--------+---------+
| akismet            | inactive | none   | 3.3.2   |
| hello              | inactive | none   | 1.6     |
| wp-multibyte-patch | inactive | none   | 2.8.1   |
+--------------------+----------+--------+---------+

プラグインの削除

wp plugin delete hello
Deleted 'hello' plugin.
Success: Deleted 1 of 1 plugins.

プラグインの検索

wp plugin search 'poll'
Success: Showing 10 of 321 plugins.
+---------------------------------------------------+------------------------------+--------+
| name                                              | slug                         | rating |
+---------------------------------------------------+------------------------------+--------+
| WP-Polls                                          | wp-polls                     | 84     |
| Poll – Video Poll, Image Poll for WordPress | poll-wp                      | 100    |
| YOP Poll                                          | yop-poll                     | 90     |
| Poll, Survey, Quiz, Slideshow & Form Builder  | social-polls-by-opinionstage | 90     |
| Democracy Poll                                    | democracy-poll               | 96     |
| Polldaddy Polls & Ratings                     | polldaddy                    | 60     |
| WP Poll                                           | wp-poll                      | 100    |
| Poll – Poll system                          | polls-widget                 | 56     |
| WordPress Poll                                    | cardoza-wordpress-poll       | 60     |
| DYAMAR Polls                                      | dyamar-polls                 | 100    |
+---------------------------------------------------+------------------------------+--------+

プラグインを投票数でソート

wp plugin search 'poll' --format=csv --fields=num_ratings,slug,rating --per-page=100 | sort -t, -k1 -r -n | head
1839,cleantalk-spam-protect,98
395,wp-live-chat-support,92
369,yop-poll,90
328,wp-staging,98
193,formidable,88
170,social-polls-by-opinionstage,90
122,likebtn-like-button,86
101,wp-polls,84
83,like-box,84
72,captainform,96

プラグインのインストール

wp plugin install yop-poll formidable wp-polls captainform awesome-surveys --activate