忘備録

日々の調べ物をまとめる。アウトプットする。基本自分用。

【CentOS6】mailxでメールを送信

環境

サーバOS: CentOS 6.7

mailxのインストール

$ yum -y install mailx
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: mirror.premi.st
 * extras: ftp.riken.jp
 * rpmforge: ftp.riken.jp
 * updates: ftp.riken.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package mailx.x86_64 0:12.4-8.el6_6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================
 パッケージ                          アーキテクチャ                       バージョン                                 リポジトリー                        容量
==============================================================================================================================================================
インストールしています:
 mailx                               x86_64                               12.4-8.el6_6                               base                               235 k

トランザクションの要約
==============================================================================================================================================================
インストール         1 パッケージ

総ダウンロード容量: 235 k
インストール済み容量: 452 k
パッケージをダウンロードしています:
mailx-12.4-8.el6_6.x86_64.rpm                                                                                                          | 235 kB     00:00     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : mailx-12.4-8.el6_6.x86_64                                                                                                     1/1 
  Verifying               : mailx-12.4-8.el6_6.x86_64                                                                                                     1/1 

インストール:
  mailx.x86_64 0:12.4-8.el6_6                                                                                                                                 

完了しました!

smtpサーバを建てない場合(gmailsmtpサーバを利用)

msmtpをインストールする。

$  yum -y install msmtp
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.riken.jp
 * extras: ftp.riken.jp
 * rpmforge: ftp.kddilabs.jp
 * updates: ftp.riken.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package msmtp.x86_64 0:1.4.32-1.el6 will be インストール
--> 依存性の処理をしています: libgsasl.so.7(LIBGSASL_1.1)(64bit) のパッケージ: msmtp-1.4.32-1.el6.x86_64
--> 依存性の処理をしています: libgnutls.so.26(GNUTLS_1_4)(64bit) のパッケージ: msmtp-1.4.32-1.el6.x86_64
--> 依存性の処理をしています: libgsasl.so.7()(64bit) のパッケージ: msmtp-1.4.32-1.el6.x86_64
--> 依存性の処理をしています: libgnutls.so.26()(64bit) のパッケージ: msmtp-1.4.32-1.el6.x86_64
--> 依存性の処理をしています: libgnome-keyring.so.0()(64bit) のパッケージ: msmtp-1.4.32-1.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package gnome-keyring.x86_64 0:2.28.2-8.el6_3 will be インストール
--> 依存性の処理をしています: GConf2 のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: GConf2 のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libpangoft2-1.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libpangocairo-1.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libpango-1.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libgtk-x11-2.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libgdk_pixbuf-2.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libgdk-x11-2.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libgconf-2.so.4()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libfreetype.so.6()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libfontconfig.so.1()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libcairo.so.2()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
--> 依存性の処理をしています: libatk-1.0.so.0()(64bit) のパッケージ: gnome-keyring-2.28.2-8.el6_3.x86_64
---> Package gnutls.x86_64 0:2.8.5-19.el6_7 will be インストール
---> Package libgsasl.x86_64 0:1.4.0-4.el6 will be インストール
--> 依存性の処理をしています: libntlm.so.0()(64bit) のパッケージ: libgsasl-1.4.0-4.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package GConf2.x86_64 0:2.28.0-6.el6 will be インストール
--> 依存性の処理をしています: sgml-common のパッケージ: GConf2-2.28.0-6.el6.x86_64
--> 依存性の処理をしています: dbus のパッケージ: GConf2-2.28.0-6.el6.x86_64
--> 依存性の処理をしています: libpolkit-gobject-1.so.0()(64bit) のパッケージ: GConf2-2.28.0-6.el6.x86_64
--> 依存性の処理をしています: libORBit-2.so.0()(64bit) のパッケージ: GConf2-2.28.0-6.el6.x86_64
---> Package atk.x86_64 0:1.30.0-1.el6 will be インストール
---> Package cairo.x86_64 0:1.8.8-6.el6_6 will be インストール
--> 依存性の処理をしています: libpng12.so.0(PNG12_0)(64bit) のパッケージ: cairo-1.8.8-6.el6_6.x86_64
--> 依存性の処理をしています: libpng12.so.0()(64bit) のパッケージ: cairo-1.8.8-6.el6_6.x86_64
--> 依存性の処理をしています: libpixman-1.so.0()(64bit) のパッケージ: cairo-1.8.8-6.el6_6.x86_64
--> 依存性の処理をしています: libXrender.so.1()(64bit) のパッケージ: cairo-1.8.8-6.el6_6.x86_64
--> 依存性の処理をしています: libX11.so.6()(64bit) のパッケージ: cairo-1.8.8-6.el6_6.x86_64
---> Package fontconfig.x86_64 0:2.8.0-5.el6 will be インストール
---> Package freetype.x86_64 0:2.3.11-15.el6_6.1 will be インストール
---> Package gdk-pixbuf2.x86_64 0:2.24.1-6.el6_7 will be インストール
--> 依存性の処理をしています: libjpeg.so.62(LIBJPEG_6.2)(64bit) のパッケージ: gdk-pixbuf2-2.24.1-6.el6_7.x86_64
--> 依存性の処理をしています: libtiff.so.3()(64bit) のパッケージ: gdk-pixbuf2-2.24.1-6.el6_7.x86_64
--> 依存性の処理をしています: libjpeg.so.62()(64bit) のパッケージ: gdk-pixbuf2-2.24.1-6.el6_7.x86_64
--> 依存性の処理をしています: libjasper.so.1()(64bit) のパッケージ: gdk-pixbuf2-2.24.1-6.el6_7.x86_64
---> Package gtk2.x86_64 0:2.24.23-6.el6 will be インストール
--> 依存性の処理をしています: libXrandr >= 1.2.99.4-2 のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: hicolor-icon-theme のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libcups.so.2()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXrandr.so.2()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXinerama.so.1()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXi.so.6()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXfixes.so.3()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXext.so.6()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXdamage.so.1()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXcursor.so.1()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
--> 依存性の処理をしています: libXcomposite.so.1()(64bit) のパッケージ: gtk2-2.24.23-6.el6.x86_64
---> Package libntlm.x86_64 0:1.0-3.el6 will be インストール
---> Package pango.x86_64 0:1.28.1-10.el6 will be インストール
--> 依存性の処理をしています: libthai >= 0.1.9 のパッケージ: pango-1.28.1-10.el6.x86_64
--> 依存性の処理をしています: libthai.so.0(LIBTHAI_0.1)(64bit) のパッケージ: pango-1.28.1-10.el6.x86_64
--> 依存性の処理をしています: libthai.so.0()(64bit) のパッケージ: pango-1.28.1-10.el6.x86_64
--> 依存性の処理をしています: libXft.so.2()(64bit) のパッケージ: pango-1.28.1-10.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package ORBit2.x86_64 0:2.14.17-5.el6 will be インストール
--> 依存性の処理をしています: libIDL-2.so.0()(64bit) のパッケージ: ORBit2-2.14.17-5.el6.x86_64
---> Package cups-libs.x86_64 1:1.4.2-72.el6 will be インストール
--> 依存性の処理をしています: libavahi-common.so.3()(64bit) のパッケージ: 1:cups-libs-1.4.2-72.el6.x86_64
--> 依存性の処理をしています: libavahi-client.so.3()(64bit) のパッケージ: 1:cups-libs-1.4.2-72.el6.x86_64
---> Package dbus.x86_64 1:1.2.24-8.el6_6 will be インストール
---> Package hicolor-icon-theme.noarch 0:0.11-1.1.el6 will be インストール
---> Package jasper-libs.x86_64 0:1.900.1-16.el6_6.3 will be インストール
---> Package libX11.x86_64 0:1.6.0-6.el6 will be インストール
--> 依存性の処理をしています: libX11-common = 1.6.0-6.el6 のパッケージ: libX11-1.6.0-6.el6.x86_64
--> 依存性の処理をしています: libxcb.so.1()(64bit) のパッケージ: libX11-1.6.0-6.el6.x86_64
---> Package libXcomposite.x86_64 0:0.4.3-4.el6 will be インストール
---> Package libXcursor.x86_64 0:1.1.14-2.1.el6 will be インストール
---> Package libXdamage.x86_64 0:1.1.3-4.el6 will be インストール
---> Package libXext.x86_64 0:1.3.2-2.1.el6 will be インストール
---> Package libXfixes.x86_64 0:5.0.1-2.1.el6 will be インストール
---> Package libXft.x86_64 0:2.3.1-2.el6 will be インストール
---> Package libXi.x86_64 0:1.7.2-2.2.el6 will be インストール
---> Package libXinerama.x86_64 0:1.1.3-2.1.el6 will be インストール
---> Package libXrandr.x86_64 0:1.4.1-2.1.el6 will be インストール
---> Package libXrender.x86_64 0:0.9.8-2.1.el6 will be インストール
---> Package libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 will be インストール
---> Package libpng.x86_64 2:1.2.49-2.el6_7 will be インストール
---> Package libthai.x86_64 0:0.1.12-3.el6 will be インストール
---> Package libtiff.x86_64 0:3.9.4-10.el6_5 will be インストール
---> Package pixman.x86_64 0:0.32.4-4.el6 will be インストール
---> Package polkit.x86_64 0:0.96-11.el6 will be インストール
--> 依存性の処理をしています: ConsoleKit のパッケージ: polkit-0.96-11.el6.x86_64
--> 依存性の処理をしています: libeggdbus-1.so.0()(64bit) のパッケージ: polkit-0.96-11.el6.x86_64
---> Package sgml-common.noarch 0:0.6.3-33.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package ConsoleKit.x86_64 0:0.4.1-3.el6 will be インストール
--> 依存性の処理をしています: libck-connector.so.0()(64bit) のパッケージ: ConsoleKit-0.4.1-3.el6.x86_64
---> Package avahi-libs.x86_64 0:0.6.25-15.el6 will be インストール
---> Package eggdbus.x86_64 0:0.6-3.el6 will be インストール
---> Package libIDL.x86_64 0:0.8.13-2.1.el6 will be インストール
---> Package libX11-common.noarch 0:1.6.0-6.el6 will be インストール
---> Package libxcb.x86_64 0:1.9.1-3.el6 will be インストール
--> 依存性の処理をしています: libXau.so.6()(64bit) のパッケージ: libxcb-1.9.1-3.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package ConsoleKit-libs.x86_64 0:0.4.1-3.el6 will be インストール
---> Package libXau.x86_64 0:1.0.6-4.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================
 パッケージ                                 アーキテクチャ                 バージョン                                   リポジトリー                     容量
