LoginSignup
2
2

More than 5 years have passed since last update.

思いつきでWordPress4.4-jaをCentOSに構築してみた

Last updated at Posted at 2016-01-08

wordpressの構築について思いつきで現時点での
最低限での導入方法をまとめてみた。

公開サーバを構築する際はセキュリティ等に配慮を行って下さい。この記事通りに構築しても不正アクセスに対する責任は負いかねます。

2016/1/8時点でyum経由での最新版を導入すると以下の通り。

CentOS
uname -a
Linux hogeserver 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 21:19:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

httpd -V
Server version: Apache/2.2.27 (Unix)

php --version
PHP 5.6.17 (cli) (built: Jan  6 2016 19:05:40)

mysql --version
mysql  Ver 14.14 Distrib 5.6.28, for Linux (x86_64) using  EditLine wrapper

以下導入手順を記載。

selinuxの無効化

/etc/selinux/config
SELINUX=disabled

epelのレポジトリ登録
rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

remiのレポジトリ登録
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

CentALTのレポジトリ登録
rpm -ivh http://mirror.sysadminguide.net/centalt/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm

「centalt.repo」の入手先変更(デフォルトのサーバに繋いでも動かないため)

/etc/yum.repos.d/centalt.repo
[CentALT]
name=CentALT Packages for Enterprise Linux 6 - $basearch
#初期のレポジトリはコメントアウト
#baseurl=http://centos.alt.ru/repository/centos/6/$basearch/
baseurl=http://mirror.sysadminguide.net/centalt/repository/centos/6/$basearch/

Apache導入
yum install httpd httpd-devel --enablerepo=CentALT

MySQL導入
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install mysql-community-server

PHP周り導入
yum install php php-mysql php-mbstring gd php-gd --enablerepo=remi-php56 --disablerepo=CentALT

mysqld起動
service mysqld start

MySQLのセキュアインストール
mysql_secure_installation
→rootのパスワード以外全てYを選択

mysqld.logディレクトリ作成

mkdir /var/log/mysqld/
mv mysqld.log ./mysqld
chown -R mysql:root /var/log/mysqld/

「my.cnf」修正

/etc/my.cnf
[mysqld]
character-set-server = utf8

[mysqld_safe]
log-error=/var/log/mysqld/mysqld.log

mysqld起動
service mysqld start

DB,ユーザ,パスワード登録
mysql -u root -p

mysql> CREATE DATABASE wordpress;
mysql> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'hogehogefugafuga';
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';

mysql> FLUSH PRIVILEGES;

mysql> quit

「php.ini」編集

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

「httpd.conf」編集

/etc/httpd/conf/httpd.conf
ServerName {hogeのIP}:80
ServerSignature Off
ServerTokens Prod
    Options -Indexes FollowSymLinks
<IfModule prefork.c>
StartServers            8
MinSpareServers         5
MaxSpareServers        20
ServerLimit           256
MaxClients            256
MaxRequestsPerChild  4000
MaxMemFree           4096
</IfModule>

ログのローテート

/etc/logrotate.conf
daily
rotate 30
compress
/etc/logrotate.d/httpd
/var/log/httpd/*log {
    daily
    rotate 30
    compress
    missingok
    notifempty
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}
/etc/logrotate.d/mysql
/var/log/mysqld/mysqld.log{
        # create 600 mysql mysql
        notifempty
        daily
        rotate 30
        missingok
        compress
        postrotate
        # just if mysqld is really running
        if test -x /usr/bin/mysqladmin && \
           /usr/bin/mysqladmin ping &>/dev/null
        then
           /usr/bin/mysqladmin flush-logs
        fi
    endscript
}

自動起動設定
chkconfig mysqld on
chkconfig httpd on

wordpressのコンテンツ展開

cd /var/www/html`
wget https://ja.wordpress.org/wordpress-4.4-ja.tar.gz
tar -zxvf ./wordpress-4.4-ja.tar.gz
mv ./wordpress ./wp
chown -R root:root ./wp

サイトアクセス
http://{hogeのIP}/wp/

後は良しなに。

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