LoginSignup
29
39

More than 5 years have passed since last update.

CentOSにWordPressをインストール

Last updated at Posted at 2016-03-26

[目的]
WordPressをインストールする

WordPressのインストール 

WordPressのダウンロード

まず、WordPressを http://ja.wordpress.org/releases/ からwgetでダウンロードする。

wgetでWordPressをダウンロード
wget https://ja.wordpress.org/wordpress-4.4.2-ja.zip
--2016-03-20 14:47:57--  https://ja.wordpress.org/wordpress-4.4.2-ja.zip
ja.wordpress.org (ja.wordpress.org) をDNSに問いあわせています... 66.155.40.249, 66.155.40.250
ja.wordpress.org (ja.wordpress.org)|66.155.40.249|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 8226853 (7.8M) [application/zip]
`wordpress-4.4.2-ja.zip' に保存中

100%[===========================================================================================================>] 8,226,853   7.18MB/s 時間 1.1s   

2016-03-20 14:47:59 (7.18 MB/s) - `wordpress-4.4.2-ja.zip' へ保存完了 [8226853/8226853]

ダウンロードファイルの解凍

ダウンロードしたファイルを解凍し、Apacheが読み込めるようにする。

ファイルの解凍
unzip wordpress-4.4.2-ja.zip 
Archive:  wordpress-4.4.2-ja.zip
   creating: wordpress/
  inflating: wordpress/wp-trackback.php  
   creating: wordpress/wp-admin/
  inflating: wordpress/wp-admin/media-upload.php  
  inflating: wordpress/wp-admin/install-helper.php  
  inflating: wordpress/wp-admin/ms-users.php  
    【略】
  inflating: wordpress/license.txt   
  inflating: wordpress/wp-signup.php  
  inflating: wordpress/index.php     
  inflating: wordpress/wp-mail.php   
  inflating: wordpress/wp-config-sample.php  
  inflating: wordpress/wp-comments-post.php  

ファイル配置

ファイルをApacheで扱えるディレクトリに配置

ディレクトリ作成
sudo cp -r wordpress /var/www/

apacheが起動しているユーザーに設定。rootやapacheなど。
ps aux | grep apache で確認可能。
bash:パーミッション設定
sudo chown -R root:root /var/www/wordpress

Apacheの設定

編集前の設定ファイルを念のためバックアップ
sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org 
設定ファイル編集 
sudo vim /etc/httpd/conf/httpd.conf
ファイル修正箇所
修正
# DocumentRootをWordPressのディレクトリに変更する
DocumentRoot "/var/www/wordpress"

追加
# .htaccessによるディレクティブの上書きを許可する 
<Directory "/var/www/wordpress">
    AllowOverride All
</Directory>
Apacheテストページの撤去のため修正
sudo vim /etc/httpd/conf.d/welcome.conf
すべてコメントアウト
# 
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL.  To disable the
# Welcome page, comment out all the lines below. 
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
#<LocationMatch "^/+$">
#    Options -Indexes
#    ErrorDocument 403 /.noindex.html
#</LocationMatch>
#
#<Directory /usr/share/httpd/noindex>
#    AllowOverride None
#    Require all granted
#</Directory>
#
#Alias /.noindex.html /usr/share/httpd/noindex/index.html
#Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
#Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
#Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
#Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png
Apache再起動で設定反映
service httpd restart
 or
apachectl restart

MySQLのインストール

MySQL公式リポジトリファイルをインストール
sudo yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
読み込んだプラグイン:fastestmirror, remove-with-leaves, show-leaves
mysql-community-release-el7-5.noarch.rpm                                                              | 6.0 kB  00:00:00     
/var/tmp/yum-root-tsJeHs/mysql-community-release-el7-5.noarch.rpm を調べています: mysql-community-release-el7-5.noarch
/var/tmp/yum-root-tsJeHs/mysql-community-release-el7-5.noarch.rpm をインストール済みとして設定しています
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ mysql-community-release.noarch 0:el7-5 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

=============================================================================================================================
 Package                           アーキテクチャー バージョン         リポジトリー                                     容量
=============================================================================================================================
インストール中:
 mysql-community-release           noarch           el7-5              /mysql-community-release-el7-5.noarch           4.3 k

トランザクションの要約
=============================================================================================================================
インストール  1 パッケージ