==============================================================================================================================================================
インストールしています:
 msmtp                                      x86_64                         1.4.32-1.el6                                 epel                            118 k
依存性関連でのインストールをします。:
 ConsoleKit                                 x86_64                         0.4.1-3.el6                                  base                             82 k
 ConsoleKit-libs                            x86_64                         0.4.1-3.el6                                  base                             17 k
 GConf2                                     x86_64                         2.28.0-6.el6                                 base                            964 k
 ORBit2                                     x86_64                         2.14.17-5.el6                                base                            168 k
 atk                                        x86_64                         1.30.0-1.el6                                 base                            195 k
 avahi-libs                                 x86_64                         0.6.25-15.el6                                base                             55 k
 cairo                                      x86_64                         1.8.8-6.el6_6                                base                            309 k
 cups-libs                                  x86_64                         1:1.4.2-72.el6                               base                            321 k
 dbus                                       x86_64                         1:1.2.24-8.el6_6                             base                            207 k
 eggdbus                                    x86_64                         0.6-3.el6                                    base                             91 k
 fontconfig                                 x86_64                         2.8.0-5.el6                                  base                            186 k
 freetype                                   x86_64                         2.3.11-15.el6_6.1                            base                            361 k
 gdk-pixbuf2                                x86_64                         2.24.1-6.el6_7                               updates                         501 k
 gnome-keyring                              x86_64                         2.28.2-8.el6_3                               base                            811 k
 gnutls                                     x86_64                         2.8.5-19.el6_7                               updates                         347 k
 gtk2                                       x86_64                         2.24.23-6.el6                                base                            3.2 M
 hicolor-icon-theme                         noarch                         0.11-1.1.el6                                 base                             40 k
 jasper-libs                                x86_64                         1.900.1-16.el6_6.3                           base                            137 k
 libIDL                                     x86_64                         0.8.13-2.1.el6                               base                             83 k
 libX11                                     x86_64                         1.6.0-6.el6                                  base                            586 k
 libX11-common                              noarch                         1.6.0-6.el6                                  base                            192 k
 libXau                                     x86_64                         1.0.6-4.el6                                  base                             24 k
 libXcomposite                              x86_64                         0.4.3-4.el6                                  base                             20 k
 libXcursor                                 x86_64                         1.1.14-2.1.el6                               base                             28 k
 libXdamage                                 x86_64                         1.1.3-4.el6                                  base                             18 k
 libXext                                    x86_64                         1.3.2-2.1.el6                                base                             35 k
 libXfixes                                  x86_64                         5.0.1-2.1.el6                                base                             17 k
 libXft                                     x86_64                         2.3.1-2.el6                                  base                             55 k
 libXi                                      x86_64                         1.7.2-2.2.el6                                base                             37 k
 libXinerama                                x86_64                         1.1.3-2.1.el6                                base                             13 k
 libXrandr                                  x86_64                         1.4.1-2.1.el6                                base                             23 k
 libXrender                                 x86_64                         0.9.8-2.1.el6                                base                             24 k
 libgsasl                                   x86_64                         1.4.0-4.el6                                  epel                            113 k
 libjpeg-turbo                              x86_64                         1.2.1-3.el6_5                                base                            174 k
 libntlm                                    x86_64                         1.0-3.el6                                    base                             42 k
 libpng                                     x86_64                         2:1.2.49-2.el6_7                             updates                         182 k
 libthai                                    x86_64                         0.1.12-3.el6                                 base                            183 k
 libtiff                                    x86_64                         3.9.4-10.el6_5                               base                            343 k
 libxcb                                     x86_64                         1.9.1-3.el6                                  base                            110 k
 pango                                      x86_64                         1.28.1-10.el6                                base                            351 k
 pixman                                     x86_64                         0.32.4-4.el6                                 base                            243 k
 polkit                                     x86_64                         0.96-11.el6                                  base                            162 k
 sgml-common                                noarch                         0.6.3-33.el6                                 base                             43 k

トランザクションの要約
==============================================================================================================================================================
インストール        44 パッケージ

