toto_1212

技術のログをツラツラ書きます。自分用ですが参考にしていただけたら嬉しいです。間違ってたらドンドン突っ込んでください。

【AWS】起動したEC2にWordpressをインストール

定番ですね。


1.SSHでEC2上のサーバへアクセスする。


2.ec2-userからrootになる。
# sudo su -
※rootになったら、passwdでパスワードを変更した方がよい


3.MySQLPerlモジュールとMySQL本体のパッケージをインストールする。
# yum install perl-DBI
# yum install mysql
# yum install mysql-server
# yum install mysql-devel

※専用リポジトリがあるためすんげー速い

 

4.MySQLを起動する。
# /etc/init.d/mysqld start

 

5.rootでMySQLへログインする。
# mysql -u root

 

6.rootのパスワードを変更
# update user set password=password ('mysqlpassword') where user='root';

※mysqlpasswordに任意のパスワードを入力

 

7.一旦、MySQLをログアウトする。
# quit

 

8.MySQLの設定ファイルに文字エンコーディングをUTF-8にするための追記。
# vi /etc/my.cnf

以下追記
[mysqld]
default-character-set=utf8

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqldump]
default-character-set=utf8

 

9.WordPress用のデータベースを作成する。
MySQLへrootでログイン
# mysql -u root -p
※-pはパスワードを設定した場合

'ec2press'というデータベースを作成するなら場合、
mysql> create database ec2press;

 

10.Apacheをインストールする。
# yum -y install httpd

 

11.Apacheを起動する。
# /etc/rc.d/init.d/httpd start

※起動確認
ブラウザからhttp://[EC2インスタンスのPublic DNS] を開いて、
Apacheの画面が出ればOKです

 

12.phpと関連モジュールをインストールする
# yum -y install php

# yum -y install php-devel php-gd php-mbstring php-mysql php-pdo php-pear php-xml php-imap

※動作確認
Apacheのルートディレクトリ(/var/www/html/)に移動し、以下コードをindex.phpで作成し、
ブラウザからhttp://[EC2インスタンスのPublic DNS]/index.phpでアクセスしエラー無く日付が
出れば問題ありません。

vi /var/www/html/index.php

<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
<?php
   print Date("Y/m/d");
?>
</div>
</body>
</html>

確認後はrm index.phpでファイル消去を忘れずに。

 

13.phpの設定をする。
日本語で動かすために必要な基本的な設定を、/etc/php.iniファイルに追記

# vi /etc/php.ini
;default_charset = "iso-8859-1"

default_charset = "UTF-8"

;date.timezone =

date.timezone = "Asia/Tokyo"

;mbstring.language = Japanese

mbstring.language = Japanese

;mbstring.internal_encoding = EUC-JP

mbstring.internal_encoding = UTF-8

;mbstring.http_input = auto

mbstring.http_input = pass

;mbstring.http_output = SJIS

mbstring.http_output = pass

;mbstring.encoding_translation = Off

mbstring.encoding_translation = Off

;mbstring.detect_order = auto

mbstring.detect_order = auto

;mbstring.substitute_character = none;

mbstring.substitute_character = none;

;mbstring.func_overload = 0

mbstring.func_overload = 0

;mbstring.strict_detection = Off

mbstring.strict_detection = Off

;mbstring.http_output_conv_mimetype=

mbstring.http_output_conv_mimetype=

 

14.WordPressのインストール。
ダウンロードファイルの仮置きに移動
# cd /tmp

# wget http://ja.wordpress.org/latest-ja.tar.gz

 

15.ダウンロードファイルを展開する。
Apacheルートディレクトリ/var/www/html/以下に展開
# tar zxvf latest-ja.tar.gz -C /var/www/html/

 

16.Wordpressの設定をする。
wp-config.phpをコピー
# cd /var/www/html/wordpress
# cp wp-config-sample.php wp-config.php

# vi wp-config.php

※wp-config.phpの、次の行を設定したものにする。

define('DB_NAME', 'ec2press');
define('DB_USER', 'root');
define('DB_PASSWORD', 'mysqlpassword');

 

17.Apachemysqlを再起動する。
# service httpd restart
# service mysqld restart

 

18.作成したサイトの初期設定画面にアクセスする。
ブラウザにて、
http://[EC2インスタンスのPublic DNS]/wordpress/wp-admin/install.php
へアクセス

 

ここからはお好みの設定でサイトを作成していただければいいかなと。。。