3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rhel7.4にWordpressを導入する

Last updated at Posted at 2018-03-03

1.はじめに

どうもこんにちは、こむぎです。今回は構築したWebサーバにWordpressを導入していこうと思います。
Wordpressを入れれば、誰でも簡単にホームページやブログを自分好みに作ることができます。

2.この記事のゴール

Apacheを導入したRhel7.4に、wordpressを導入し、wordpressの画面を表示させるところまで。

3.環境

Server:AmazonEC2
OS:Red Hat Enterprise Linux Server release 7.4(Maipo)

4.主な導入パッケージ

PHP
PHP 5.4.16
Mariadb
10.1.31-1.el7
wordpress
wordpress-4.8-1

5.手順

5-1.root権限になる

以降のコマンド入力はroot権限で行う。

$sudo su 

5-2.PHPの導入

5-2-1.php php-mysqlのインストール

$yum install -y php php-mysql

5-2-2.PHPのバージョン確認

$php -v

5-2-3.PHP初期設定(タイムゾーンの変更)

$cp /etc/php.ini /etc/php.ini.org
$vi /etc/php.ini
php.ini
date.timezone= 
→date.timezone= "Asia/Tokyo"

5-3.MariaDB 導入

5-3-1.MariaDBのリポジトリを追加

$vi /etc/yum.repos.d/mariaDB.repo
mariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

5-3-2.MariaDB-server MariaDB-clientのインストール

$yum install MariaDB-server MariaDB-client

5-3-3.MariaDBの起動・有効化

$systemctl start mariadb
$systemctl enable mariadb

5-3-4.mariadbパスワード変更

$mysql -u root
mysql> update mysql.user set password=password('Password') where user = 'root';
mysql> flush privileges;
mysql> exit;

5-3-5.設定したパスワードでログインできるか確認

$mysql -u root -p

5-3-6.database(wp)の作成

mysql> create database wp;
mysql> show databases;

5-4.wgetインストール(入っていなければ)

$yum install wget

5-5.Wordpressの導入

5-5-1.wordpressをhttp://ja.wordpress.org/からwgetして解凍する

$wget http://ja.wordpress.org/wordpress-4.8-1-ja.tar.gz`
$tar -zxvf wordpress-4.8.1-ja.tar.gz -C /var/www/`

5-5-2. /var/www配下のディレクトリの所有者・グループをApacheに変更

$cd /var/www
$chown -R apache:apache *

5-5-3.httpd.confのバックアップを取ったうえでコンフィグ編集

$cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
$vi /etc/httpd/conf/httpd.conf
httpf.conf
DocumentRoot "/var/www/html"DocumentRoot "/var/www/wordpress"


><Directory "/var/www/html">
 AllowOverride All
</Directory>
↓
<Directory "/var/www/wordpress">
 AllowOverride All
</Directory>

5-5-4.httpdの再起動

$systemctl stop httpd
$systemctl start httpd

5-6.Wordpressにアクセス

http://XXX.XXX.XXX/
(http.confでDocumentrootの変更により、上記アクセスで自動的に/wordpressにアクセスするようになっている)

6.まとめ

今回はWordpressの画面を表示させるところまでの手順でした。次回は、Databaseについて触れていければと思います。
Wordpress上でDBのデータを表示させる方法や、wordpress上からDBにデータを追加する方法に触れていきたいです。

お疲れさまでした!

3
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?