総ダウンロード容量: 11 M
インストール済み容量: 41 M
パッケージをダウンロードしています:
(1/44): ConsoleKit-0.4.1-3.el6.x86_64.rpm                                                                                              |  82 kB     00:00     
(2/44): ConsoleKit-libs-0.4.1-3.el6.x86_64.rpm                                                                                         |  17 kB     00:00     
(3/44): GConf2-2.28.0-6.el6.x86_64.rpm                                                                                                 | 964 kB     00:00     
(4/44): ORBit2-2.14.17-5.el6.x86_64.rpm                                                                                                | 168 kB     00:00     
(5/44): atk-1.30.0-1.el6.x86_64.rpm                                                                                                    | 195 kB     00:00     
(6/44): avahi-libs-0.6.25-15.el6.x86_64.rpm                                                                                            |  55 kB     00:00     
(7/44): cairo-1.8.8-6.el6_6.x86_64.rpm                                                                                                 | 309 kB     00:00     
(8/44): cups-libs-1.4.2-72.el6.x86_64.rpm                                                                                              | 321 kB     00:00     
(9/44): dbus-1.2.24-8.el6_6.x86_64.rpm                                                                                                 | 207 kB     00:00     
(10/44): eggdbus-0.6-3.el6.x86_64.rpm                                                                                                  |  91 kB     00:00     
(11/44): fontconfig-2.8.0-5.el6.x86_64.rpm                                                                                             | 186 kB     00:00     
(12/44): freetype-2.3.11-15.el6_6.1.x86_64.rpm                                                                                         | 361 kB     00:00     
(13/44): gdk-pixbuf2-2.24.1-6.el6_7.x86_64.rpm                                                                                         | 501 kB     00:00     
(14/44): gnome-keyring-2.28.2-8.el6_3.x86_64.rpm                                                                                       | 811 kB     00:00     
(15/44): gnutls-2.8.5-19.el6_7.x86_64.rpm                                                                                              | 347 kB     00:00     
(16/44): gtk2-2.24.23-6.el6.x86_64.rpm                                                                                                 | 3.2 MB     00:01     
(17/44): hicolor-icon-theme-0.11-1.1.el6.noarch.rpm                                                                                    |  40 kB     00:00     
(18/44): jasper-libs-1.900.1-16.el6_6.3.x86_64.rpm                                                                                     | 137 kB     00:00     
(19/44): libIDL-0.8.13-2.1.el6.x86_64.rpm                                                                                              |  83 kB     00:00     
(20/44): libX11-1.6.0-6.el6.x86_64.rpm                                                                                                 | 586 kB     00:00     
(21/44): libX11-common-1.6.0-6.el6.noarch.rpm                                                                                          | 192 kB     00:00     
(22/44): libXau-1.0.6-4.el6.x86_64.rpm                                                                                                 |  24 kB     00:00     
(23/44): libXcomposite-0.4.3-4.el6.x86_64.rpm                                                                                          |  20 kB     00:00     
(24/44): libXcursor-1.1.14-2.1.el6.x86_64.rpm                                                                                          |  28 kB     00:00     
(25/44): libXdamage-1.1.3-4.el6.x86_64.rpm                                                                                             |  18 kB     00:00     
(26/44): libXext-1.3.2-2.1.el6.x86_64.rpm                                                                                              |  35 kB     00:00     
(27/44): libXfixes-5.0.1-2.1.el6.x86_64.rpm                                                                                            |  17 kB     00:00     
(28/44): libXft-2.3.1-2.el6.x86_64.rpm                                                                                                 |  55 kB     00:00     
(29/44): libXi-1.7.2-2.2.el6.x86_64.rpm                                                                                                |  37 kB     00:00     
(30/44): libXinerama-1.1.3-2.1.el6.x86_64.rpm                                                                                          |  13 kB     00:00     
(31/44): libXrandr-1.4.1-2.1.el6.x86_64.rpm                                                                                            |  23 kB     00:00     
(32/44): libXrender-0.9.8-2.1.el6.x86_64.rpm                                                                                           |  24 kB     00:00     
(33/44): libgsasl-1.4.0-4.el6.x86_64.rpm                                                                                               | 113 kB     00:00     
(34/44): libjpeg-turbo-1.2.1-3.el6_5.x86_64.rpm                                                                                        | 174 kB     00:00     
(35/44): libntlm-1.0-3.el6.x86_64.rpm                                                                                                  |  42 kB     00:00     
(36/44): libpng-1.2.49-2.el6_7.x86_64.rpm                                                                                              | 182 kB     00:00     
(37/44): libthai-0.1.12-3.el6.x86_64.rpm                                                                                               | 183 kB     00:00     
(38/44): libtiff-3.9.4-10.el6_5.x86_64.rpm                                                                                             | 343 kB     00:00     
(39/44): libxcb-1.9.1-3.el6.x86_64.rpm                                                                                                 | 110 kB     00:00     
(40/44): msmtp-1.4.32-1.el6.x86_64.rpm                                                                                                 | 118 kB     00:00     
(41/44): pango-1.28.1-10.el6.x86_64.rpm                                                                                                | 351 kB     00:00     
(42/44): pixman-0.32.4-4.el6.x86_64.rpm                                                                                                | 243 kB     00:00     
(43/44): polkit-0.96-11.el6.x86_64.rpm                                                                                                 | 162 kB     00:00     
(44/44): sgml-common-0.6.3-33.el6.noarch.rpm                                                                                           |  43 kB     00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                          915 kB/s |  11 MB     00:12     
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : freetype-2.3.11-15.el6_6.1.x86_64                                                                                            1/44 
  インストールしています  : fontconfig-2.8.0-5.el6.x86_64                                                                                                2/44 
  インストールしています  : libjpeg-turbo-1.2.1-3.el6_5.x86_64                                                                                           3/44 
  インストールしています  : 1:dbus-1.2.24-8.el6_6.x86_64                                                                                                 4/44 
  インストールしています  : 2:libpng-1.2.49-2.el6_7.x86_64                                                                                               5/44 
  インストールしています  : libtiff-3.9.4-10.el6_5.x86_64                                                                                                6/44 
  インストールしています  : atk-1.30.0-1.el6.x86_64                                                                                                      7/44 
  インストールしています  : gnutls-2.8.5-19.el6_7.x86_64                                                                                                 8/44 
  インストールしています  : ConsoleKit-libs-0.4.1-3.el6.x86_64                                                                                           9/44 
  インストールしています  : jasper-libs-1.900.1-16.el6_6.3.x86_64                                                                                       10/44 
  インストールしています  : pixman-0.32.4-4.el6.x86_64                                                                                                  11/44 
  インストールしています  : libthai-0.1.12-3.el6.x86_64                                                                                                 12/44 
  インストールしています  : libXau-1.0.6-4.el6.x86_64                                                                                                   13/44 
  インストールしています  : libxcb-1.9.1-3.el6.x86_64                                                                                                   14/44 
  インストールしています  : eggdbus-0.6-3.el6.x86_64                                                                                                    15/44 
  インストールしています  : polkit-0.96-11.el6.x86_64                                                                                                   16/44 
  インストールしています  : ConsoleKit-0.4.1-3.el6.x86_64                                                                                               17/44 
  インストールしています  : libX11-common-1.6.0-6.el6.noarch                                                                                            18/44 
  インストールしています  : libX11-1.6.0-6.el6.x86_64                                                                                                   19/44 
  インストールしています  : libXrender-0.9.8-2.1.el6.x86_64                                                                                             20/44 
  インストールしています  : libXext-1.3.2-2.1.el6.x86_64                                                                                                21/44 
  インストールしています  : cairo-1.8.8-6.el6_6.x86_64                                                                                                  22/44 
  インストールしています  : libXfixes-5.0.1-2.1.el6.x86_64                                                                                              23/44 
  インストールしています  : gdk-pixbuf2-2.24.1-6.el6_7.x86_64                                                                                           24/44 
  インストールしています  : libXdamage-1.1.3-4.el6.x86_64                                                                                               25/44 
  インストールしています  : libXcursor-1.1.14-2.1.el6.x86_64                                                                                            26/44 
  インストールしています  : libXinerama-1.1.3-2.1.el6.x86_64                                                                                            27/44 
  インストールしています  : libXrandr-1.4.1-2.1.el6.x86_64                                                                                              28/44 
  インストールしています  : libXi-1.7.2-2.2.el6.x86_64                                                                                                  29/44 
  インストールしています  : libXft-2.3.1-2.el6.x86_64                                                                                                   30/44 
  インストールしています  : pango-1.28.1-10.el6.x86_64                                                                                                  31/44 
  インストールしています  : libXcomposite-0.4.3-4.el6.x86_64                                                                                            32/44 
  インストールしています  : avahi-libs-0.6.25-15.el6.x86_64                                                                                             33/44 
  インストールしています  : 1:cups-libs-1.4.2-72.el6.x86_64                                                                                             34/44 
  インストールしています  : libIDL-0.8.13-2.1.el6.x86_64                                                                                                35/44 
  インストールしています  : ORBit2-2.14.17-5.el6.x86_64                                                                                                 36/44 
  インストールしています  : hicolor-icon-theme-0.11-1.1.el6.noarch                                                                                      37/44 
  インストールしています  : gtk2-2.24.23-6.el6.x86_64                                                                                                   38/44 
  インストールしています  : libntlm-1.0-3.el6.x86_64                                                                                                    39/44 
  インストールしています  : libgsasl-1.4.0-4.el6.x86_64                                                                                                 40/44 
  インストールしています  : sgml-common-0.6.3-33.el6.noarch                                                                                             41/44 
  インストールしています  : GConf2-2.28.0-6.el6.x86_64                                                                                                  42/44 
  インストールしています  : gnome-keyring-2.28.2-8.el6_3.x86_64                                                                                         43/44 
  インストールしています  : msmtp-1.4.32-1.el6.x86_64                                                                                                   44/44 
  Verifying               : cairo-1.8.8-6.el6_6.x86_64                                                                                                   1/44 
  Verifying               : libXrender-0.9.8-2.1.el6.x86_64                                                                                              2/44 
  Verifying               : sgml-common-0.6.3-33.el6.noarch                                                                                              3/44 
  Verifying               : libXdamage-1.1.3-4.el6.x86_64                                                                                                4/44 
  Verifying               : jasper-libs-1.900.1-16.el6_6.3.x86_64                                                                                        5/44 
  Verifying               : libxcb-1.9.1-3.el6.x86_64                                                                                                    6/44 
  Verifying               : fontconfig-2.8.0-5.el6.x86_64                                                                                                7/44 
  Verifying               : libtiff-3.9.4-10.el6_5.x86_64                                                                                                8/44 
  Verifying               : ConsoleKit-0.4.1-3.el6.x86_64                                                                                                9/44 
  Verifying               : GConf2-2.28.0-6.el6.x86_64                                                                                                  10/44 
  Verifying               : pango-1.28.1-10.el6.x86_64                                                                                                  11/44 
  Verifying               : polkit-0.96-11.el6.x86_64                                                                                                   12/44 
  Verifying               : 2:libpng-1.2.49-2.el6_7.x86_64                                                                                              13/44 
  Verifying               : libgsasl-1.4.0-4.el6.x86_64                                                                                                 14/44 
  Verifying               : libntlm-1.0-3.el6.x86_64                                                                                                    15/44 
  Verifying               : gnome-keyring-2.28.2-8.el6_3.x86_64                                                                                         16/44 
  Verifying               : hicolor-icon-theme-0.11-1.1.el6.noarch                                                                                      17/44 
  Verifying               : libIDL-0.8.13-2.1.el6.x86_64                                                                                                18/44 
  Verifying               : libX11-1.6.0-6.el6.x86_64                                                                                                   19/44 
  Verifying               : ORBit2-2.14.17-5.el6.x86_64                                                                                                 20/44 
  Verifying               : freetype-2.3.11-15.el6_6.1.x86_64                                                                                           21/44 
  Verifying               : 1:dbus-1.2.24-8.el6_6.x86_64                                                                                                22/44 
  Verifying               : libXft-2.3.1-2.el6.x86_64                                                                                                   23/44 
  Verifying               : gnutls-2.8.5-19.el6_7.x86_64                                                                                                24/44 
  Verifying               : avahi-libs-0.6.25-15.el6.x86_64                                                                                             25/44 
  Verifying               : gdk-pixbuf2-2.24.1-6.el6_7.x86_64                                                                                           26/44 
  Verifying               : ConsoleKit-libs-0.4.1-3.el6.x86_64                                                                                          27/44 
  Verifying               : gtk2-2.24.23-6.el6.x86_64                                                                                                   28/44 
  Verifying               : libXinerama-1.1.3-2.1.el6.x86_64                                                                                            29/44 
  Verifying               : msmtp-1.4.32-1.el6.x86_64                                                                                                   30/44 
  Verifying               : libX11-common-1.6.0-6.el6.noarch                                                                                            31/44 
  Verifying               : eggdbus-0.6-3.el6.x86_64                                                                                                    32/44 
  Verifying               : libXext-1.3.2-2.1.el6.x86_64                                                                                                33/44 
  Verifying               : libjpeg-turbo-1.2.1-3.el6_5.x86_64                                                                                          34/44 
  Verifying               : libXcursor-1.1.14-2.1.el6.x86_64                                                                                            35/44 
  Verifying               : libXrandr-1.4.1-2.1.el6.x86_64                                                                                              36/44 
  Verifying               : libXi-1.7.2-2.2.el6.x86_64                                                                                                  37/44 
  Verifying               : 1:cups-libs-1.4.2-72.el6.x86_64                                                                                             38/44 
  Verifying               : libXau-1.0.6-4.el6.x86_64                                                                                                   39/44 
  Verifying               : libthai-0.1.12-3.el6.x86_64                                                                                                 40/44 
  Verifying               : pixman-0.32.4-4.el6.x86_64                                                                                                  41/44 
  Verifying               : atk-1.30.0-1.el6.x86_64                                                                                                     42/44 
  Verifying               : libXcomposite-0.4.3-4.el6.x86_64                                                                                            43/44 
  Verifying               : libXfixes-5.0.1-2.1.el6.x86_64                                                                                              44/44 

