お名前.com VPS (KVM) にて WordPress をはじめるまで(2)
第2回は、AMP(Apache、MySQL、PHP)のインストールについてです。
2012年5月から お名前.com VPS(KVM) の利用を始めています。
標準 OS にて、設定などを備忘録として残しておきたいと思います。前回は、思った以上に駆け足の記録になってしまいました。おそらく今回以降もそのようになってしまいそうです。
リポジトリの追加
yum を利用してインストールを進めますが、標準 OS インストール直後の yum では、インストールするパッケージのバージョンがだいぶ古かったりします。ですので、まず、いくつかリポジトリを追加インストールします。
EPEL リポジトリです。
[shell]
$ sudo rpm -ihv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
[/shell]
/etc/yum.repos.d/epel.repo において enabled=1 のところは enabled=0 と書き直しました。実行する場合は、次のようなオプションを付けます。
[shell]
$ sudo yum update –enablerepo=epel
[/shell]
CentALT リポジトリです。
/etc/yum.repos.d/centos.alt.ru.repo を以下の内容で作成します。
[shell]
[CentALT]
name=CentALT Packages for Enterprise Linux 6 – $basearch
baseurl=http://centos.alt.ru/repository/centos/6/$basearch/
enabled=0
gpgcheck=0
[/shell]
実行する場合は、次のようなオプションを付けます。
[shell]
$ sudo yum update –enablerepo=CentALT
[/shell]
remi リポジトリです。
[shell]
$ sudo rpm -ihv http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
[/shell]
/etc/yum.repos.d/remi.repo において enabled=1 となっているときは enabled=0 と書き直します。実行する場合は、次のようなオプションを付けます。
[shell]
$ sudo yum update –enablerepo=remi
[/shell]
AMP パッケージのインストール
[shell]
$ sudo yum install httpd –enablerepo=epel –enablerepo=CentALT –enablerepo=remi
[/shell]
このようにパッケージをインストールしていきます。
[shell]
$ sudo yum install mysql-server –enablerepo=epel,CentALT,remi
$ sudo yum install php php-gd php-mbstring php-mcrypt php-mysql php-pear –enablerepo=epel,CentALT,remi
[/shell]
このようなインストールのまとめかたもできるようです。
Apache の起動
[shell]
$ sudo service httpd start
[/shell]
Apache の設定は、/etc/httpd/conf/httpd.conf を中心に編集します。この内容については、「お名前.com VPS (KVM) にて WordPress をはじめるまで(6)」でバーチャルホストの設定などとあわせて残したいと思います。
自動起動を設定します。
[shell]
$ sudo chkconfig httpd on
[/shell]
MySQL の起動
[shell]
$ sudo service mysqld start
[/shell]
初期設定を対話形式で行います。
[shell]
$ sudo mysql_secure_installation
[/shell]
質問の部分を拾いだして、入力例を書き込みました。
[shell]
~ 省略 ~
Enter current password for root (enter for none): (入力しない)
~ 省略 ~
Set root password? [Y/n] y
New password:(任意のパスワード)
Re-enter new password:(同上)
~ 省略 ~
Remove anonymous users? [Y/n] y
~ 省略 ~
Disallow root login remotely? [Y/n] y
~ 省略 ~
Remove test database and access to it? [Y/n] y
~ 省略 ~
Reload privilege tables now? [Y/n] y
~ 省略 ~
[/shell]
自動起動を設定します。
[shell]
$ sudo chkconfig mysqld on
[/shell]
データベースの作成などについては、「お名前.com VPS (KVM) にて WordPress をはじめるまで(7)」の WordPress のインストールなどとあわせて残したいと思います。
補足
php.ini の設定
php 環境の日本語対応など、php.ini の設定について簡単に書き出します。
[php]
[Date]
date.timezone = Asia/Tokyo
[mbstring]
mbstring.language = Japanese
[/php]
実行するプログラムによっては、さらに設定が必要になる場合があります。実行結果やエラーログなどを確認しながら見直していきます。
CentALT リポジトリについて補足
http://centos.alt.ru/repository/centos/readme.txt が公式なドキュメントのようです。
また、次のような方法でも設定が可能です。
[shell]
$ sudo rpm -ihv http://centos.alt.ru/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
[/shell]