合計容量: 4.3 k
インストール容量: 4.3 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : mysql-community-release-el7-5.noarch                                                         1/1 
  検証中                  : mysql-community-release-el7-5.noarch                                                         1/1 

インストール:
  mysql-community-release.noarch 0:el7-5                                                                                     

完了しました!
New leaves:
  mysql-community-release.noarch
MySQLインストール
sudo yum install mysql-server
読み込んだプラグイン:fastestmirror, remove-with-leaves, show-leaves
mysql-connectors-community                                                                            | 2.5 kB  00:00:00     
mysql-tools-community                                                                                 | 2.5 kB  00:00:00     
mysql56-community                                                                                     | 2.5 kB  00:00:00     
(1/3): mysql-connectors-community/x86_64/primary_db                                                   | 9.8 kB  00:00:00     
(2/3): mysql-tools-community/x86_64/primary_db                                                        |  25 kB  00:00:00     
(3/3): mysql56-community/x86_64/primary_db                                                            | 115 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ mysql-community-server.x86_64 0:5.6.29-2.el7 を インストール
--> 依存性の処理をしています: mysql-community-common(x86-64) = 5.6.29-2.el7 のパッケージ: mysql-community-server-5.6.29-2.el7.x86_64
--> 依存性の処理をしています: mysql-community-client(x86-64) = 5.6.29-2.el7 のパッケージ: mysql-community-server-5.6.29-2.el7.x86_64
--> 依存性の処理をしています: perl(DBI) のパッケージ: mysql-community-server-5.6.29-2.el7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ mysql-community-client.x86_64 0:5.6.29-2.el7 を インストール
--> 依存性の処理をしています: mysql-community-libs(x86-64) = 5.6.29-2.el7 のパッケージ: mysql-community-client-5.6.29-2.el7.x86_64
---> パッケージ mysql-community-common.x86_64 0:5.6.29-2.el7 を インストール
---> パッケージ perl-DBI.x86_64 0:1.627-4.el7 を インストール
--> 依存性の処理をしています: perl(RPC::PlServer) >= 0.2001 のパッケージ: perl-DBI-1.627-4.el7.x86_64
--> 依存性の処理をしています: perl(RPC::PlClient) >= 0.2000 のパッケージ: perl-DBI-1.627-4.el7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ mariadb-libs.x86_64 1:5.5.44-2.el7.centos を 不要
---> パッケージ mysql-community-libs.x86_64 0:5.6.29-2.el7 を 非推奨
---> パッケージ perl-PlRPC.noarch 0:0.2020-14.el7 を インストール
--> 依存性の処理をしています: perl(Net::Daemon) >= 0.13 のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> 依存性の処理をしています: perl(Net::Daemon::Test) のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> 依存性の処理をしています: perl(Net::Daemon::Log) のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> 依存性の処理をしています: perl(Compress::Zlib) のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> トランザクションの確認を実行しています。
---> パッケージ perl-IO-Compress.noarch 0:2.061-2.el7 を インストール
--> 依存性の処理をしています: perl(Compress::Raw::Zlib) >= 2.061 のパッケージ: perl-IO-Compress-2.061-2.el7.noarch
--> 依存性の処理をしています: perl(Compress::Raw::Bzip2) >= 2.061 のパッケージ: perl-IO-Compress-2.061-2.el7.noarch
---> パッケージ perl-Net-Daemon.noarch 0:0.48-5.el7 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 を インストール
---> パッケージ perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

=============================================================================================================================
 Package                              アーキテクチャー    バージョン                    リポジトリー                    容量
=============================================================================================================================
インストール中:
 mysql-community-libs                 x86_64              5.6.29-2.el7                  mysql56-community              2.0 M
     mariadb-libs.x86_64 1:5.5.44-2.el7.centos を入れ替えます
 mysql-community-server               x86_64              5.6.29-2.el7                  mysql56-community               58 M
依存性関連でのインストールをします:
 mysql-community-client               x86_64              5.6.29-2.el7                  mysql56-community               19 M
 mysql-community-common               x86_64              5.6.29-2.el7                  mysql56-community              256 k
 perl-Compress-Raw-Bzip2              x86_64              2.061-3.el7                   base                            32 k
 perl-Compress-Raw-Zlib               x86_64              1:2.061-4.el7                 base                            57 k
 perl-DBI                             x86_64              1.627-4.el7                   base                           802 k
 perl-IO-Compress                     noarch              2.061-2.el7                   base                           260 k
 perl-Net-Daemon                      noarch              0.48-5.el7                    base                            51 k
 perl-PlRPC                           noarch              0.2020-14.el7                 base                            36 k

