
typographyimages / Pixabay
WordPress
現時点におけるWordPressの最新板は4.7.3である。(2017年4月16日時点)
推奨環境は
- PHP バージョン 7 以上
- MySQL バージョン 5.6 以上 または MariaDB バージョン 10.0 以上
となっている。
CentOS6の標準環境は
- PHP 5.3
- MySQL 5.1
である。
下記サイトよりセキュリティ的な問題は無さそうだが、新しい構文が使えないとプラグイン等で不具合がありそうなのでさくらVPS(CentOS6)にPHP7、MySQL5.6の環境を構築する。
PHP7のインストール
下記サイトを参考にPHP7をインストールする。
古いパッケージの削除
yum remove php-*
Remiリポジトリのインストール
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
PHP7.0のインストール
yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd php-mysql
日本語利用(mbstring)の設定
下記サイトを参考に設定する。
PHPの設定ファイルを開く。
vi /etc/php.ini
変更箇所は太い赤字の部分。
[mbstring]
; language for internal character representation.
; This affects mb_send_mail() and mbstring.detect_order.
; http://php.net/mbstring.language
mbstring.language = Japanese
; Use of this INI entry is deprecated, use global internal_encoding instead.
; internal/script encoding.
; Some encoding cannot work as internal encoding. (e.g. SJIS, BIG5, ISO-2022-*)
; If empty, default_charset or internal_encoding or iconv.internal_encoding is used.
; The precedence is: default_charset < internal_encoding < iconv.internal_encoding
mbstring.internal_encoding = UTF-8
; Use of this INI entry is deprecated, use global input_encoding instead.
; http input encoding.
; mbstring.encoding_traslation = On is needed to use this setting.
; If empty, default_charset or input_encoding or mbstring.input is used.
; The precedence is: default_charset < intput_encoding < mbsting.http_input
; http://php.net/mbstring.http-input
mbstring.http_input = pass
; Use of this INI entry is deprecated, use global output_encoding instead.
; http output encoding.
; mb_output_handler must be registered as output buffer to function.
; If empty, default_charset or output_encoding or mbstring.http_output is used.
; The precedence is: default_charset < output_encoding < mbstring.http_output
; To use an output encoding conversion, mbstring's output handler must be set
; otherwise output encoding conversion cannot be performed.
; http://php.net/mbstring.http-output
mbstring.http_output = pass
; enable automatic encoding translation according to
; mbstring.internal_encoding setting. Input chars are
; converted to internal encoding by setting this to On.
; Note: Do _not_ use automatic encoding translation for
; portable libs/applications.
; http://php.net/mbstring.encoding-translation
mbstring.encoding_translation = Off
; automatic encoding detection order.
; "auto" detect order is changed according to mbstring.language
; http://php.net/mbstring.detect-order
mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII
; substitute_character used when character cannot be converted
; one from another
; http://php.net/mbstring.substitute-character
mbstring.substitute_character = none
; overload(replace) single byte functions by mbstring functions.
; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
; etc. Possible values are 0,1,2,4 or combination of them.
; For example, 7 for overload everything.
; 0: No overload
; 1: Overload mail() function
; 2: Overload str*() functions
; 4: Overload ereg*() functions
; http://php.net/mbstring.func-overload
mbstring.func_overload = 0
; enable strict encoding detection.
; Default: Off
mbstring.strict_detection = Off
; This directive specifies the regex pattern of content types for which mb_output_handler()
; is activated.
; Default: mbstring.http_output_conv_mimetype=^(text/|application/xhtml\+xml)
;mbstring.http_output_conv_mimetype=
Apacheの再起動で設定反映
service httpd restart
MySQL5.6のインストール
下記サイトを参考にMySQL5.6をインストールする。
古いパッケージの削除
yum remove mysql*
MySQLコミュニティリポジトリのインストール
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
MySQL5.6のインストール
yum install mysql mysql-devel mysql-server mysql-utilities
MySQLの起動
service mysqld start
MySQLの自動起動設定
chkconfig mysqld on
スクリプトで初期設定
/usr/bin/mysql_secure_installation
指示に沿って回答していけばOK。
MySQLの日本語対応設定
MySQLの設定ファイルを開く。
/usr/bin/mysql_secure_installation
変更箇所は太い赤字の部分
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
default-storage-engine=InnoDB
innodb_file_per_table
character-set-server = utf8
collation-server = utf8_general_ci
[mysql]
default-character-set=utf8
[client]
default-character-set = utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
推奨環境の構築完了
あとはWordPressをApacheの公開ディレクトリに設置して、MySQLにWordPressのデータベースとユーザを作成するだけ。