Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

CentOS7 WordPress インストール

More than 1 year has passed since last update.

CentOS7にWordPress インストール

環境

  • OS: CentOS Linux release 7.6.1810 (Core)
  • ImageId: ami-045f38c93733dd48d
  • InstanceType: t2.micro
  • SELinux: disabled
  • install: MariaDB10.3, httpd2.4, php7.3, wget1.1, WordPress5.2.1

手順

OS確認
$ sudo more /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
ロケール変更
$ localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us
$ localectl list-locales | grep -i ja_JP.utf8
ja_JP.utf8
$ sudo localectl set-locale LANG=ja_JP.utf8
$ sudo localectl set-keymap jp106 
$ localectl
   System Locale: LANG=ja_JP.utf8
       VC Keymap: jp106
      X11 Layout: jp
       X11 Model: jp106
     X11 Options: terminate:ctrl_alt_bksp
Timezone変更
$ timedatectl status
      Local time: Tue 2018-06-26 05:37:04 UTC
  Universal time: Tue 2018-06-26 05:37:04 UTC
        RTC time: Tue 2018-06-26 05:37:03
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
$ sudo timedatectl set-timezone Asia/Tokyo
$ timedatectl status
     Local time: Tue 2018-06-26 14:38:43 JST
  Universal time: Tue 2018-06-26 05:38:43 UTC
        RTC time: Tue 2018-06-26 05:38:42
       Time zone: Asia/Tokyo (JST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
ホスト名変更
$ uname -n
ip-172-16-0-4.ap-northeast-1.compute.internal
$ sudo hostnamectl set-hostname wordpress
$ uname -n
wordpress
SELinux無効化
$ sudo getenforce
Enforcing
$ sudo sed -i.bak "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
$ diff /etc/selinux/config*
7c7
< SELINUX=disabled
---
> SELINUX=enforcing

$ sudo shutdown -r now
モジュール最新化
$ sudo yum update -y
$ sudo shutdown -r now
リポジトリ登録
$ sudo yum install epel-release -y
$ sudo yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm -y
$ sudo sed -i.bak "s/enabled=0/enabled=1/g" /etc/yum.repos.d/remi-php73.repo
$ diff /etc/yum.repos.d/remi-php73.repo*
9c9
< enabled=1
---
> enabled=0
16c16
< enabled=1
---
> enabled=0
25c25
< enabled=1
---
> enabled=0
32c32
< enabled=1
---
> enabled=0
$ curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
$ yum repolist enabled
$ ls -l /etc/yum.repos.d/
apache,php,mariadbインストール
$ sudo yum install httpd mariadb mariadb-server php php-mysql wget -y
$ rpm -qa | egrep php\|httpd\|MariaDB
php-json-7.3.6-3.el7.remi.x86_64
MariaDB-compat-10.3.15-1.el7.centos.x86_64
php-cli-7.3.6-3.el7.remi.x86_64
php-pdo-7.3.6-3.el7.remi.x86_64
php-7.3.6-3.el7.remi.x86_64
php-mysqlnd-7.3.6-3.el7.remi.x86_64
php-common-7.3.6-3.el7.remi.x86_64
MariaDB-common-10.3.15-1.el7.centos.x86_64
httpd-tools-2.4.6-89.el7.centos.x86_64
MariaDB-client-10.3.15-1.el7.centos.x86_64
httpd-2.4.6-89.el7.centos.x86_64
MariaDB-server-10.3.15-1.el7.centos.x86_64
mariadb設定
$ sudo systemctl start mariadb.service
$ systemctl status mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since 水 2018-08-29 01:33:12 JST; 6s ago
  Process: 3617 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 3538 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 3616 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─3616 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─3778 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql...

 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: MySQL manual for mo...
 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: Please report any p...
 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: The latest informat...
 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: You can find additi...
 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: http://dev.mysql.com
 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: Consider joining Ma...
 8月 29 01:33:10 wordpress mariadb-prepare-db-dir[3538]: https://mariadb.org...
 8月 29 01:33:10 wordpress mysqld_safe[3616]: 180829 01:33:10 mysqld_safe L....
 8月 29 01:33:10 wordpress mysqld_safe[3616]: 180829 01:33:10 mysqld_safe S...l
 8月 29 01:33:12 wordpress systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
$ sudo systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <Enter押下>
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: <MaridDB用rootPassword入力>
Re-enter new password: <MaridDB用rootPassword再入力>
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

$ mysql -u root -p
Enter password: <MaridDB用rootPassword入力>
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.60-MariaDB MariaDB Server

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

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

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

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

MariaDB [(none)]>  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wordpress          |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> quit

apache設定
$ cd /etc/httpd/conf/
$ sudo cp -p httpd.conf httpd.conf.bak
$ sudo vi httpd.conf
$ diff http*
119c119
< DocumentRoot "/var/www/wordpress"
---
> DocumentRoot "/var/www/html"
125c125
<     AllowOverride All
---
>     AllowOverride None

$ sudo mkdir /var/www/wordpress
$ sudo systemctl start httpd
$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since 水 2018-08-29 01:40:10 JST; 6s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 3915 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─3915 /usr/sbin/httpd -DFOREGROUND
           ├─3916 /usr/sbin/httpd -DFOREGROUND
           ├─3917 /usr/sbin/httpd -DFOREGROUND
           ├─3918 /usr/sbin/httpd -DFOREGROUND
           ├─3919 /usr/sbin/httpd -DFOREGROUND
           └─3920 /usr/sbin/httpd -DFOREGROUND

 8月 29 01:40:10 wordpress systemd[1]: Starting The Apache HTTP Server...
 8月 29 01:40:10 wordpress httpd[3915]: AH00558: httpd: Could not reliably ...e
 8月 29 01:40:10 wordpress systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
$ sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
$
$ cd /tmp
$ wget http://wordpress.org/latest.tar.gz
$ tar xvf latest.tar.gz​
$ sudo cp -r wordpress /var/www/
$ sudo chown -R apache.apache /var/www/wordpress

WordPress設定

  • ブラウザでアクセスし、以下の通りセットアップ

image.png
image.png
image.png
image.png
image.png
image.png
image.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away