Apacheのインストール

インスト-ル

yum install httpd
systemctl start httpd
systemctl enable httpd

これでapacheが起動して、ブラウザでアクセスし確認しますが
CentOS7のデフォルトではhttpプロトコルの通信はfirewalldで
ブロックされているので、http通信を許可する設定を行います。

firewalldの設定

#Firewallの設定
firewall-cmd --list-services --zone=public

#http通信を許可
firewall-cmd --add-service=http --zone=public --permanent

#再読み込み
firewall-cmd --reload

yumリポジトリの設定

EPELと、remiのリポジトリを追加する

EPELリポジトリの追加

yum install epel-release

remiリポジトリを追加する

rpm --import https://raw.githubusercontent.com/remicollet/remirepo/master/remi-release/RPM-GPG-KEY-remi
yum install yum-utils http://mirror.smartmedia.net.id/remi/enterprise/remi-release-7.rpm

PHPのインストール

PHP7.0はremiリポジトリからインストールする必要があります。

yum install php php-mbstring php-gmp --enablerepo=remi-php70
yum install php-mysqlnd --enablerepo=remi-php70

Mariadbインストール

yum install mariadb-server

/etc/my.cnf.d/server.cnf に以下の設定を追加

[mysqld]
character-set-server=utf8

/etc/my.cnf.d/client.cnf に以下の設定を追加

[client]
default-character-set=utf8
起動します。
systemctl start mariadb

初期設定
/usr/bin/mysql_secure_installation
最初に聞かれるパスワードはエンター

動作チェック

testユーザを作成し、テーブルを作成する。
root でログインする

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.47-MariaDB MariaDB Server

ユーザ作成

MariaDB [(none)]> grant all on test.* to taro@localhost identified by 'xxx';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> select user from mysql.user;
+------+
| user |
+------+
| root |
| root |
| root |
| taro |
+------+
4 rows in set (0.00 sec)

データベース作成

 MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.00 sec)

一旦ログアウトして、taroユーザでログインして
testデータベースで表を作成し、SQLで操作できるか確認する。

# mysql -u taro -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use test;
Database changed
MariaDB [test]> create table test(num int ,name varchar(10));
Query OK, 0 rows affected (0.08 sec)

MariaDB [test]> insert into test values(1,'aa');
Query OK, 1 row affected (0.00 sec)

MariaDB [test]> select * from test;
+------+------+
| num  | name |
+------+------+
|    1 | aa   |
+------+------+
1 row in set (0.00 sec)

phpMyAdminをインストール

Apache,Mariadbが準備できました。次にphpMyAdminをインストールします。
これもリポジトリからyumコマンドでインストールを実行します。

 yum install phpMyAdmin --enablerepo=remi-php70

この状態ですと、phpMyAdminはリモートアクセスを受付しないので
設定を変更します。
vi /etc/httpd/conf.d/phpMyAdmin.conf を開き、タグで
リモートアクセスを許可します。

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
       Require ip リモート接続するIP
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>

Apacheを再起動します。

systemctl restart httpd

WordPressの設置

ダウンロード

最新版をWordpressの公式サイトよりダウンロードして、展開します。

cd /var/www/html
curl -LO https://ja.wordpress.org/latest-ja.tar.gz
tar -zxvf latest-ja.tar.gz 

wp-config.phpの設定

cd wordpress
cp wp-config-sample.php wp-config.php
vi wp-config.php

wp-configの編集内容

DBの接続情報を環境に合わせて設定します。

// ** MySQL 設定 - この情報はホスティング先から入手してください。 ** //
/** WordPress のためのデータベース名 */
define('DB_NAME', 'XXXXX);

/** MySQL データベースのユーザー名 */
define('DB_USER', 'XXXXX');

/** MySQL データベースのパスワード */
define('DB_PASSWORD', 'XXX');

認証用ユニークキーの秘密鍵を入力します。

define( 'AUTH_KEY',         't`DK%X:>xy|e-Z(BXb/f(Ur`8#~UzUQG-^_Cs_GHs5U-&Wb?pgn^p8(2@}IcnCa|' );
define( 'SECURE_AUTH_KEY',  'D&ovlU#|CvJ##uNq}bel+^MFtT&.b9{UvR]g%ixsXhGlRJ7q!h}XWdEC[BOKXssj' );
define( 'LOGGED_IN_KEY',    'MGKi8Br(&{H*~&0s;{k0<S(O:+f#WM+q|npJ-+P;RDKT:~jrmgj#/-,[hOBk!ry^' );
define( 'NONCE_KEY',        'FIsAsXJKL5ZlQo)iD-pt??eUbdc{_Cn<4!d~yqz))&B D?AwK%)+)F2aNwI|siOe' );
define( 'AUTH_SALT',        '7T-!^i!0,w)L#JK@pc2{8XE[DenYI^BVf{L:jvF,hf}zBf883td6D;Vcy8,S)-&G' );
define( 'SECURE_AUTH_SALT', 'I6`V|mDZq21-J|ihb u^q0F }F_NUcy`l,=obGtq*p#Ybe4a31R,r=|n#=]@]c #' );
define( 'LOGGED_IN_SALT',   'w<$4c$Hmd%/*]`Oom>(hdXW|0M=X={we6;Mpvtg+V.o<$|#_}qG(GaVDEsn,~*4i' );
define( 'NONCE_SALT',       'a|#h{c5|P &xWs4IZ20c2&%4!c(/uG}W:mAvy<I44`jAbup]t=]V<`}.py(wTP%%' );

秘密鍵はオンラインジェネレータを使って作成すると楽です。
このあたりの手順は、公式サイトの wp-config.phpの編集 を参考にしてください。

http://公開ホスト/wordpress/wp-admin/install.php

以上で準備完了です。インストール画面を起動してインストールを行えば
作業終了です。

** おまけ **
プラグインをインストールしようとして、FTPを利用するように言われた場合は、以下の設定をwp-config.phpに追加で行います。

define('FS_METHOD', 'direct');