インストール:
  msmtp.x86_64 0:1.4.32-1.el6                                                                                                                                 

依存性関連をインストールしました:
  ConsoleKit.x86_64 0:0.4.1-3.el6           ConsoleKit-libs.x86_64 0:0.4.1-3.el6     GConf2.x86_64 0:2.28.0-6.el6        ORBit2.x86_64 0:2.14.17-5.el6       
  atk.x86_64 0:1.30.0-1.el6                 avahi-libs.x86_64 0:0.6.25-15.el6        cairo.x86_64 0:1.8.8-6.el6_6        cups-libs.x86_64 1:1.4.2-72.el6     
  dbus.x86_64 1:1.2.24-8.el6_6              eggdbus.x86_64 0:0.6-3.el6               fontconfig.x86_64 0:2.8.0-5.el6     freetype.x86_64 0:2.3.11-15.el6_6.1 
  gdk-pixbuf2.x86_64 0:2.24.1-6.el6_7       gnome-keyring.x86_64 0:2.28.2-8.el6_3    gnutls.x86_64 0:2.8.5-19.el6_7      gtk2.x86_64 0:2.24.23-6.el6         
  hicolor-icon-theme.noarch 0:0.11-1.1.el6  jasper-libs.x86_64 0:1.900.1-16.el6_6.3  libIDL.x86_64 0:0.8.13-2.1.el6      libX11.x86_64 0:1.6.0-6.el6         
  libX11-common.noarch 0:1.6.0-6.el6        libXau.x86_64 0:1.0.6-4.el6              libXcomposite.x86_64 0:0.4.3-4.el6  libXcursor.x86_64 0:1.1.14-2.1.el6  
  libXdamage.x86_64 0:1.1.3-4.el6           libXext.x86_64 0:1.3.2-2.1.el6           libXfixes.x86_64 0:5.0.1-2.1.el6    libXft.x86_64 0:2.3.1-2.el6         
  libXi.x86_64 0:1.7.2-2.2.el6              libXinerama.x86_64 0:1.1.3-2.1.el6       libXrandr.x86_64 0:1.4.1-2.1.el6    libXrender.x86_64 0:0.9.8-2.1.el6   
  libgsasl.x86_64 0:1.4.0-4.el6             libjpeg-turbo.x86_64 0:1.2.1-3.el6_5     libntlm.x86_64 0:1.0-3.el6          libpng.x86_64 2:1.2.49-2.el6_7      
  libthai.x86_64 0:0.1.12-3.el6             libtiff.x86_64 0:3.9.4-10.el6_5          libxcb.x86_64 0:1.9.1-3.el6         pango.x86_64 0:1.28.1-10.el6        
  pixman.x86_64 0:0.32.4-4.el6              polkit.x86_64 0:0.96-11.el6              sgml-common.noarch 0:0.6.3-33.el6  

完了しました!

msmtpの設定

サンプルを参考に設定ファイルを作成。

$ cp /usr/share/doc/msmtp-1.4.32/msmtprc-user.example ~/.msmtprc
$ vi ~/.msmtprc

最終的にこんな感じに。

# Example for a user configuration file

# Set default values for all following accounts.
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
logfile ~/.msmtp.log

# gmail service
account gmail
host smtp.gmail.com # smtpサーバ
port 587 # smtpサーバのポート
from user@gmail.com # 送信元メールアドレス
user user # 認証に利用されるユーザ
password password # 認証に利用されるパスワード

# Set a default account
account default : gmail

mailxの設定

.mailrcの作成

$ vi ~/.mailrc

先ほど設定したmsmtpの設定を使うようにする。