トランザクションの要約
=============================================================================================================================
インストール  2 パッケージ (+8 個の依存関係のパッケージ)

総ダウンロード容量: 80 M
Is this ok [y/d/N]: y
Downloading packages:
警告: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.29-2.el7.x86_64.rpm: ヘッダー V3 DSA/SHA1 Signature、鍵 ID 5072e1f5: NOKEY
mysql-community-common-5.6.29-2.el7.x86_64.rpm の公開鍵がインストールされていません
(1/10): mysql-community-common-5.6.29-2.el7.x86_64.rpm                                                | 256 kB  00:00:00     
(2/10): mysql-community-libs-5.6.29-2.el7.x86_64.rpm                                                  | 2.0 MB  00:00:00     
(3/10): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                |  32 kB  00:00:00     
(4/10): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                 |  57 kB  00:00:00     
(5/10): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                         |  51 kB  00:00:00     
(6/10): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                       | 260 kB  00:00:00     
(7/10): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                           |  36 kB  00:00:00     
(8/10): perl-DBI-1.627-4.el7.x86_64.rpm                                                               | 802 kB  00:00:00     
(9/10): mysql-community-client-5.6.29-2.el7.x86_64.rpm                                                |  19 MB  00:00:01     
(10/10): mysql-community-server-5.6.29-2.el7.x86_64.rpm                                               |  58 MB  00:00:03     
-----------------------------------------------------------------------------------------------------------------------------
合計                                                                                          22 MB/s |  80 MB  00:00:03     
file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql から鍵を取得中です。
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (@/mysql-community-release-el7-5.noarch)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
上記の処理を行います。よろしいでしょうか? [y/N]y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : mysql-community-common-5.6.29-2.el7.x86_64                                                  1/11 
  インストール中          : mysql-community-libs-5.6.29-2.el7.x86_64                                                    2/11 
  インストール中          : mysql-community-client-5.6.29-2.el7.x86_64                                                  3/11 
  インストール中          : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                  4/11 
  インストール中          : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                 5/11 
  インストール中          : perl-IO-Compress-2.061-2.el7.noarch                                                         6/11 
  インストール中          : perl-Net-Daemon-0.48-5.el7.noarch                                                           7/11 
  インストール中          : perl-PlRPC-0.2020-14.el7.noarch                                                             8/11 
  インストール中          : perl-DBI-1.627-4.el7.x86_64                                                                 9/11 
  インストール中          : mysql-community-server-5.6.29-2.el7.x86_64                                                 10/11 
  削除中                  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                  11/11 
  検証中                  : mysql-community-common-5.6.29-2.el7.x86_64                                                  1/11 
  検証中                  : mysql-community-libs-5.6.29-2.el7.x86_64                                                    2/11 
  検証中                  : perl-Net-Daemon-0.48-5.el7.noarch                                                           3/11 
  検証中                  : mysql-community-client-5.6.29-2.el7.x86_64                                                  4/11 
  検証中                  : mysql-community-server-5.6.29-2.el7.x86_64                                                  5/11 
  検証中                  : perl-IO-Compress-2.061-2.el7.noarch                                                         6/11 
  検証中                  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                 7/11 
  検証中                  : perl-DBI-1.627-4.el7.x86_64                                                                 8/11 
  検証中                  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                  9/11 
  検証中                  : perl-PlRPC-0.2020-14.el7.noarch                                                            10/11 
  検証中                  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                  11/11 

インストール:
  mysql-community-libs.x86_64 0:5.6.29-2.el7                   mysql-community-server.x86_64 0:5.6.29-2.el7                  

依存性関連をインストールしました:
  mysql-community-client.x86_64 0:5.6.29-2.el7                  mysql-community-common.x86_64 0:5.6.29-2.el7                 
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7                  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7                  
  perl-DBI.x86_64 0:1.627-4.el7                                 perl-IO-Compress.noarch 0:2.061-2.el7                        
  perl-Net-Daemon.noarch 0:0.48-5.el7                           perl-PlRPC.noarch 0:0.2020-14.el7                            

置換:
  mariadb-libs.x86_64 1:5.5.44-2.el7.centos                                                                                  

完了しました!
New leaves:
  mysql-community-server.x86_64

mysqlデーモンの起動

