Ruby on Rails のインストール手順を備忘録のためにまとめた記事にとなります。
手順にまとめてみると、やはり、Ruby on Railsの環境構築は大変だと思いました。
少しでも参考にしていただければと思います。
前提条件
SSHでの接続完了が前提
railsに必要なパッケージのインストール
railsの起動に必要なパッケージをインストールします。
1 |
sudo yum install -y gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel |
実行結果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
[oot@ip-xxx-xxx-xxx-xxx ~]# sudo yum install -y gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Existing lock /var/run/yum.pid: another copy is running as pid 7369. Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 148 M RSS (365 MB VSZ) Started: Mon Aug 23 05:26:36 2021 - 00:05 ago State : Running, pid: 7369 Package readline-6.2-10.amzn2.0.2.x86_64 already installed and latest version Package zlib-1.2.7-18.amzn2.x86_64 already installed and latest version Package libxml2-2.9.1-6.amzn2.5.4.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package gcc-c++.x86_64 0:7.3.1-13.amzn2 will be installed --> Processing Dependency: gcc(x86-64) = 7.3.1-13.amzn2 for package: gcc-c++-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-c++-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-c++-7.3.1-13.amzn2.x86_64 ---> Package glibc-headers.x86_64 0:2.26-48.amzn2 will be installed --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.26-48.amzn2.x86_64 --> Processing Dependency: kernel-headers for package: glibc-headers-2.26-48.amzn2.x86_64 ---> Package libffi-devel.x86_64 0:3.0.13-18.amzn2.0.2 will be installed ---> Package libxml2-devel.x86_64 0:2.9.1-6.amzn2.5.4 will be installed --> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.amzn2.5.4.x86_64 ---> Package libxslt.x86_64 0:1.1.28-6.amzn2 will be installed ---> Package libxslt-devel.x86_64 0:1.1.28-6.amzn2 will be installed --> Processing Dependency: libgcrypt-devel for package: libxslt-devel-1.1.28-6.amzn2.x86_64 ---> Package libyaml-devel.x86_64 0:0.1.4-11.amzn2.0.2 will be installed ---> Package openssl-devel.x86_64 1:1.0.2k-19.amzn2.0.7 will be installed --> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.amzn2.0.7.x86_64 ---> Package readline-devel.x86_64 0:6.2-10.amzn2.0.2 will be installed --> Processing Dependency: ncurses-devel for package: readline-devel-6.2-10.amzn2.0.2.x86_64 ---> Package sqlite-devel.x86_64 0:3.7.17-8.amzn2.1.1 will be installed ---> Package zlib-devel.x86_64 0:1.2.7-18.amzn2 will be installed --> Running transaction check ---> Package gcc.x86_64 0:7.3.1-13.amzn2 will be installed --> Processing Dependency: cpp = 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libsanitizer >= 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libquadmath >= 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libmpx >= 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libitm >= 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libcilkrts >= 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: libatomic >= 7.3.1-13.amzn2 for package: gcc-7.3.1-13.amzn2.x86_64 --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-7.3.1-13.amzn2.x86_64 ---> Package kernel-headers.x86_64 0:4.14.243-185.433.amzn2 will be installed ---> Package krb5-devel.x86_64 0:1.15.1-37.amzn2.2.2 will be installed --> Processing Dependency: libkadm5(x86-64) = 1.15.1-37.amzn2.2.2 for package: krb5-devel-1.15.1-37.amzn2.2.2.x86_64 --> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-37.amzn2.2.2.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-37.amzn2.2.2.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-37.amzn2.2.2.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-37.amzn2.2.2.x86_64 ---> Package libgcrypt-devel.x86_64 0:1.5.3-14.amzn2.0.2 will be installed --> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel-1.5.3-14.amzn2.0.2.x86_64 ---> Package libmpc.x86_64 0:1.0.1-3.amzn2.0.2 will be installed ---> Package mpfr.x86_64 0:3.1.1-4.amzn2.0.2 will be installed ---> Package ncurses-devel.x86_64 0:6.0-8.20170212.amzn2.1.3 will be installed --> Processing Dependency: ncurses-c++-libs(x86-64) = 6.0-8.20170212.amzn2.1.3 for package: ncurses-devel-6.0-8.20170212.amzn2.1.3.x86_64 --> Processing Dependency: libncurses++w.so.6()(64bit) for package: ncurses-devel-6.0-8.20170212.amzn2.1.3.x86_64 --> Processing Dependency: libncurses++.so.6()(64bit) for package: ncurses-devel-6.0-8.20170212.amzn2.1.3.x86_64 ---> Package xz-devel.x86_64 0:5.2.2-1.amzn2.0.2 will be installed --> Running transaction check ---> Package cpp.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package glibc-devel.x86_64 0:2.26-48.amzn2 will be installed ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.amzn2.0.2 will be installed ---> Package libatomic.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package libcilkrts.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package libcom_err-devel.x86_64 0:1.42.9-19.amzn2 will be installed ---> Package libgpg-error-devel.x86_64 0:1.12-3.amzn2.0.3 will be installed ---> Package libitm.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package libkadm5.x86_64 0:1.15.1-37.amzn2.2.2 will be installed ---> Package libmpx.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package libquadmath.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package libsanitizer.x86_64 0:7.3.1-13.amzn2 will be installed ---> Package libselinux-devel.x86_64 0:2.5-12.amzn2.0.2 will be installed --> Processing Dependency: libsepol-devel(x86-64) >= 2.5-6 for package: libselinux-devel-2.5-12.amzn2.0.2.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-12.amzn2.0.2.x86_64 --> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-12.amzn2.0.2.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.amzn2.0.2 will be installed ---> Package ncurses-c++-libs.x86_64 0:6.0-8.20170212.amzn2.1.3 will be installed --> Running transaction check ---> Package libsepol-devel.x86_64 0:2.5-8.1.amzn2.0.2 will be installed ---> Package pcre-devel.x86_64 0:8.32-17.amzn2.0.2 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================= Package Arch Version Repository Size ======================================================================================================================= Installing: gcc-c++ x86_64 7.3.1-13.amzn2 amzn2-core 13 M glibc-headers x86_64 2.26-48.amzn2 amzn2-core 512 k libffi-devel x86_64 3.0.13-18.amzn2.0.2 amzn2-core 23 k libxml2-devel x86_64 2.9.1-6.amzn2.5.4 amzn2-core 1.1 M libxslt x86_64 1.1.28-6.amzn2 amzn2-core 240 k libxslt-devel x86_64 1.1.28-6.amzn2 amzn2-core 309 k libyaml-devel x86_64 0.1.4-11.amzn2.0.2 amzn2-core 82 k openssl-devel x86_64 1:1.0.2k-19.amzn2.0.7 amzn2-core 1.5 M readline-devel x86_64 6.2-10.amzn2.0.2 amzn2-core 139 k sqlite-devel x86_64 3.7.17-8.amzn2.1.1 amzn2-core 105 k zlib-devel x86_64 1.2.7-18.amzn2 amzn2-core 50 k Installing for dependencies: cpp x86_64 7.3.1-13.amzn2 amzn2-core 9.2 M gcc x86_64 7.3.1-13.amzn2 amzn2-core 22 M glibc-devel x86_64 2.26-48.amzn2 amzn2-core 992 k kernel-headers x86_64 4.14.243-185.433.amzn2 amzn2-core 1.1 M keyutils-libs-devel x86_64 1.5.8-3.amzn2.0.2 amzn2-core 37 k krb5-devel x86_64 1.15.1-37.amzn2.2.2 amzn2-core 272 k libatomic x86_64 7.3.1-13.amzn2 amzn2-core 46 k libcilkrts x86_64 7.3.1-13.amzn2 amzn2-core 85 k libcom_err-devel x86_64 1.42.9-19.amzn2 amzn2-core 32 k libgcrypt-devel x86_64 1.5.3-14.amzn2.0.2 amzn2-core 129 k libgpg-error-devel x86_64 1.12-3.amzn2.0.3 amzn2-core 16 k libitm x86_64 7.3.1-13.amzn2 amzn2-core 84 k libkadm5 x86_64 1.15.1-37.amzn2.2.2 amzn2-core 179 k libmpc x86_64 1.0.1-3.amzn2.0.2 amzn2-core 52 k libmpx x86_64 7.3.1-13.amzn2 amzn2-core 51 k libquadmath x86_64 7.3.1-13.amzn2 amzn2-core 189 k libsanitizer x86_64 7.3.1-13.amzn2 amzn2-core 641 k libselinux-devel x86_64 2.5-12.amzn2.0.2 amzn2-core 187 k libsepol-devel x86_64 2.5-8.1.amzn2.0.2 amzn2-core 77 k libverto-devel x86_64 0.2.5-4.amzn2.0.2 amzn2-core 12 k mpfr x86_64 3.1.1-4.amzn2.0.2 amzn2-core 208 k ncurses-c++-libs x86_64 6.0-8.20170212.amzn2.1.3 amzn2-core 52 k ncurses-devel x86_64 6.0-8.20170212.amzn2.1.3 amzn2-core 502 k pcre-devel x86_64 8.32-17.amzn2.0.2 amzn2-core 480 k xz-devel x86_64 5.2.2-1.amzn2.0.2 amzn2-core 46 k Transaction Summary ======================================================================================================================= Install 11 Packages (+25 Dependent packages) Total download size: 53 M Installed size: 156 M Downloading packages: (1/36): cpp-7.3.1-13.amzn2.x86_64.rpm | 9.2 MB 00:00:00 (2/36): gcc-7.3.1-13.amzn2.x86_64.rpm | 22 MB 00:00:00 (3/36): gcc-c++-7.3.1-13.amzn2.x86_64.rpm | 13 MB 00:00:00 (4/36): glibc-devel-2.26-48.amzn2.x86_64.rpm | 992 kB 00:00:00 (5/36): glibc-headers-2.26-48.amzn2.x86_64.rpm | 512 kB 00:00:00 (6/36): keyutils-libs-devel-1.5.8-3.amzn2.0.2.x86_64.rpm | 37 kB 00:00:00 (7/36): kernel-headers-4.14.243-185.433.amzn2.x86_64.rpm | 1.1 MB 00:00:00 (8/36): krb5-devel-1.15.1-37.amzn2.2.2.x86_64.rpm | 272 kB 00:00:00 (9/36): libatomic-7.3.1-13.amzn2.x86_64.rpm | 46 kB 00:00:00 (10/36): libcilkrts-7.3.1-13.amzn2.x86_64.rpm | 85 kB 00:00:00 (11/36): libcom_err-devel-1.42.9-19.amzn2.x86_64.rpm | 32 kB 00:00:00 (12/36): libffi-devel-3.0.13-18.amzn2.0.2.x86_64.rpm | 23 kB 00:00:00 (13/36): libgcrypt-devel-1.5.3-14.amzn2.0.2.x86_64.rpm | 129 kB 00:00:00 (14/36): libgpg-error-devel-1.12-3.amzn2.0.3.x86_64.rpm | 16 kB 00:00:00 (15/36): libitm-7.3.1-13.amzn2.x86_64.rpm | 84 kB 00:00:00 (16/36): libkadm5-1.15.1-37.amzn2.2.2.x86_64.rpm | 179 kB 00:00:00 (17/36): libmpc-1.0.1-3.amzn2.0.2.x86_64.rpm | 52 kB 00:00:00 (18/36): libmpx-7.3.1-13.amzn2.x86_64.rpm | 51 kB 00:00:00 (19/36): libquadmath-7.3.1-13.amzn2.x86_64.rpm | 189 kB 00:00:00 (20/36): libsanitizer-7.3.1-13.amzn2.x86_64.rpm | 641 kB 00:00:00 (21/36): libselinux-devel-2.5-12.amzn2.0.2.x86_64.rpm | 187 kB 00:00:00 (22/36): libverto-devel-0.2.5-4.amzn2.0.2.x86_64.rpm | 12 kB 00:00:00 (23/36): libsepol-devel-2.5-8.1.amzn2.0.2.x86_64.rpm | 77 kB 00:00:00 (24/36): libxslt-1.1.28-6.amzn2.x86_64.rpm | 240 kB 00:00:00 (25/36): libxml2-devel-2.9.1-6.amzn2.5.4.x86_64.rpm | 1.1 MB 00:00:00 (26/36): libyaml-devel-0.1.4-11.amzn2.0.2.x86_64.rpm | 82 kB 00:00:00 (27/36): libxslt-devel-1.1.28-6.amzn2.x86_64.rpm | 309 kB 00:00:00 (28/36): ncurses-c++-libs-6.0-8.20170212.amzn2.1.3.x86_64.rpm | 52 kB 00:00:00 (29/36): mpfr-3.1.1-4.amzn2.0.2.x86_64.rpm | 208 kB 00:00:00 (30/36): ncurses-devel-6.0-8.20170212.amzn2.1.3.x86_64.rpm | 502 kB 00:00:00 (31/36): openssl-devel-1.0.2k-19.amzn2.0.7.x86_64.rpm | 1.5 MB 00:00:00 (32/36): pcre-devel-8.32-17.amzn2.0.2.x86_64.rpm | 480 kB 00:00:00 (33/36): readline-devel-6.2-10.amzn2.0.2.x86_64.rpm | 139 kB 00:00:00 (34/36): xz-devel-5.2.2-1.amzn2.0.2.x86_64.rpm | 46 kB 00:00:00 (35/36): sqlite-devel-3.7.17-8.amzn2.1.1.x86_64.rpm | 105 kB 00:00:00 (36/36): zlib-devel-1.2.7-18.amzn2.x86_64.rpm | 50 kB 00:00:00 ----------------------------------------------------------------------------------------------------------------------- Total 38 MB/s | 53 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mpfr-3.1.1-4.amzn2.0.2.x86_64 1/36 Installing : libmpc-1.0.1-3.amzn2.0.2.x86_64 2/36 Installing : zlib-devel-1.2.7-18.amzn2.x86_64 3/36 Installing : cpp-7.3.1-13.amzn2.x86_64 4/36 Installing : ncurses-c++-libs-6.0-8.20170212.amzn2.1.3.x86_64 5/36 Installing : ncurses-devel-6.0-8.20170212.amzn2.1.3.x86_64 6/36 Installing : libgpg-error-devel-1.12-3.amzn2.0.3.x86_64 7/36 Installing : libgcrypt-devel-1.5.3-14.amzn2.0.2.x86_64 8/36 Installing : libmpx-7.3.1-13.amzn2.x86_64 9/36 Installing : keyutils-libs-devel-1.5.8-3.amzn2.0.2.x86_64 10/36 Installing : libxslt-1.1.28-6.amzn2.x86_64 11/36 Installing : kernel-headers-4.14.243-185.433.amzn2.x86_64 12/36 Installing : glibc-headers-2.26-48.amzn2.x86_64 13/36 Installing : glibc-devel-2.26-48.amzn2.x86_64 14/36 Installing : pcre-devel-8.32-17.amzn2.0.2.x86_64 15/36 Installing : libatomic-7.3.1-13.amzn2.x86_64 16/36 Installing : libitm-7.3.1-13.amzn2.x86_64 17/36 Installing : libcilkrts-7.3.1-13.amzn2.x86_64 18/36 Installing : xz-devel-5.2.2-1.amzn2.0.2.x86_64 19/36 Installing : libxml2-devel-2.9.1-6.amzn2.5.4.x86_64 20/36 Installing : libverto-devel-0.2.5-4.amzn2.0.2.x86_64 21/36 Installing : libsepol-devel-2.5-8.1.amzn2.0.2.x86_64 22/36 Installing : libselinux-devel-2.5-12.amzn2.0.2.x86_64 23/36 Installing : libkadm5-1.15.1-37.amzn2.2.2.x86_64 24/36 Installing : libquadmath-7.3.1-13.amzn2.x86_64 25/36 Installing : libcom_err-devel-1.42.9-19.amzn2.x86_64 26/36 Installing : krb5-devel-1.15.1-37.amzn2.2.2.x86_64 27/36 Installing : libsanitizer-7.3.1-13.amzn2.x86_64 28/36 Installing : gcc-7.3.1-13.amzn2.x86_64 29/36 Installing : gcc-c++-7.3.1-13.amzn2.x86_64 30/36 Installing : 1:openssl-devel-1.0.2k-19.amzn2.0.7.x86_64 31/36 Installing : libxslt-devel-1.1.28-6.amzn2.x86_64 32/36 Installing : readline-devel-6.2-10.amzn2.0.2.x86_64 33/36 Installing : sqlite-devel-3.7.17-8.amzn2.1.1.x86_64 34/36 Installing : libffi-devel-3.0.13-18.amzn2.0.2.x86_64 35/36 Installing : libyaml-devel-0.1.4-11.amzn2.0.2.x86_64 36/36 Verifying : libsanitizer-7.3.1-13.amzn2.x86_64 1/36 Verifying : libgcrypt-devel-1.5.3-14.amzn2.0.2.x86_64 2/36 Verifying : libyaml-devel-0.1.4-11.amzn2.0.2.x86_64 3/36 Verifying : libmpc-1.0.1-3.amzn2.0.2.x86_64 4/36 Verifying : libcom_err-devel-1.42.9-19.amzn2.x86_64 5/36 Verifying : gcc-c++-7.3.1-13.amzn2.x86_64 6/36 Verifying : libxml2-devel-2.9.1-6.amzn2.5.4.x86_64 7/36 Verifying : libquadmath-7.3.1-13.amzn2.x86_64 8/36 Verifying : libkadm5-1.15.1-37.amzn2.2.2.x86_64 9/36 Verifying : cpp-7.3.1-13.amzn2.x86_64 10/36 Verifying : libsepol-devel-2.5-8.1.amzn2.0.2.x86_64 11/36 Verifying : libverto-devel-0.2.5-4.amzn2.0.2.x86_64 12/36 Verifying : zlib-devel-1.2.7-18.amzn2.x86_64 13/36 Verifying : libffi-devel-3.0.13-18.amzn2.0.2.x86_64 14/36 Verifying : mpfr-3.1.1-4.amzn2.0.2.x86_64 15/36 Verifying : xz-devel-5.2.2-1.amzn2.0.2.x86_64 16/36 Verifying : libselinux-devel-2.5-12.amzn2.0.2.x86_64 17/36 Verifying : ncurses-devel-6.0-8.20170212.amzn2.1.3.x86_64 18/36 Verifying : sqlite-devel-3.7.17-8.amzn2.1.1.x86_64 19/36 Verifying : 1:openssl-devel-1.0.2k-19.amzn2.0.7.x86_64 20/36 Verifying : libcilkrts-7.3.1-13.amzn2.x86_64 21/36 Verifying : krb5-devel-1.15.1-37.amzn2.2.2.x86_64 22/36 Verifying : readline-devel-6.2-10.amzn2.0.2.x86_64 23/36 Verifying : libitm-7.3.1-13.amzn2.x86_64 24/36 Verifying : glibc-devel-2.26-48.amzn2.x86_64 25/36 Verifying : libatomic-7.3.1-13.amzn2.x86_64 26/36 Verifying : glibc-headers-2.26-48.amzn2.x86_64 27/36 Verifying : pcre-devel-8.32-17.amzn2.0.2.x86_64 28/36 Verifying : kernel-headers-4.14.243-185.433.amzn2.x86_64 29/36 Verifying : gcc-7.3.1-13.amzn2.x86_64 30/36 Verifying : libxslt-1.1.28-6.amzn2.x86_64 31/36 Verifying : keyutils-libs-devel-1.5.8-3.amzn2.0.2.x86_64 32/36 Verifying : libxslt-devel-1.1.28-6.amzn2.x86_64 33/36 Verifying : libmpx-7.3.1-13.amzn2.x86_64 34/36 Verifying : libgpg-error-devel-1.12-3.amzn2.0.3.x86_64 35/36 Verifying : ncurses-c++-libs-6.0-8.20170212.amzn2.1.3.x86_64 36/36 Installed: gcc-c++.x86_64 0:7.3.1-13.amzn2 glibc-headers.x86_64 0:2.26-48.amzn2 libffi-devel.x86_64 0:3.0.13-18.amzn2.0.2 libxml2-devel.x86_64 0:2.9.1-6.amzn2.5.4 libxslt.x86_64 0:1.1.28-6.amzn2 libxslt-devel.x86_64 0:1.1.28-6.amzn2 libyaml-devel.x86_64 0:0.1.4-11.amzn2.0.2 openssl-devel.x86_64 1:1.0.2k-19.amzn2.0.7 readline-devel.x86_64 0:6.2-10.amzn2.0.2 sqlite-devel.x86_64 0:3.7.17-8.amzn2.1.1 zlib-devel.x86_64 0:1.2.7-18.amzn2 Dependency Installed: cpp.x86_64 0:7.3.1-13.amzn2 gcc.x86_64 0:7.3.1-13.amzn2 glibc-devel.x86_64 0:2.26-48.amzn2 kernel-headers.x86_64 0:4.14.243-185.433.amzn2 keyutils-libs-devel.x86_64 0:1.5.8-3.amzn2.0.2 krb5-devel.x86_64 0:1.15.1-37.amzn2.2.2 libatomic.x86_64 0:7.3.1-13.amzn2 libcilkrts.x86_64 0:7.3.1-13.amzn2 libcom_err-devel.x86_64 0:1.42.9-19.amzn2 libgcrypt-devel.x86_64 0:1.5.3-14.amzn2.0.2 libgpg-error-devel.x86_64 0:1.12-3.amzn2.0.3 libitm.x86_64 0:7.3.1-13.amzn2 libkadm5.x86_64 0:1.15.1-37.amzn2.2.2 libmpc.x86_64 0:1.0.1-3.amzn2.0.2 libmpx.x86_64 0:7.3.1-13.amzn2 libquadmath.x86_64 0:7.3.1-13.amzn2 libsanitizer.x86_64 0:7.3.1-13.amzn2 libselinux-devel.x86_64 0:2.5-12.amzn2.0.2 libsepol-devel.x86_64 0:2.5-8.1.amzn2.0.2 libverto-devel.x86_64 0:0.2.5-4.amzn2.0.2 mpfr.x86_64 0:3.1.1-4.amzn2.0.2 ncurses-c++-libs.x86_64 0:6.0-8.20170212.amzn2.1.3 ncurses-devel.x86_64 0:6.0-8.20170212.amzn2.1.3 pcre-devel.x86_64 0:8.32-17.amzn2.0.2 xz-devel.x86_64 0:5.2.2-1.amzn2.0.2 Complete! [roo@ip-xxx-xxx-xxx-xxx ~]# |
gitのインストール
1 |
sudo yum install -y git |
実行結果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
[roo@ip-xxx-xxx-xxx-xxx ~]# sudo yum install -y git Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 3.7 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package git.x86_64 0:2.32.0-1.amzn2.0.1 will be installed --> Processing Dependency: perl-Git = 2.32.0-1.amzn2.0.1 for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Processing Dependency: git-core-doc = 2.32.0-1.amzn2.0.1 for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Processing Dependency: git-core = 2.32.0-1.amzn2.0.1 for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Processing Dependency: emacs-filesystem >= 27.1 for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Processing Dependency: perl(Term::ReadKey) for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Processing Dependency: perl(Git::I18N) for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Processing Dependency: perl(Git) for package: git-2.32.0-1.amzn2.0.1.x86_64 --> Running transaction check ---> Package emacs-filesystem.noarch 1:27.2-4.amzn2.0.1 will be installed ---> Package git-core.x86_64 0:2.32.0-1.amzn2.0.1 will be installed ---> Package git-core-doc.noarch 0:2.32.0-1.amzn2.0.1 will be installed ---> Package perl-Git.noarch 0:2.32.0-1.amzn2.0.1 will be installed --> Processing Dependency: perl(Error) for package: perl-Git-2.32.0-1.amzn2.0.1.noarch ---> Package perl-TermReadKey.x86_64 0:2.30-20.amzn2.0.2 will be installed --> Running transaction check ---> Package perl-Error.noarch 1:0.17020-2.amzn2 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================= Package Arch Version Repository Size ======================================================================================================================= Installing: git x86_64 2.32.0-1.amzn2.0.1 amzn2-core 126 k Installing for dependencies: emacs-filesystem noarch 1:27.2-4.amzn2.0.1 amzn2-core 67 k git-core x86_64 2.32.0-1.amzn2.0.1 amzn2-core 4.8 M git-core-doc noarch 2.32.0-1.amzn2.0.1 amzn2-core 2.7 M perl-Error noarch 1:0.17020-2.amzn2 amzn2-core 32 k perl-Git noarch 2.32.0-1.amzn2.0.1 amzn2-core 43 k perl-TermReadKey x86_64 2.30-20.amzn2.0.2 amzn2-core 31 k Transaction Summary ======================================================================================================================= Install 1 Package (+6 Dependent packages) Total download size: 7.8 M Installed size: 38 M Downloading packages: (1/7): git-2.32.0-1.amzn2.0.1.x86_64.rpm | 126 kB 00:00:00 (2/7): emacs-filesystem-27.2-4.amzn2.0.1.noarch.rpm | 67 kB 00:00:00 (3/7): git-core-doc-2.32.0-1.amzn2.0.1.noarch.rpm | 2.7 MB 00:00:00 (4/7): git-core-2.32.0-1.amzn2.0.1.x86_64.rpm | 4.8 MB 00:00:00 (5/7): perl-Error-0.17020-2.amzn2.noarch.rpm | 32 kB 00:00:00 (6/7): perl-Git-2.32.0-1.amzn2.0.1.noarch.rpm | 43 kB 00:00:00 (7/7): perl-TermReadKey-2.30-20.amzn2.0.2.x86_64.rpm | 31 kB 00:00:00 ----------------------------------------------------------------------------------------------------------------------- Total 25 MB/s | 7.8 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : git-core-2.32.0-1.amzn2.0.1.x86_64 1/7 Installing : git-core-doc-2.32.0-1.amzn2.0.1.noarch 2/7 Installing : 1:perl-Error-0.17020-2.amzn2.noarch 3/7 Installing : 1:emacs-filesystem-27.2-4.amzn2.0.1.noarch 4/7 Installing : perl-TermReadKey-2.30-20.amzn2.0.2.x86_64 5/7 Installing : perl-Git-2.32.0-1.amzn2.0.1.noarch 6/7 Installing : git-2.32.0-1.amzn2.0.1.x86_64 7/7 Verifying : perl-TermReadKey-2.30-20.amzn2.0.2.x86_64 1/7 Verifying : git-core-doc-2.32.0-1.amzn2.0.1.noarch 2/7 Verifying : perl-Git-2.32.0-1.amzn2.0.1.noarch 3/7 Verifying : 1:emacs-filesystem-27.2-4.amzn2.0.1.noarch 4/7 Verifying : git-2.32.0-1.amzn2.0.1.x86_64 5/7 Verifying : git-core-2.32.0-1.amzn2.0.1.x86_64 6/7 Verifying : 1:perl-Error-0.17020-2.amzn2.noarch 7/7 Installed: git.x86_64 0:2.32.0-1.amzn2.0.1 Dependency Installed: emacs-filesystem.noarch 1:27.2-4.amzn2.0.1 git-core.x86_64 0:2.32.0-1.amzn2.0.1 git-core-doc.noarch 0:2.32.0-1.amzn2.0.1 perl-Error.noarch 1:0.17020-2.amzn2 perl-Git.noarch 0:2.32.0-1.amzn2.0.1 perl-TermReadKey.x86_64 0:2.30-20.amzn2.0.2 Complete! [roo@ip-xxx-xxx-xxx-xxx ~]# |
rbenvのインストール
rebenvは、rubyのバージョンを管理するツールです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[roo@ip-xxx-xxx-xxx-xxx ~]# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv Cloning into '/root/.rbenv'... remote: Enumerating objects: 2946, done. remote: Counting objects: 100% (50/50), done. remote: Compressing objects: 100% (39/39), done. remote: Total 2946 (delta 22), reused 22 (delta 11), pack-reused 2896 Receiving objects: 100% (2946/2946), 590.01 KiB | 1.38 MiB/s, done. Resolving deltas: 100% (1831/1831), done. [roo@ip-xxx-xxx-xxx-xxx ~]# 上記でだけでは、コマンド実行できないのでPATHを設定します。 [roo@ip-xxx-xxx-xxx-xxx ~]# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile [roo@ip-xxx-xxx-xxx-xxx ~]# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile [roo@ip-xxx-xxx-xxx-xxx ~]# source ~/.bash_profile |
ruby-buildのインストール
ruby-buildはrubyをインストールするためのrbenvプラグインです。
1 |
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build |
実行結果
1 2 3 4 5 6 7 8 9 10 11 |
[roo@ip-xxx-xxx-xxx-xxx ~]# git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build Cloning into '/root/.rbenv/plugins/ruby-build'... remote: Enumerating objects: 11732, done. remote: Counting objects: 100% (425/425), done. remote: Compressing objects: 100% (149/149), done. remote: Total 11732 (delta 275), reused 369 (delta 246), pack-reused 11307 Receiving objects: 100% (11732/11732), 2.47 MiB | 405.00 KiB/s, done. Resolving deltas: 100% (7742/7742), done. [roo@ip-xxx-xxx-xxx-xxx ~]# cd ~/.rbenv/plugins/ruby-build [roo@ip-xxx-xxx-xxx-xxx ruby-build]# sudo ./install.sh [roo@ip-xxx-xxx-xxx-xxx ruby-build]# |
rbenvの確認
1 2 |
[roo@ip-xxx-xxx-xxx-xxx ruby-build]# rbenv -v rbenv 1.1.2-61-g585ed84 |
rubyのインストール
rbenvでバージョン2.7.2をインストールします。
1 2 3 |
$ rbenv install -v 2.7.2 $ rbenv rehash $ rbenv global 2.7.2 |
バージョン確認
1 2 3 |
[roo@ip-xxx-xxx-xxx-xxx ruby-build]# ruby -v ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux] [roo@ip-xxx-xxx-xxx-xxx ruby-build]# |
bundlerのインストール
bundlerは、gemの依存関係とバージョンを管理するためのgemです。
gem同士の関係で問題が発生しないようにgemをインストールしたり、プロジェクトごとに分けることが可能です。
1 2 |
$ gem install bundle $ bundler -v |
実行結果
1 2 3 4 5 6 7 8 9 10 |
[roo@ip-xxx-xxx-xxx-xxx ruby-build]# gem install bundle Fetching bundle-0.0.1.gem Successfully installed bundle-0.0.1 Parsing documentation for bundle-0.0.1 Installing ri documentation for bundle-0.0.1 Done installing documentation for bundle after 0 seconds 1 gem installed [roo@ip-xxx-xxx-xxx-xxx ruby-build]# bundler -v Bundler version 2.1.4 [roo@ip-xxx-xxx-xxx-xxx ruby-build]# |
railsのインストール
1 |
$ gem install rails |
実行結果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
[roo@ip-xxx-xxx-xxx-xxx ruby-build]# gem install rails Fetching rack-test-1.1.0.gem Fetching activesupport-6.1.4.1.gem Fetching tzinfo-2.0.4.gem Fetching zeitwerk-2.4.2.gem Fetching rails-dom-testing-2.0.3.gem Fetching rack-2.2.3.gem Fetching crass-1.0.6.gem Fetching i18n-1.8.10.gem Fetching actionpack-6.1.4.1.gem Fetching loofah-2.12.0.gem Fetching rails-html-sanitizer-1.4.1.gem Fetching nokogiri-1.12.3-x86_64-linux.gem Fetching builder-3.2.4.gem Fetching activerecord-6.1.4.1.gem Fetching globalid-0.5.2.gem Fetching activemodel-6.1.4.1.gem Fetching erubi-1.10.0.gem Fetching actionview-6.1.4.1.gem Fetching concurrent-ruby-1.1.9.gem Fetching actionmailer-6.1.4.1.gem Fetching nio4r-2.5.8.gem Fetching mini_mime-1.1.1.gem Fetching mail-2.7.1.gem Fetching activejob-6.1.4.1.gem Fetching activestorage-6.1.4.1.gem Fetching actionmailbox-6.1.4.1.gem Fetching railties-6.1.4.1.gem Fetching actioncable-6.1.4.1.gem Fetching websocket-extensions-0.1.5.gem Fetching websocket-driver-0.7.5.gem Fetching marcel-1.0.1.gem Fetching thor-1.1.0.gem Fetching method_source-1.0.0.gem Fetching actiontext-6.1.4.1.gem Fetching sprockets-rails-3.2.2.gem Fetching rails-6.1.4.1.gem Fetching sprockets-4.0.2.gem Successfully installed concurrent-ruby-1.1.9 Successfully installed i18n-1.8.10 Successfully installed tzinfo-2.0.4 Successfully installed zeitwerk-2.4.2 Successfully installed activesupport-6.1.4.1 Successfully installed rack-2.2.3 Successfully installed rack-test-1.1.0 Successfully installed crass-1.0.6 Successfully installed nokogiri-1.12.3-x86_64-linux Successfully installed loofah-2.12.0 Successfully installed rails-html-sanitizer-1.4.1 Successfully installed rails-dom-testing-2.0.3 Successfully installed builder-3.2.4 Successfully installed erubi-1.10.0 Successfully installed actionview-6.1.4.1 Successfully installed actionpack-6.1.4.1 Successfully installed activemodel-6.1.4.1 Successfully installed activerecord-6.1.4.1 Successfully installed globalid-0.5.2 Successfully installed activejob-6.1.4.1 Successfully installed mini_mime-1.1.1 Successfully installed mail-2.7.1 Successfully installed actionmailer-6.1.4.1 Building native extensions. This could take a while... Successfully installed nio4r-2.5.8 Successfully installed websocket-extensions-0.1.5 Building native extensions. This could take a while... Successfully installed websocket-driver-0.7.5 Successfully installed actioncable-6.1.4.1 Successfully installed marcel-1.0.1 Successfully installed activestorage-6.1.4.1 Successfully installed actionmailbox-6.1.4.1 Successfully installed actiontext-6.1.4.1 Successfully installed thor-1.1.0 Successfully installed method_source-1.0.0 Successfully installed railties-6.1.4.1 Successfully installed sprockets-4.0.2 Successfully installed sprockets-rails-3.2.2 Successfully installed rails-6.1.4.1 Parsing documentation for concurrent-ruby-1.1.9 Installing ri documentation for concurrent-ruby-1.1.9 Parsing documentation for i18n-1.8.10 Installing ri documentation for i18n-1.8.10 Parsing documentation for tzinfo-2.0.4 Installing ri documentation for tzinfo-2.0.4 Parsing documentation for zeitwerk-2.4.2 Installing ri documentation for zeitwerk-2.4.2 Parsing documentation for activesupport-6.1.4.1 Installing ri documentation for activesupport-6.1.4.1 Parsing documentation for rack-2.2.3 Installing ri documentation for rack-2.2.3 Parsing documentation for rack-test-1.1.0 Installing ri documentation for rack-test-1.1.0 Parsing documentation for crass-1.0.6 Installing ri documentation for crass-1.0.6 Parsing documentation for nokogiri-1.12.3-x86_64-linux Installing ri documentation for nokogiri-1.12.3-x86_64-linux Parsing documentation for loofah-2.12.0 Installing ri documentation for loofah-2.12.0 Parsing documentation for rails-html-sanitizer-1.4.1 Installing ri documentation for rails-html-sanitizer-1.4.1 Parsing documentation for rails-dom-testing-2.0.3 Installing ri documentation for rails-dom-testing-2.0.3 Parsing documentation for builder-3.2.4 Installing ri documentation for builder-3.2.4 Parsing documentation for erubi-1.10.0 Installing ri documentation for erubi-1.10.0 Parsing documentation for actionview-6.1.4.1 Installing ri documentation for actionview-6.1.4.1 Parsing documentation for actionpack-6.1.4.1 Installing ri documentation for actionpack-6.1.4.1 Parsing documentation for activemodel-6.1.4.1 Installing ri documentation for activemodel-6.1.4.1 Parsing documentation for activerecord-6.1.4.1 Installing ri documentation for activerecord-6.1.4.1 Parsing documentation for globalid-0.5.2 Installing ri documentation for globalid-0.5.2 Parsing documentation for activejob-6.1.4.1 Installing ri documentation for activejob-6.1.4.1 Parsing documentation for mini_mime-1.1.1 Installing ri documentation for mini_mime-1.1.1 Parsing documentation for mail-2.7.1 Installing ri documentation for mail-2.7.1 Parsing documentation for actionmailer-6.1.4.1 Installing ri documentation for actionmailer-6.1.4.1 Parsing documentation for nio4r-2.5.8 Installing ri documentation for nio4r-2.5.8 Parsing documentation for websocket-extensions-0.1.5 Installing ri documentation for websocket-extensions-0.1.5 Parsing documentation for websocket-driver-0.7.5 Installing ri documentation for websocket-driver-0.7.5 Parsing documentation for actioncable-6.1.4.1 Installing ri documentation for actioncable-6.1.4.1 Parsing documentation for marcel-1.0.1 Installing ri documentation for marcel-1.0.1 Parsing documentation for activestorage-6.1.4.1 Installing ri documentation for activestorage-6.1.4.1 Parsing documentation for actionmailbox-6.1.4.1 Installing ri documentation for actionmailbox-6.1.4.1 Parsing documentation for actiontext-6.1.4.1 Installing ri documentation for actiontext-6.1.4.1 Parsing documentation for thor-1.1.0 Installing ri documentation for thor-1.1.0 Parsing documentation for method_source-1.0.0 Installing ri documentation for method_source-1.0.0 Parsing documentation for railties-6.1.4.1 Installing ri documentation for railties-6.1.4.1 Parsing documentation for sprockets-4.0.2 Installing ri documentation for sprockets-4.0.2 Parsing documentation for sprockets-rails-3.2.2 Installing ri documentation for sprockets-rails-3.2.2 Parsing documentation for rails-6.1.4.1 Installing ri documentation for rails-6.1.4.1 Done installing documentation for concurrent-ruby, i18n, tzinfo, zeitwerk, activesupport, rack, rack-test, crass, nokogiri, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, sprockets, sprockets-rails, rails after 57 seconds 37 gems installed [roo@ip-xxx-xxx-xxx-xxx ruby-build]# |
nvmのインストール
Node.jsが必要なのでnvmをインストールします。
nvmとは、rbenvのようなnodeのバージョンを切り替えれるツールです。
1 |
$ git clone https://github.com/creationix/nvm.git ~/.nvm |
実行結果
1 2 3 4 5 6 7 8 9 |
[roo@ip-xxx-xxx-xxx-xxx ruby-build]# git clone https://github.com/creationix/nvm.git ~/.nvm Cloning into '/root/.nvm'... remote: Enumerating objects: 8361, done. remote: Counting objects: 100% (162/162), done. remote: Compressing objects: 100% (95/95), done. remote: Total 8361 (delta 84), reused 131 (delta 62), pack-reused 8199 Receiving objects: 100% (8361/8361), 3.05 MiB | 15.64 MiB/s, done. Resolving deltas: 100% (5268/5268), done. [roo@ip-xxx-xxx-xxx-xxx ruby-build]# |
profile編集
1 |
[roo@ip-xxx-xxx-xxx-xxx ruby-build]# source ~/.nvm/nvm.sh |
次回から起動時に読み込まれるように .bash_profile を編集します。
1 |
$ vi .bash_profile |
以下を記述
1 2 3 |
if [ -f ~/.nvm/nvm.sh ]; then . ~/.nvm/nvm.sh fi |
Node.jsのインストール
nvmでNodeバージョン14.15.3をインストールします。
1 2 |
$ nvm install 14.15.3 $ node -v |
実行結果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[roo@ip-xxx-xxx-xxx-xxx ~]# nvm install 14.15.3 Downloading and installing node v14.15.3... Downloading https://nodejs.org/dist/v14.15.3/node-v14.15.3-linux-x64.tar.xz... ################################################################################################################ 100.0% Computing checksum with sha256sum Checksums matched! Now using node v14.15.3 (npm v6.14.9) Creating default alias: default -> 14.15.3 (-> v14.15.3) [roo@ip-xxx-xxx-xxx-xxx ~]# [roo@ip-xxx-xxx-xxx-xxx ~]# node -v v14.15.3 [roo@ip-xxx-xxx-xxx-xxx ~]# npm -v 6.14.9 |
yarnのインストール
Rails 6からwebpckerというものが必要になり、yarnのインストールが必要になりました。
webpackerとは簡単に言うと、webpackを使用してRails上でJavascript開発するために必要な一連のまとまりを、標準で実装できるgemパッケージです。
webpackとは、Webアプリケーションを構成するリソース(jsファイル、cssファイル、画像ファイル)を一つにまとめてくれるルーツです。
1 |
npm install yarn -g |
実行結果
1 2 3 4 5 6 7 8 9 10 11 12 |
[roo@ip-xxx-xxx-xxx-xxx ~]# npm install yarn -g > yarn@1.22.11 preinstall /root/.nvm/versions/node/v14.15.3/lib/node_modules/yarn > :; (node ./preinstall.js > /dev/null 2>&1 || true) /root/.nvm/versions/node/v14.15.3/bin/yarn -> /root/.nvm/versions/node/v14.15.3/lib/node_modules/yarn/bin/yarn.js /root/.nvm/versions/node/v14.15.3/bin/yarnpkg -> /root/.nvm/versions/node/v14.15.3/lib/node_modules/yarn/bin/yarn.js + yarn@1.22.11 added 1 package in 0.885s [roo@ip-xxx-xxx-xxx-xxx ~]# yarn -v 1.22.11 |
Railsの雛形アプリケーション「sample」の作成
1 2 3 4 |
$ sudo yum -y install mysql-devel $ rails new sample -d mysql --skip-turbolinks $ cd sample $ bundle install --path vender/bundle |
Railsサーバーの起動
環境構築が完了したところで、Railsサーバーを起動します。
1 |
# rails s -b 0.0.0.0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[roo@ip-xxx-xxx-xxx-xxx sample]# rails s -b 0.0.0.0 => Booting Puma => Rails 6.1.4.1 application starting in development => Run `bin/rails server --help` for more startup options Puma starting in single mode... * Puma version: 5.4.0 (ruby 2.7.2-p137) ("Super Flight") * Min threads: 5 * Max threads: 5 * Environment: development * PID: 24308 * Listening on http://0.0.0.0:3000 Use Ctrl-C to stop Started GET "/" for 157.65.116.11 at 2021-08-23 06:44:51 +0000 Cannot render console from 157.65.116.11! Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by Rails::WelcomeController#index as HTML Rendering vender/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/templates/rails/welcome/index.html.erb Rendered vender/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/templates/rails/welcome/index.html.erb (Duration: 10.3ms | Allocations: 333) Completed 200 OK in 19ms (Views: 12.0ms | ActiveRecord: 0.0ms | Allocations: 2744) |
接続確認
3000番ポートからインターネット接続します。
まずは、EC2インスタンスのセキュリティグループを編集します。
セキュリティーグループのインバウンドルールにルールを追加します。
・カスタム TCPを選択
・ポート範囲に3000を入力
・ソースに「0.0.0.0/0と::/0」を選択
下記の画面が表示されれば、インストール完了です。
データベースの作成
config/database.ymlをデータベース編で作成した認証情報とホストにエンドポイントを指定して、データベース設定をします。
1 2 3 4 5 6 7 8 9 |
... default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: "認証情報のユーザ名" password: "認証情報のパスワード" host: "RDSのエンドポイント" ... |
1 2 3 4 5 |
rails db:create [roo@ip-xxx-xxx-xxx-xxx sample]# rails db:create Created database 'sample_development' Created database 'sample_test' |
Nginxのインストール
1 |
$ sudo amazon-linux-extras install -y nginx1 |
実行結果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
[roo@ip-xxx-xxx-xxx-xxx sample]# sudo amazon-linux-extras install -y nginx1 Installing nginx Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Cleaning repos: amzn2-core amzn2extra-docker amzn2extra-nginx1 12 metadata files removed 4 sqlite files removed 0 metadata files removed Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 3.7 kB 00:00:00 amzn2extra-docker | 3.0 kB 00:00:00 amzn2extra-nginx1 | 3.0 kB 00:00:00 (1/7): amzn2-core/2/x86_64/group_gz | 2.5 kB 00:00:00 (2/7): amzn2-core/2/x86_64/updateinfo | 405 kB 00:00:00 (3/7): amzn2extra-nginx1/2/x86_64/primary_db | 36 kB 00:00:00 (4/7): amzn2extra-docker/2/x86_64/updateinfo | 76 B 00:00:00 (5/7): amzn2extra-nginx1/2/x86_64/updateinfo | 76 B 00:00:00 (6/7): amzn2extra-docker/2/x86_64/primary_db | 79 kB 00:00:00 (7/7): amzn2-core/2/x86_64/primary_db | 56 MB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.20.0-2.amzn2.0.3 will be installed --> Processing Dependency: nginx-filesystem = 1:1.20.0-2.amzn2.0.3 for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_1)(64bit) for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nginx-1.20.0-2.amzn2.0.3.x86_64 --> Running transaction check ---> Package gperftools-libs.x86_64 0:2.6.1-1.amzn2 will be installed ---> Package nginx-filesystem.noarch 1:1.20.0-2.amzn2.0.3 will be installed ---> Package openssl11-libs.x86_64 1:1.1.1g-12.amzn2.0.3 will be installed --> Processing Dependency: openssl11-pkcs11 for package: 1:openssl11-libs-1.1.1g-12.amzn2.0.3.x86_64 --> Running transaction check ---> Package openssl11-pkcs11.x86_64 0:0.4.10-6.amzn2.0.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================= Package Arch Version Repository Size ======================================================================================================================= Installing: nginx x86_64 1:1.20.0-2.amzn2.0.3 amzn2extra-nginx1 579 k Installing for dependencies: gperftools-libs x86_64 2.6.1-1.amzn2 amzn2-core 274 k nginx-filesystem noarch 1:1.20.0-2.amzn2.0.3 amzn2extra-nginx1 23 k openssl11-libs x86_64 1:1.1.1g-12.amzn2.0.3 amzn2-core 1.4 M openssl11-pkcs11 x86_64 0.4.10-6.amzn2.0.1 amzn2-core 61 k Transaction Summary ======================================================================================================================= Install 1 Package (+4 Dependent packages) Total download size: 2.3 M Installed size: 6.6 M Downloading packages: (1/5): nginx-filesystem-1.20.0-2.amzn2.0.3.noarch.rpm | 23 kB 00:00:00 (2/5): gperftools-libs-2.6.1-1.amzn2.x86_64.rpm | 274 kB 00:00:00 (3/5): nginx-1.20.0-2.amzn2.0.3.x86_64.rpm | 579 kB 00:00:00 (4/5): openssl11-pkcs11-0.4.10-6.amzn2.0.1.x86_64.rpm | 61 kB 00:00:00 (5/5): openssl11-libs-1.1.1g-12.amzn2.0.3.x86_64.rpm | 1.4 MB 00:00:00 ----------------------------------------------------------------------------------------------------------------------- Total 7.0 MB/s | 2.3 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:openssl11-libs-1.1.1g-12.amzn2.0.3.x86_64 1/5 Installing : openssl11-pkcs11-0.4.10-6.amzn2.0.1.x86_64 2/5 Installing : 1:nginx-filesystem-1.20.0-2.amzn2.0.3.noarch 3/5 Installing : gperftools-libs-2.6.1-1.amzn2.x86_64 4/5 Installing : 1:nginx-1.20.0-2.amzn2.0.3.x86_64 5/5 Verifying : openssl11-pkcs11-0.4.10-6.amzn2.0.1.x86_64 1/5 Verifying : gperftools-libs-2.6.1-1.amzn2.x86_64 2/5 Verifying : 1:nginx-filesystem-1.20.0-2.amzn2.0.3.noarch 3/5 Verifying : 1:nginx-1.20.0-2.amzn2.0.3.x86_64 4/5 Verifying : 1:openssl11-libs-1.1.1g-12.amzn2.0.3.x86_64 5/5 Installed: nginx.x86_64 1:1.20.0-2.amzn2.0.3 Dependency Installed: gperftools-libs.x86_64 0:2.6.1-1.amzn2 nginx-filesystem.noarch 1:1.20.0-2.amzn2.0.3 openssl11-libs.x86_64 1:1.1.1g-12.amzn2.0.3 openssl11-pkcs11.x86_64 0:0.4.10-6.amzn2.0.1 Complete! [roo@ip-xxx-xxx-xxx-xxx sample]# |
nginxのサービス登録
1 2 |
$ sudo systemctl start nginx.service $ sudo systemctl status nginx.service |
Nginxの起動確認
3000番ポート指定せずに、パブリックIPアドレスに接続します。
下記のNginxが表示されていれば完了です。
NginxからRailsに接続する
Nginxから接続するにはアプリケーションサーバーが必要となります。
一般的には、unicornというものを使用します。
unicornのインストール
Gemfileに下記の行を追加し、bundleインストールします。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
gem 'unicorn' $ bundle install ・・・略・・・ Fetching unicorn 6.0.0 Installing unicorn 6.0.0 with native extensions Using web-console 4.1.0 Using webdrivers 4.6.1 Using webpacker 5.4.2 Bundle complete! 17 Gemfile dependencies, 75 gems now installed. Bundled gems are installed into `./vender/bundle` [roo@ip-xxx-xxx-xxx-xxx sample]# |
unicornの設定ファイル作成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
vi config/unicorn.rb $worker = 2 $timeout = 30 $app_root = File.expand_path('../../', __FILE__) $listen = File.expand_path 'tmp/sockets/unicorn.sock', $app_root $pid = File.expand_path 'tmp/pids/unicorn.pid', $app_root $std_log = File.expand_path 'log/unicorn.log', $app_root worker_processes $worker working_directory $app_root stderr_path $std_log stdout_path $std_log timeout $timeout listen $listen pid $pid preload_app true before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin Process.kill "QUIT", File.read(old_pid).to_i rescue Errno::ENOENT, Errno::ESRCH end end end after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end |
Nginxの再起動
編集完了したらNginxの再起動をします。
$ sudo systemctl restart nginx.service
ポート指定せずにアクセスできれば、設定完了となります。