# set smtp for mailx
set sendmail="/usr/bin/msmtp"

送信テスト

送信してみる。

$  mail hoge@example.com
Subject: テスト件名
テスト本文
.
EOT

エラーが。。。

send-mail: authentication failed (method PLAIN)
send-mail: server message: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvp3
#〜〜〜〜〜〜〜〜〜〜〜〜〜〜(省略)〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
send-mail: server message: 534-5.7.14 ygIFjX33634n_LN73HnYlF-FZ-oE> Please log in via your web browser and
send-mail: server message: 534-5.7.14 then try again.
send-mail: server message: 534-5.7.14  Learn more at
send-mail: server message: 534 5.7.14  https://support.google.com/mail/answer/78754 i15sm36542030pfi.55 - gsmtp
send-mail: could not send mail (account default from /root/.msmtprc)

ググる

phpmailer - Gmail SMTP debug: error "please log in via your web browser" - Stack Overflow

Head over to Account Security Settings (https://www.google.com/settings/security/lesssecureapps) and enable "Access for less secure apps", this allows you to use the google smtp for clients other than the official ones.

書いてあるとおりhttps://www.google.com/settings/security/lesssecureappsにアクセス。

f:id:mktktmr:20160222232614p:plain

ベストな方法ではないんだろうけど、他にやり方が見つからなかったのでこれにて対応。

参考

Send mail as from my personal gmail account - Ask Ubuntu

msmtp 1.4.23 日本語訳: msmtp

CentOS7 on AWS httpサーバ構築ではまったこと

環境

サーバ

AWSVPC上に構築

EC2インスタンス概要

サーバソフト

作業クライアント

OS X 10.10.5

やったこと

詳しくは書かないが、一応メモとして

  • apache実行ユーザの作成
  • 不要なサービスの停止
  • パッケージの最新化
  • cronによるmydnsへIPの通知
  • httpdのインストール
  • httpdの設定
    • httpd.confを弄る
    • バーチャルホストの設定
  • ディレクトリのオーナー・アクセス権限変更
  • SELinuxの無効化

はまったこと

1. SSHで接続できない?

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜(中略)〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜

「WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED」というワーニングが出る。

設定ミスってEC2作り直したんだけど、そのせいで、なりすましだと勘違いされてしまったっぽい。

なんで、SSHの既知のホスト情報を一旦消すと良いみたい。

SSH接続で WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! って言われて接続を拒否られるとき(コメント)

過去の投稿にもありますが、ssh-keygen -R で消せます。

$ ssh-keygen -R hoge.example.com

これで解決かと思ったんですが。。。

$ ssh -i key.pem ec2-user@hoge.example.com
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

次は認証エラーで繋げず。。。

ググってもなかなか原因が分からず、途方にくれているところ、たまたまAWSのコンソールを弄ってたら

f:id:mktktmr:20160222003141p:plain

。。。あっ

AMIがRHEL7の場合、初期ユーザが「ec2-user」だったので、CentOS7も同じだろうと思っていたら違いました。

CentOS7の場合は「centos」でした。

見つけたから良かったけど、これは分かりにくい。。。

2. ネットワークコマンドがない?

サーバの疎通を確認するためにdigやnslookupを叩きたいが、デフォルトでは入っていなかった。

$ dig
-bash: dig: command not found
$ nslookup
-bash: nslookup: command not found

で、yumでインストールを試みるが。。。

# dig
$ yum install dig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
No package dig available.
Error: Nothing to do
# nslookup
$ yum install nslookup
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
No package nslookup available.
Error: Nothing to do

ない。

と思ったら、digやnslookupはbind-utilsパッケージにいるらしい

digも、hostも、nslookupも入ってない - Snufkinski Memo

CentOS 6をminimalインストールすると、デフォルトではDNS名前解決テスト用のdig,nslookup,hostコマンドがインストールされていません。
CentOS 6にdig,nslookup,hostコマンドをインストールしたい場合、bind-utilsをインストールします。

yum -y install bind-utils

3. httpサーバにアクセスできない?

httpdも動いているし。。。

$ systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-02-21 15:43:49 UTC; 33min ago
#〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜(省略)〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜

IPとドメインの紐付けもちゃんとできてるし。。。

nslookup -type=A hoge.example.com
Server:     XXX.XXX.XXX.XXX
Address:    XXX.XXX.XXX.XXX#ZZ

Non-authoritative answer:
Name:   hoge.example.com
Address: YYY.YYY.YYY.YYY

firewalldまでいれて80ポートも開けたんだよ!

。。。

いやいや、AWSなんだからセキュリティグループ弄れよって話でした。

Linux インスタンスの Amazon EC2 セキュリティグループ - Amazon Elastic Compute Cloud

f:id:mktktmr:20160222011400p:plain

とりあえず、おおきくハマったのは以上の3点。

つまらないことで、時間を消費してしまった。。。

Git Flow

Gitの構成管理・運用方法として知られているGit Flowについて学びたいと思います

参考

git-model

環境

  • OS: OS X 10.10.5
  • git version 2.5.4 (Apple Git-61)

準備

git flowをサポートしてくれるツール

その名も「git−flow」(直球)をインストールします

$ brew install git-flow
==> Downloading https://homebrew.bintray.com/bottles/git-flow-0.4.1.yosemite.bot
######################################################################## 100.0%
==> Pouring git-flow-0.4.1.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/git-flow/0.4.1: 15 files, 106.6K
# 確認
$ git flow version
0.4.1

git-flow初期化

git-flowを使って初期化を行います

# 開発対象のリポジトリをclone
$ git clone https://github.com/mktktmr/ex_git-flow.git
Cloning into 'ex_git-flow'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
Checking connectivity... done.
$ cd ex_git-flow/
# 「git flow init」でgit flowに必要な初期化を行う
# オプション-d は初期設定
$ git flow init -d
Using default branch names.

Which branch should be used for bringing forth production releases?
   - master
Branch name for production releases: [master] 
Branch name for "next release" development: [develop] 
$ 
$ git branch -a
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
$ 
$ git push -u origin develop
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
 * [new branch]      develop -> develop
Branch develop set up to track remote branch develop from origin. 

git flowにおけるブランチの役割

master

  • リリース用
  • プロダクトのバージョンでtagを切る
  • 各開発者はこのブランチに対してcommitすることはない

develop

  • 開発用
  • このブランチに開発中の最新ソースがあるよう管理する
  • featureブランチ(後述)をきる元のブランチとなる
  • 各開発者はこのブランチに対してcommitすることはない

feature

  • 作業用
  • 各開発者はこのブランチにcommitをし、作業が終わったらfeatureにPullRequestを送る

release

  • バージョン番号の付与などリリースに関する作業を行う
  • リリース作業中に発見されたバグはこのブランチにコミットしてよい
  • 仕様変更や機能変更は行わない
  • releaseブランチでの作業が完了したらmasterブランチとdevelopブランチにmergeし、masterブランチではタグを切る

hotfix

  • hotfixブランチはフローにおいて必須ではなく、以下のようなことが発生した場合、適宜作成する
    • release後バグが見つかり、かつdevelopブランチのソースがmergeできる状態でない
    • バグや障害の対応が早急に必要で次のリリースバージョンを待つことができない

ワークフロー

featureブランチでの作業

# ブランチを最新化(1つのブランチに対して複数の開発者がいる場合)
$ git pull
Already up-to-date.
$ 
# git-flowでfeatureブランチ追加
$ git flow feature start add-user
Switched to a new branch 'feature/add-user'

Summary of actions:
- A new branch 'feature/add-user' was created, based on 'develop'
- You are now on branch 'feature/add-user'

Now, start committing on your feature. When done, use:

     git flow feature finish add-user

$ 
# 確認
$ git branch -a
  develop
* feature/add-user
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/master
$ 
# featureブランチをリモートにpush
$ git push origin feature/add-user
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
 * [new branch]      feature/add-user -> feature/add-user
$
# 実装(した体で)
$ touch AddUser.java
$ 
$ git add .
$ git commit -m "Add AddUser.java"
[feature/add-user aae3200] Add AddUser.java
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 AddUser.java
$ 
# pushの前にブランチを最新化
$ git pull origin feature/add-user
From https://github.com/mktktmr/ex_git-flow
 * branch            feature/add-user -> FETCH_HEAD
Already up-to-date.
$ 
# pushの前にdevelopブランチとmergeしておく(他の開発者が更新してるかもしれない)
$ git merge --no-ff origin develop
Already up-to-date.
$ 
# push
$ git push origin feature/add-user
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 299 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
   114038f..aae3200  feature/add-user -> feature/add-user 
# ここまできたらPull Requestを送る

デフォルトブランチについて

デフォルトブランチとは

GitHubにてリポジトリを選択した際に、最初に選択されるブランチ。

git flow ではdevelopブランチを起点にして作業をするため、git flowを採用するのなら 作業ミスを防ぐためデフォルトブランチをdevelopにすることが望ましい

デフォルトブランチの設定方法

デフォルトブランチの設定を変更したいリポジトリ開き、「setting」タブを選択

f:id:mktktmr:20160212195928p:plain

「Branches」を選択し、Default branchの項目のプルダウンからデフォルトにしたいブランチを選び、「Update」をクリックする

f:id:mktktmr:20160212142146p:plain

Pull Request後のフロー

  1. PRした内容をレビューをしてもらい、フィードバックをもらう
    • テストが通ってない
    • コーディング規約に反している
    • コードが汚い
    • リファクタリングの余地がある
    • etc...
  2. レビューのフィードバックを反映させ、pushする
  3. 問題がなくなるまで、1〜2を繰り返す
  4. 管理者がdevelpブランチにマージする

Pull RequestからPR mergeまでの例

pull requestをする

f:id:mktktmr:20160212140429p:plain

フィードバックがある。。。

f:id:mktktmr:20160212140740p:plain

# フィードバックをもとに修正
$ vi AddUser.java 
$ git add .
$ git commit -m "Done Refactoring"
[feature/add-user b35e838] Done Refactoring
 1 file changed, 5 insertions(+)
$ 
# 修正内容をpush
$ git push origin feature/add-user
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 365 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
   aae3200..b35e838  feature/add-user -> feature/add-user

フィードバックが反映され、問題がなければ、pull requestがマージされる

f:id:mktktmr:20160212141344p:plain

# pull request がマージされたらローカルのdevelpブランチを更新する
$ git checkout develop
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
$ git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/mktktmr/ex_git-flow
   1e91db3..5b91113  develop    -> origin/develop
Updating 1e91db3..5b91113
Fast-forward
 AddUser.java | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 AddUser.java

以上を繰り返し機能を追加していく。

featureブランチを切る粒度については今後の研究課題。。。

releaseブランチでの作業

featureブランチによる機能開発が全て終わり、マージが済んだらリリース作業用としてreleaseブランチを切る

このブランチで行うことはバグの修正のみであり、機能追加などはしてはいけない

# ブランチの確認
$ git branch
* develop
  feature/add-user
  master
$ 
# 最新の状態にしておく
$ git pull
Already up-to-date.
# git-flowでreleaseブランチを作成する
$ git flow release start "1.0.0"
Switched to a new branch 'release/1.0.0'

Summary of actions:
- A new branch 'release/1.0.0' was created, based on 'develop'
- You are now on branch 'release/1.0.0'

Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:

     git flow release finish '1.0.0'

$ 
# ブランチ確認
$ git branch
  develop
  feature/add-user
  master
* release/1.0.0
$ 
# バグが見つかったので、修正する(という体)
$ vi AddUser.java 
$ git commit -am "Bugfix"
[release/1.0.0 8ea7af0] Bugfix
 1 file changed, 1 insertion(+)
$ 
# git-flowでrelease 作業のクローズする
# git-flow release finishを実行すると以下の処理が走る
# 1. releaseブランチがmasterブランチにマージされる
# 2. タグの発行
# 3. releaseブランチがdevelopブランチにマージされる
$ git flow release finish
Missing argument <version>
usage: git flow release [list] [-v]
       git flow release start [-F] <version>
       git flow release finish [-Fsumpk] <version>
       git flow release publish <name>
       git flow release track <name>
$ git flow release finish "1.0.0"
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Merge made by the 'recursive' strategy.
 AddUser.java | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 AddUser.java
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
Merge made by the 'recursive' strategy.
 AddUser.java | 1 +
 1 file changed, 1 insertion(+)
Deleted branch release/1.0.0 (was 8ea7af0).

Summary of actions:
- Latest objects have been fetched from 'origin'
- Release branch has been merged into 'master'
- The release was tagged '1.0.0'
- Release branch has been back-merged into 'develop'
- Release branch 'release/1.0.0' has been deleted

$ 
# タグの確認
$ git tag
1.0.0
$ 
# ブランチ確認
$ git branch
* develop
  feature/add-user
  master
$
# developブランチのpush
$ git push origin develop
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 434 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
   5b91113..8f133fb  develop -> develop
$ 
# masterブランチのpush
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 5 commits.
  (use "git push" to publish your local commits)
$ git push
Counting objects: 1, done.
Writing objects: 100% (1/1), 241 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
   1e91db3..5efe88e  master -> master
$ 
# タグをpush
$ git push --tag
Counting objects: 1, done.
Writing objects: 100% (1/1), 175 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
 * [new tag]         1.0.0 -> 1.0.0

hotfixブランチでの作業

# 1.0.0タグからhotfix/1.0.1ブランチを作成
$ git flow hotfix start '1.0.1' '1.0.0'
Switched to a new branch 'hotfix/1.0.1'

Summary of actions:
- A new branch 'hotfix/1.0.1' was created, based on '1.0.0'
- You are now on branch 'hotfix/1.0.1'

Follow-up actions:
- Bump the version number now!
- Start committing your hot fixes
- When done, run:

     git flow hotfix finish '1.0.1'

# バグを修正する(体で)
$ vi AddUser.java 
# 修正をコミット
$ git commit -am "HotFix"
[hotfix/1.0.1 4df2872] HotFix
 1 file changed, 1 insertion(+)
$ 
$ git push origin 
$ git branch
  develop
  feature/add-user
* hotfix/1.0.1
  master
$ git push origin hotfix/1.0.1
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 331 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/mktktmr/ex_git-flow.git
 * [new branch]      hotfix/1.0.1 -> hotfix/1.0.1

バグを修正し、hotfixブランチをpushしたらPRを送る

merge対象はmasterブランチとなることがポイント

f:id:mktktmr:20160215203322p:plain

特に問題もなく、PRが取り込まれたとする

f:id:mktktmr:20160215203649p:plain

タグの作成とリリース

f:id:mktktmr:20160215211739p:plain

f:id:mktktmr:20160215211749p:plain

f:id:mktktmr:20160215211821p:plain

f:id:mktktmr:20160215213627p:plain

タグを切ったら、hotfixとしての対応は終了だが、developブランチと差分が出て入るはずのなので、developブランチにもPRを送り、適宜mergeする

# ブランチを最新化
$ git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/mktktmr/ex_git-flow
   8f133fb..f04db69  develop    -> origin/develop
 * [new tag]         1.0.1      -> 1.0.1
Already up-to-date.
# タグの確認
$ git tag
1.0.0
1.0.1
$ git checkout develop
Switched to branch 'develop'
Your branch is behind 'origin/develop' by 3 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
# ブランチの最新化
$ git pull origin develop
From https://github.com/mktktmr/ex_git-flow
 * branch            develop    -> FETCH_HEAD
Updating 8f133fb..f04db69
Fast-forward
 AddUser.java | 1 +
 1 file changed, 1 insertion(+)
# タグの確認
$ git tag
1.0.0
1.0.1 

【Linux】セキュアなサーバを構築するための最低限の設定

サーバ立て直すことにしたのでメモ

環境

CentOS 6.7

前提

OSのインストールは最小構成(minimal)で行っているものとする

参考

Linuxサーバーセキュリティ徹底入門 オープンソースによるサーバー防衛の基本

作業用ユーザの作成

rootユーザでの作業はしないようにするため、作業用のユーザを作成

# ユーザ作成
$ adduser hoge
# パスワード設定
$ passwd hoge
Changing password for user hoge.
New password:
Retype:
password: all authentication tokens updated successfully.

システムのアップデート

システムの状態を最新にする

$ yum -y update
読み込んだプラグイン:fastestmirror
更新処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
依存性の解決をしています
#〜〜〜〜〜〜〜(中略)〜〜〜〜〜〜〜〜〜
  selinux-policy-targeted.noarch 0:3.7.19-279.el6_7.8             sqlite.x86_64 0:3.6.20-1.el6_7.2                          
  sudo.x86_64 0:1.8.6p3-20.el6_7                                  tzdata.noarch 0:2016a-2.el6                               
  udev.x86_64 0:147-2.63.el6_7.1                                 

完了しました!

不要なサービスの停止

動作しているサービスの確認

$ chkconfig --list | grep 3:on
auditd          0:off  1:off  2:on   3:on   4:on   5:on   6:off
blk-availability    0:off  1:on   2:on   3:on   4:on   5:on   6:off
crond           0:off  1:off  2:on   3:on   4:on   5:on   6:off
ip6tables       0:off  1:off  2:on   3:on   4:on   5:on   6:off
iptables        0:off  1:off  2:on   3:on   4:on   5:on   6:off
iscsi           0:off  1:off  2:off  3:on   4:on   5:on   6:off
iscsid          0:off  1:off  2:off  3:on   4:on   5:on   6:off
lvm2-monitor    0:off  1:on   2:on   3:on   4:on   5:on   6:off
mdmonitor       0:off  1:off  2:on   3:on   4:on   5:on   6:off
netfs           0:off  1:off  2:off  3:on   4:on   5:on   6:off
network         0:off  1:off  2:on   3:on   4:on   5:on   6:off
postfix         0:off  1:off  2:on   3:on   4:on   5:on   6:off
rsyslog         0:off  1:off  2:on   3:on   4:on   5:on   6:off
sshd            0:off  1:off  2:on   3:on   4:on   5:on   6:off
udev-post       0:off  1:on   2:on   3:on   4:on   5:on   6:off

不要なサービスの停止

$ service ip6tables stop
ip6tables: チェインをポリシー ACCEPT に設定中: filter      [  OK  ]
ip6tables: ファイアウォールルールを消去中:                 [  OK  ]
ip6tables: モジュールを取り外し中:                         [  OK  ]
$ service netfs stop
$ service postfix stop
postfix を停止中:                                          [  OK  ]

ログインの制限

sshから直接rootユーザにログインできなくする

以下のファイルを編集
/etc/ssh/sshd_config

#PermitRootLogin yes

PermitRootLogin no

に変更

sshのポートを変更

ウェルノウンポートのままだと攻撃を受けやすいため変更しておく

以下のファイルを編集
/etc/ssh/sshd_config

Port 22

Port 20022

に変更

併せてiptablesの設定も変更しておく

以下のファイルを変更
/etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 20022 -j ACCEPT

に変更

sshiptablesを再起動する

$ service sshd restart
$ service iptables restart

ネットワークの確認

余計なポートが開いていないか確認

$ netstat -atun
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 0.0.0.0:20022               0.0.0.0:*                   LISTEN      
tcp        0     48 192.168.100.251:20022       192.168.100.100:64595       ESTABLISHED 
tcp        0      0 :::20022                    :::*                        LISTEN      
udp        0      0 0.0.0.0:68                  0.0.0.0:*                        

ファイアウォールの設定を確認

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:20022 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

前回立てたサーバーはこれくらいのことしかしてなかった。

今回はもう少し突っ込んで、セキュリティ対策してみようと思う(するとは言っていない)

【CentOS6】インストール後に設定しておきたいこと

今更感溢れるCentOS6系の設定について

環境

前提

  • OSを最小構成にてインストールしていること

ネットワークインターフェースの自動起動

デフォルトの設定ではネットワークインターフェースが自動的に起動しないようになっている

自動起動するためには以下のファイルを書き換える

/etc/sysconfig/network-scripts/ifcfg-eth0

ONBOOT=yes # noをyesに変更

キーボード

インストール時ににキーボードの設定を誤ってしまったなど、キーボードの設定を変更したい場合、以下のファイルを書き換えると変更できる

/etc/sysconfig/keyboard

例)日本語配列にしたい場合の設定

