LoginSignup
2
2

More than 5 years have passed since last update.

AWS(Amazon EC2)のWebサーバーの設定

Posted at

概要

AWS(Amazon EC2)のWebサーバーの設定方法です。
ターミナルからコマンドを打つことで書く設定をすることができます。

最初にec2-userからrootになりましょう。

$ sudo -i

言語ファイルの設定

言語を日本語に変更
```

vim /etc/sysconfig/i18n

vimなので、入力モードに変更して下記のように編集、コマンドモードに変更して保存します。

LANG=ja_JP.UTF-8
```

タイムゾーンの設定

日本に設定

# cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

確認(JSTと出て入れば変更完了)

$ date
Thu Jul 13 14:06:12 JST 2017

PHP

インストール

# yum install -y php

確認
```

php -v

言語ファイルを日本に変更

vim /etc/php.ini

開いたファイルを/date.timezoneで検索し、;を外して'Asia/Tokyo'に設定します。
※タイムゾーンはApacheの設定と合わせておきましょう。

```php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = 'Asia/Tokyo'

MySQL

インストール

# yum install -y mysql-server

自動起動を設定
```

chkconfig mysqld on


### パスワードを設定
起動

service mysqld start

動作確認

service mysqld status

mysqld (pid 3101) を実行中...
```

ログインパスワード設定

mysql> set password for root@localhost=password('パスワード');
Query OK, 0 rows affected (0.00 sec)

ログアウト

mysql> exit
Bye

初期設定

初期設定(mysql_secure_installation)
```

/usr/bin/mysql_secure_installation

対話形式で、ログインユーザーの設定などを設定

Change the root password? [Y/n] n
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
```

再起動
```

service mysqld restart



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