LoginSignup
2
2

More than 5 years have passed since last update.

CentOSにWordpressをインストール

Last updated at Posted at 2016-09-10

環境

CentOS7
WordPress4.6
PHP5.6
MySQL5.6

CentOSの初期設定

FireWallの設定を解除

$ sudo systemctl stop firewalld
$ sudo systemctl disable firewalld.service
# systemctl list-unit-files -t service
firewalld.service                           disabled

epelレポジトリを追加

# yum install epel-release

epelレポジトリを明示して使用するために無効化する。

# vi /etc/yum.repos.d/epel.repo 
[epel]
(中略)
enabled=0

remiレポジトリを追加

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Apacheのインストール

# yum intall httpd
# systemctl start httpd
# systemctl enable httpd.service

phpのインストール

CentOS7の標準レポジトリではphp5.4がインストールされる。
今回はphp5.6を使用するため、別レポジトリを使用する。

# yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd

php.iniを編集

/etc/php.ini
date.timezone = "Asia/Tokyo"

mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = UTF-8
mbstring.http_output = pass
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_character = none

MySQLのインストール

mariadbの削除

centOS7には標準でmariadbがインストールされている。
競合を避けるために予めアンインストールする。

# yum remove mariadb-libs

MySQLリポジトリの追加

参考ページによるとCentOS7から標準リポジトリでMySQLが提供されないため、MySQLリポジトリをシステムに追加する必要がある。

 RHEL系の Linux は、パッケージ管理ツール yum を利用して様々なソフトウェアをインストールすることができますが、CentOS 7 からは標準リポジトリで MySQL が提供されなくなり、代わりに MySQL と互換性のある MariaDB が提供されるようになりました。 MySQL は、MySQL 公式の yum リポジトリを利用することでインストールできます。

# yum localinstall http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm

MySQLのリポジトリの状態確認

# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community         有効:    21
mysql-connectors-community-source MySQL Connectors Community - Sourc 無効
mysql-tools-community/x86_64      MySQL Tools Community              有効:    38
mysql-tools-community-source      MySQL Tools Community - Source     無効
mysql55-community/x86_64          MySQL 5.5 Community Server         無効
mysql55-community-source          MySQL 5.5 Community Server - Sourc 無効
mysql56-community/x86_64          MySQL 5.6 Community Server         無効
mysql56-community-source          MySQL 5.6 Community Server - Sourc 無効
mysql57-community/x86_64          MySQL 5.7 Community Server         有効:   130
mysql57-community-source          MySQL 5.7 Community Server - Sourc 無効

MySQL5.6のリポジトリが無効(disabled)になっているので、この状態を反転させる。

# yum -y install yum-utils
# yum-config-manager --disable mysql57-community
# yum-config-manager --enable mysql56-community
# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community         有効:    21
mysql-connectors-community-source MySQL Connectors Community - Sourc 無効
mysql-tools-community/x86_64      MySQL Tools Community              有効:    38
mysql-tools-community-source      MySQL Tools Community - Source     無効
mysql55-community/x86_64          MySQL 5.5 Community Server         無効
mysql55-community-source          MySQL 5.5 Community Server - Sourc 無効
mysql56-community/x86_64          MySQL 5.6 Community Server         有効:   299
mysql56-community-source          MySQL 5.6 Community Server - Sourc 無効
mysql57-community/x86_64          MySQL 5.7 Community Server         無効
mysql57-community-source          MySQL 5.7 Community Server - Sourc 無効

MySQLのインストール

# yum install mysql-community-server
# mysqld --version
mysqld  Ver 5.6.33 for Linux on x86_64 (MySQL Community Server (GPL))

MySQL初期設定

起動

# systemctl start mysqld

自動起動設定(mysqlはchkconfigコマンドで設定を行う)

# chkconfig --level 35 mysqld on

rootパスワード設定

# mysql -u root
> set password for root@localhost=password('hoge');

mysql_secure_installationの実行

# /usr/bin/mysql_secure_installation 



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

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, 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): 
OK, successfully used password, moving on...

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

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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, MySQL 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...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - 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!




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

Thanks for using MySQL!


Cleaning up...

phpMyAdminのインストール

インストールするとエラーが出る

# yum install --enablerepo=remi,remi-php56 phpMyAdmin
エラー: パッケージ: php-tidy-5.6.25-1.el7.remi.x86_64 (remi-php56)
             要求: libtidy-0.99.so.0()(64bit)
 問題を回避するために --skip-broken を用いることができます。
 これらを試行できます: rpm -Va --nofiles --nodigest

libtidy-0.99.so.0が無いと言われているので下記の方法でインストールする。

# wget ftp5.gwdg.de/pub/opensuse/repositories/home:/csbuild:/centosextra/RedHat_RHEL-6/x86_64/libtidy-20081207-1.1.x86_64.rpm
# rpm -Uvh libtidy-20081207-1.1.x86_64.rpm 

再度phpMyAdminのインストールを実行。成功した。

# yum install --enablerepo=remi,remi-php56 phpMyAdmin

phpMyAdminの設定をする。

/etc/phpMyAdmin/config.inc.php
$cfg['DefaultLang'] = 'ja-utf-8';
# chown -R root:apache /usr/share/phpMyAdmin/

アクセス可能にするためApacheの設定を行う。

/etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>
     Require ip 192.168.1.0/24
# systemctl reload httpd

WordPressのインストール

WordPress パッケージをダウンロードして、解凍。

$ unzip wordpress-4.6.1-ja.zip 

phpmyadminにログインして下記を実行

  • 専用のDBを作成
  • 専用のユーザーを作成

wp-config.phpを編集する

$ sudo mv wordpress /var/www/html/
$ cp -pr wp-config-sample.php wp-config.php
/var/www/html/wordpress/wp-config.php
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

インストールスクリプトを実行するために下記URLにアクセス

http://サーバIP/wordpress/wp-admin/install.php

参考

CentOS6/CentOS7にPHP5.6/PHP7をyumでインストール
MySQL 5.6 を CentOS 7 に yum インストールする手順
【初心者級】libtidy-0.99.so.0がない! centos7のphp7でphpMyadmin入れようとしたら(略

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