KEYTABLE="jp106"
MODEL="jp106"
LAYOUT="jp"
KEYBOARDTYPE="pc"

参考:CentOSでキーボード設定が日本語じゃないときの対処法: m6 BLOG

システム時刻

# ntpdateのインストール
$ yum install ntpdate
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
#〜〜〜〜〜〜〜〜〜〜〜中略〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
インストール:
  ntpdate.x86_64 0:4.2.6p5-5.el6.centos.4                                       

完了しました!
# システム時刻の設定
$ ntpdate ntp.nict.jp
15 Feb 03:18:47 ntpdate[2539]: step time server 133.243.238.244 offset 471.270285 sec
# 確認
$ date
2016215日 月曜日 03:18:50 JST
# ついでにハードウェアクロックも修正
# システムクロックの時刻をハードウェアクロックに反映
$ hwclock -w
# 確認
$ hwclock -r
20160215031928秒  -0.609921 秒

cronで定期実行する場合(下記の例は毎月1日の0:00に実行)

0 0 1 * * /usr/sbin/ntpdate ntp.nict.jp > /dev/null 2>&1
0 0 1 * * /sbin/hwclock -w > /dev/null 2>&1

参考:LPIC Linux - システム時刻の維持

MeteorやっててClient IDの取得でハマった