service mysqld start

Wordpressに必要なPHP拡張をインストール

sudo yum install php-mysql php-mbstring
読み込んだプラグイン:fastestmirror, remove-with-leaves, show-leaves
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.kddilabs.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ php-mbstring.x86_64 0:5.4.16-36.el7_1 を インストール
---> パッケージ php-mysql.x86_64 0:5.4.16-36.el7_1 を インストール
--> 依存性の処理をしています: php-pdo(x86-64) = 5.4.16-36.el7_1 のパッケージ: php-mysql-5.4.16-36.el7_1.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ php-pdo.x86_64 0:5.4.16-36.el7_1 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

=============================================================================================================================
 Package                         アーキテクチャー          バージョン                          リポジトリー             容量
=============================================================================================================================
インストール中:
 php-mbstring                    x86_64                    5.4.16-36.el7_1                     base                    503 k
 php-mysql                       x86_64                    5.4.16-36.el7_1                     base                     99 k
依存性関連でのインストールをします:
 php-pdo                         x86_64                    5.4.16-36.el7_1                     base                     97 k

トランザクションの要約
=============================================================================================================================
インストール  2 パッケージ (+1 個の依存関係のパッケージ)

総ダウンロード容量: 700 k
インストール容量: 1.7 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): php-mysql-5.4.16-36.el7_1.x86_64.rpm                                                           |  99 kB  00:00:00     
(2/3): php-pdo-5.4.16-36.el7_1.x86_64.rpm                                                             |  97 kB  00:00:00     
(3/3): php-mbstring-5.4.16-36.el7_1.x86_64.rpm                                                        | 503 kB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------
合計                                                                                         2.4 MB/s | 700 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : php-pdo-5.4.16-36.el7_1.x86_64                                                               1/3 
  インストール中          : php-mysql-5.4.16-36.el7_1.x86_64                                                             2/3 
  インストール中          : php-mbstring-5.4.16-36.el7_1.x86_64                                                          3/3 
  検証中                  : php-mbstring-5.4.16-36.el7_1.x86_64                                                          1/3 
  検証中                  : php-mysql-5.4.16-36.el7_1.x86_64                                                             2/3 
  検証中                  : php-pdo-5.4.16-36.el7_1.x86_64                                                               3/3 

インストール:
  php-mbstring.x86_64 0:5.4.16-36.el7_1                          php-mysql.x86_64 0:5.4.16-36.el7_1                         

依存性関連をインストールしました:
  php-pdo.x86_64 0:5.4.16-36.el7_1                                                                                           

完了しました!
New leaves:
  php-mbstring.x86_64
  php-mysql.x86_64

Apache再起動

service httpd restart

MySQLの設定

起動確認

MySQLが起動しているか確認
mysqladmin -u root ping
aliveになっていることを確認
mysqld is alive

自動起動設定

自動起動ON
chkconfig mysqld on
自動起動設定確認
systemctl is-enabled mysqld
enabled

 ## rootパスワードの設定

MySQLにrootでログイン
mysql -u root
パスワードの変更 
mysql> update mysql.user set password=password('root用の任意パスワード') where user = 'root';
Query OK, 4 rows affected (0.05 sec)
Rows matched: 4  Changed: 4  Warnings: 0
変更の反映
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MySQL終了
mysql> exit;
Bye
設定したパスワードでMySQLにログインできるか確認
mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 
MySQL終了
mysql> exit;
Bye

WordPress用のデータベース・ユーザー作成

rootでMySQLにログイン
mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 
mysql> create database 【データベース名】;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on 【データベース名】.* to 【ユーザー名】@localhost identified by '【パスワード】';
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye

WordPressの初期設定

Wordpressを配置したパスをブラウザから確認する。
http://xxxxxxxxx/wp-admin/setup-config.php

データベースの設定ウィザードが表示されるので、先ほど作成したMySQLの情報を入力する。

項目 入力内容
データベース名 先ほど作成した【データベース名】
ユーザー名 先ほど作成した【ユーザー名】
パスワード 先ほど作成した【パスワード】
データベースのホスト名 localhost
テーブル接頭辞 wp_

「ファイル wp-config.php に書き込めませんでした。」となった場合は、画面に従い、ファイルを作成する。

画面に指定されている内容を記載する
sudo vim /var/www/wordpress/wp-config.php

※続けて、FTPサーバの設定 を実施する

29
39
1

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
29
39