Laravel HomesteadをJST&localeをjaにしてみた

LaravelのHomesteadがUTCだったのでJST&日本語にしてみたメモ。

# 環境
vagrant上のhomestead 
homestead=Ubuntu 14.04.4 LTS (GNU/Linux 3.19.0-25-generic x86_64)

※ubuntuとCentosでちょっと違ったよ、ってだけナリ

# JSTに変更

以下`$vagrant ssh`後

もともとの時間は

```
$ date 
Wed Jun  1 01:47:15 UTC 2016
```

UTC.
JSTを取得する必要があったので

```
$ sudo su
# cp -p /etc/localtime /etc/localtime.bak
# cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
```

かくにん

```
# date
Wed Jun  1 11:03:08 JST 2016
```

JSTになりましたよ！

# locale変更

```
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
```

localeが日本じゃないからphpで時刻とってもJSTが取れない？
そのまま

```
$localectl list-locales
```

してもjaが出てこないので、パッケージインストール

```
$ sudo su
#  apt-get install language-pack-ja
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  language-pack-ja-base
The following NEW packages will be installed:
  language-pack-ja language-pack-ja-base
0 upgraded, 2 newly installed, 0 to remove and 74 not upgraded.
Need to get 1,942 kB of archives.
After this operation, 8,949 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
```

"y"入力すして

```
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main language-pack-ja-base all 1:14.04+20150804 [1,940 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main language-pack-ja all 1:14.04+20150804 [1,814 B]
Fetched 1,942 kB in 4s (471 kB/s)       
Selecting previously unselected package language-pack-ja-base.
(Reading database ... 73798 files and directories currently installed.)
Preparing to unpack .../language-pack-ja-base_1%3a14.04+20150804_all.deb ...
Unpacking language-pack-ja-base (1:14.04+20150804) ...
Selecting previously unselected package language-pack-ja.
Preparing to unpack .../language-pack-ja_1%3a14.04+20150804_all.deb ...
Unpacking language-pack-ja (1:14.04+20150804) ...
Setting up language-pack-ja (1:14.04+20150804) ...
Setting up language-pack-ja-base (1:14.04+20150804) ...
Generating locales...
  ja_JP.UTF-8... done
Generation complete.
```

でろでろ。終わり。

```
# localectl list-locales
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
ja_JP.utf8
```

jaが追加になった。


```
# export LANG=ja_JP.UTF-8
# update-locale LANG=ja_JP.UTF-8
```

かくにん

```
# locale
LANG=ja_JP.UTF-8
LANGUAGE=en_US:
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
```

うーん・・・LANGUAGE=en_US:がおかしい。

```
# update-locale LANG=ja_JP.UTF-8
```

かくにん

```
# locale
LANG=ja_JP.UTF-8
LANGUAGE=ja_JP.UTF-8
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=ja_JP.UTF-8
# date
2016年  6月  1日 水曜日 11:29:52 JST
```

日本語になりました。


# NTPの設定
追記）時刻が数分ずれているのでNTPの設定修正

vagrant上

```file:/etc/default/ntpdate
NTPSERVERS="ntp.ubuntu.com"
↓
NTPSERVERS="ntp.ring.gr.jp"
```

その後vagrant reload。

---
# 参考）
http://koudaiii.hatenablog.com/entry/2013/12/24/163740
http://www.dreamedge.net/archives/111
http://ochaochaocha3.hateblo.jp/entry/2014/07/26/changing-to-japanese-locale-completely-on-ubuntu-server-14.04
http://qiita.com/kei2100/items/a912ec733f646f8c3938
http://zorinos.seesaa.net/article/390315967.html