環境

Meteor: 1.2.1

前提

Googleアカウントを持っていること

accounts-googleの実装

MeteorでGoogleのOAuthによるログインを実装するのはすごく簡単で、
以下の通りパッケージを追加して、コードを一行差し込むだけでできてしまう。

パッケージ追加

meteor add accounts-google accounts-ui

sample.html

<head>
  <title>test-meteor-pja</title>
</head>

<body>
  <h1>Welcome to Meteor!</h1>

  {{> loginButtons}}  <!-- add -->

  {{> hello}}
</body>

<template name="hello">
  <button>Click Me</button>
  <p>You've pressed the button {{counter}} times.</p>
</template>

アクセスするとご覧の通り

f:id:mktktmr:20160212231237p:plain

ただ、client IDの登録でハマります。

私のようなイングリッシュがプアな人間は特に。

ログインボタンを実装後、クリックするとClient IDの登録手順が示されるんですが、これが古いもののためのなのか、書いてあることと実際の画面が全然異なるのである。

f:id:mktktmr:20160212085747p:plain

というわけで、OAuth認証ができるようになるまでを説明していく。

1. Google Developers Consoleへアクセス

まずは「Google Developers Console」にアクセスする

https://console.developers.google.com/

f:id:mktktmr:20160212074024p:plain

2. プロジェクトの作成

はじめてGoogle Developers Consoleを利用する人はプロジェクトがないはずなので「Create project」からプロジェクトを作成する

f:id:mktktmr:20160210135939p:plain

f:id:mktktmr:20160210135942p:plain

3. OAuth consentの設定

プロジェクトが作成できたら、ダッシュボードがひらくので、 左上にあるハンバーガーアイコンをクリックし、メニューを開く

f:id:mktktmr:20160210135945p:plain

メニューのなかに「API Manager」という項目があるので選択する

f:id:mktktmr:20160210135949p:plain

API Managerページのメニューのなかに「Credentials」があるので選択し、開かれたページのタブのなかの「OAuth consent screen」を選択する f:id:mktktmr:20160210135953p:plain

メールアドレスとProduct nameを入力し、「save」ボタンをクリック

f:id:mktktmr:20160212234056p:plain

4. Credentialの作成

次に「Credentials」タブを選択し、「New Credentials」ボタンを押下する

f:id:mktktmr:20160210140000p:plain

すると、プルダウンが開き、そのなかに「OAuth Client ID」があるので選択する。

f:id:mktktmr:20160210140004p:plain

  1. Application type
    Web applicationを選択

  2. Name
    任意の名前を入力

  3. Authorized JavaScript origins
    http://localhost:3000

  4. Authorized redirect URIs
    http://localhost:3000/_oauth/google

以上を入力し、「Create」ボタンをクリック

f:id:mktktmr:20160212232948p:plain

すると「client ID」と「client secret」が発行される

f:id:mktktmr:20160210140031p:plain

5. 「client ID」および「client secret」の登録

手順4で発行された「client ID」および「client secret」をMeteorアプリケーションのOAuth設定のフォームに入力し、「Save Configration」をクリックする

f:id:mktktmr:20160212085252p:plain

↓のようになればおk

f:id:mktktmr:20160212233625p:plain

【React】とりあえず環境

Reactを弄る環境を整えてみる

環境

  • OS: OS X 10.10.5
  • React: 0.14.7
  • npm: 3.3.12

前提

  • npmがインストールされていること

参考

Getting Started | React

npmを使った方法

CommonJSのモジュールシステムとして「browserify」と「webpack」を使う方法があるが、今回はbrowserifyを利用する

※「browserify」とは

browserify をはじめてみる - Please Sleep

CommonJS のモジュールの仕組み、つまり Node.js の require をブラウザ上でも使えるようにするもの、ということでいいみたい。

公式:Browserify

browserifyのインストール

$ sudo npm install -g browserify
Password:
/usr/local/bin/browserify -> /usr/local/lib/node_modules/browserify/bin/cmd.js
/usr/local/lib
└─┬ browserify@13.0.0 
  ├── assert@1.3.0 
#〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜中略〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
  ├─┬ vm-browserify@0.0.4 
  │ └── indexof@0.0.1 
  └── xtend@4.0.1 

Reactのインストール

$ npm install --save react react-dom babelify babel-preset-react
npm WARN saveError ENOENT: no such file or directory, open '/path/package.json'
/path/Using_React_from_npm
├─┬ babel-preset-react@6.3.13 
│ ├─┬ babel-plugin-syntax-flow@6.3.13 
#〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜中略〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
│   └── whatwg-fetch@0.9.0 
└── react-dom@0.14.7 

npm WARN ENOENT ENOENT: no such file or directory, open '/path/Using_React_from_npm/package.json'
npm WARN EPACKAGEJSON Using_React_from_npm No description
npm WARN EPACKAGEJSON Using_React_from_npm No repository field.
npm WARN EPACKAGEJSON Using_React_from_npm No README data
npm WARN EPACKAGEJSON Using_React_from_npm No license field.

ワーニングは後で調べます。。。

サンプルソース

サンプルソースとして以下を用意する

helloworld.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
  </head>
  <body>
    <div id="example"></div>
    <script src="bundle.js"></script>
  </body>
</html>

main.js

var React = require('react');
var ReactDOM = require('react-dom');

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('example')
);

トランスパイル

main.jsをbundle.jsとしてトランスパイルする

$ browserify -t [ babelify --presets [ react ] ] main.js -o bundle.js

HTMLファイルを開いてみると

f:id:mktktmr:20160203160602p:plain

ちなみに最終的なディレクトリ構成以下です

Root/
├ bundle.js
├ helloworld.html
├ main.js
└ node_modules/

Error

ちょっとハマりました。。。

当初HTMLを以下のように書いていて

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
  </head>
  <body>
    <div id="example"></div>
    <script src="bundle.js"></script>
  </body>
</html>

↓こんなエラー出てました。。。

f:id:mktktmr:20160203161011p:plain

Invariant Violation: _registerComponent(...): Target container is not a DOM element.
invariantbundle.js:908
_registerComponentbundle.js:13104:165
_renderNewRootComponentbundle.js:13126
ReactMount__renderNewRootComponentbundle.js:14476
_renderSubtreeIntoContainerbundle.js:13206
renderbundle.js:13226
React_renderbundle.js:14476
(anonymous 関数)bundle.js:34
sbundle.js:16
ebundle.js:25
(anonymous 関数)bundle.js:27

javascript - Invariant Violation: _registerComponent(...): Target container is not a DOM element - Stack Overflow

上記のコードだと、スクリプトが読まれた時点では、バインドしたいDOMが生成されていなため、エラーをこいてしまうってことだと思う。

スクリプトを読み込む位置を変えずに、

<script async src="bundle.js"></script> <!-- add async -->

でもいけるが、スクリプトを読み込む位置を変える方がベターらしい

starter kitを使った方法

starter kitを利用するとnpmなしでもReactをできるよ!とのことでこちらも試してみる

starter kitのダウンロード

f:id:mktktmr:20160215171515p:plain

とりあえずHTMLに直書きでReactのコードを差し込む

以下HTMLファイルをダウンロードしてきたディレクトリ配下に置く

react-0.14.7/
┣ README.md
┣ build
┣ examples
helloworld.html

helloworld.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
    <script src="build/react.js"></script>
    <script src="build/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
  </head>
  <body>
    <div id="example"></div>
    <script type="text/babel">
      ReactDOM.render(
        <h1>Hello, world!</h1>,
        document.getElementById('example')
      );
    </script>
  </body>
</html>

helloworld.htmlを開いてみる

f:id:mktktmr:20160215173414p:plain

HTMLとjsファイルを分割してみる

以下jsファイルを追加

react-0.14.7/
┣ README.md
┣ build
┣ examples
┣ helloworld.html
┗ src/
    ┗ helloworld.js

ReactDOM.render(
  <h1>Hello, world!!</h1>,
  document.getElementById('example')
);

上記jsファイルを読み込むようHTMLを修正

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
    <script src="build/react.js"></script>
    <script src="build/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
  </head>
  <body>
    <div id="example"></div>
    <script type="text/babel" src="src/helloworld.js"></script> <!-- 修正 -->
  </body>
</html>

helloworld.htmlを開く

f:id:mktktmr:20160215175725p:plain

※ちなみに公式の説明にもある通りブラウザによっては直接HTMLファイルを開くとエラーが発生することがある

Note that some browsers (Chrome, e.g.) will fail to load the file unless it's served via HTTP.

Chromeで開くとこんな具合

f:id:mktktmr:20160215180504p:plain

そんな時はpythonのhttpモジュールを呼ぶと便利(最近知った)

# python -m SimpleHTTPServerと一行叩くだけでhttpseverが起動する。。。
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

んで、http://localhost:8000/helloworld.htmlにアクセスすると

f:id:mktktmr:20160215180847p:plain

オフラインでトランスパイル

Babelを利用することで、オフラインでもJavaScriptをトランスパイルできる

※「Babel」とは

Babelで始める!モダンJavaScript開発 | HTML5Experts.jp

ECMAScript2015 (ES6)やECMAScript7などで書かれたソースコードを一般的なブラウザがサポートしているECMAScript5の形式に出力することができます。

とりあえずbabelをインストール

npm install --global babel-cli
npm install babel-preset-react

_人人人人人人人人人人人人人_
> Quick Start Without npm <
 ̄Y^Y^Y^Y^Y^Y^Y^YY^Y^Y^ ̄

なんて銘打っておいてnpm使ってるじゃんっていうツッコミをしたくなるんですが、まあ、置いときます

ソースファイル修正

以下jsファイルを修正

src/helloworld.js

ReactDOM.render(
  React.createElement('h1', null, 'Hello, world!!!'),
  document.getElementById('example')
);

HTMLファイルも修正

src/helloworld.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
    <script src="build/react.js"></script>
    <script src="build/react-dom.js"></script>
    <!-- No need for Babel! -->
  </head>
  <body>
    <div id="example"></div>
    <script src="build/helloworld.js"></script>
  </body>
</html>

bable発動

# srcディレクトリを監視して、トランスパイルしたファイルをbuildディレクトリに出力する
$ babel --presets react src --watch --out-dir build
src/helloworld.js -> build/helloworld.js

ブラウザでhtmlファイルオープン

f:id:mktktmr:20160215185051p:plain

こんな感じで色々な方法でReactを利用できる

どれがベスト・ベターな方法なのかはこれから探っていく

個人的にはReactはWebフロントのJavaScriptフレームワークの中で一番注目している

また、WebだけでなくNativeアプリを向けのReact Nativeなんてのも開発中みたいで、これから先も楽しみなフレームワークです