本記事では、AmazonEC2サーバーに、Laravelをインストール手順をまとめています。
前提条件として、AmazonEC2の環境構築が完了しているものとして解説していきます。
EC2サーバーの最新化
最初にEC2サーバーの最新化を実施します。
1 |
sudo yum update -y |
ローカライズ設定
ローカライズ設定を行います。
タイムゾーンは日本時間にセットします。
1 2 |
sysconfig/clock $sudo vim sysconfig/clock |
ZONE="Asia/Tokyo"
UTC=false
反映には再起動が必要なので、とりあえず日本時間にセットします。
1 |
$ sudo cp /usr/share/zoneinfo/Japan localtime |
日本語設定
1 2 |
sysconfig/i18n $ sudo vim sysconfig/i18n |
LANG=ja_JP.UTF-8
phpのインストール
本記事では、php7.3をインストールします。
1 |
$ sudo amazon-linux-extras install php7.3 |
一緒に必要なパッケージもインストールされます。
1 2 3 4 5 6 |
php-cli.x86_64 7.3.6-1.amzn2.0.1 @amzn2extra-php7.3 php-common.x86_64 7.3.6-1.amzn2.0.1 @amzn2extra-php7.3 php-fpm.x86_64 7.3.6-1.amzn2.0.1 @amzn2extra-php7.3 php-json.x86_64 7.3.6-1.amzn2.0.1 @amzn2extra-php7.3 php-mysqlnd.x86_64 7.3.6-1.amzn2.0.1 @amzn2extra-php7.3 php-pdo.x86_64 7.3.6-1.amzn2.0.1 @amzn2extra-php7.3 |
phpのインストール確認のために、バージョンを表示します。
1 2 3 4 5 6 |
$ php -v [ec2-user@ip-xxx-xxx-xxx-xxx ~]$ php -v PHP 7.3.29 (cli) (built: Jul 7 2021 17:34:15) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies |
php 拡張モジュールの確認
amazon-linux-extras でパッケージをインストールすると、拡張モジュールに関しては、yumを使って適切なパッケージをインストールしてくれます。
実際にインストール可能な拡張モジュールを確認します。
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 |
$ sudo yum list php* | grep php7.3 [ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo yum list php* | grep php7.3 php-cli.x86_64 7.3.29-1.amzn2 @amzn2extra-php7.3 php-common.x86_64 7.3.29-1.amzn2 @amzn2extra-php7.3 php-fpm.x86_64 7.3.29-1.amzn2 @amzn2extra-php7.3 php-json.x86_64 7.3.29-1.amzn2 @amzn2extra-php7.3 php-mysqlnd.x86_64 7.3.29-1.amzn2 @amzn2extra-php7.3 php-pdo.x86_64 7.3.29-1.amzn2 @amzn2extra-php7.3 php.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-bcmath.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-dba.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-dbg.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-devel.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-embedded.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-enchant.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-gd.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-gmp.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-intl.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-ldap.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-mbstring.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-odbc.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-opcache.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-pecl-apcu.x86_64 5.1.12-3.amzn2.0.2 amzn2extra-php7.3 php-pecl-apcu-devel.noarch 5.1.12-3.amzn2.0.2 amzn2extra-php7.3 php-pecl-igbinary.x86_64 2.0.7-3.amzn2.0.2 amzn2extra-php7.3 php-pecl-igbinary-devel.noarch 2.0.7-3.amzn2.0.2 amzn2extra-php7.3 php-pecl-imagick.x86_64 3.4.4-1.amzn2.0.4 amzn2extra-php7.3 php-pecl-imagick-devel.noarch 3.4.4-1.amzn2.0.4 amzn2extra-php7.3 php-pecl-libsodium.x86_64 2.0.21-1.amzn2.0.2 amzn2extra-php7.3 php-pecl-mailparse.x86_64 3.1.0-1.amzn2.0.1 amzn2extra-php7.3 php-pecl-mcrypt.x86_64 1.0.1-3.amzn2.0.2 amzn2extra-php7.3 php-pecl-memcached.x86_64 3.1.3-1.amzn2 amzn2extra-php7.3 php-pecl-msgpack.x86_64 2.0.3-1.amzn2 amzn2extra-php7.3 php-pecl-msgpack-devel.noarch 2.0.3-1.amzn2 amzn2extra-php7.3 php-pecl-oauth.x86_64 2.0.3-1.amzn2 amzn2extra-php7.3 php-pecl-redis.x86_64 4.3.0-1.amzn2.0.1 amzn2extra-php7.3 php-pecl-uuid.x86_64 1.0.4-3.amzn2.0.2 amzn2extra-php7.3 php-pecl-zip.x86_64 1.15.4-1.amzn2 amzn2extra-php7.3 php-pgsql.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-process.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-pspell.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-recode.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-snmp.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-soap.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-sodium.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-xml.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 php-xmlrpc.x86_64 7.3.29-1.amzn2 amzn2extra-php7.3 |
php-xmlのインストール
必要な拡張モジュールをインストールしていきます。
必要に応じて各自検討ください。
php-xmlは、Laravelインストール時に、phpunitのインストールに必要になるので、事前にインストールしておきます。
1 |
$sudo yum install php-mbstring php-pecl-memcached php-gd php-apcu php-xml |
apache2.4のインストール
次に、apache2.4をインストールします。
AmazonLinuxの場合は、2.4系を入れる場合は、httpd24 ですが、AmazonLinux2の場合は、httpd で、2.4系になるようです。
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 |
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo yum install httpd Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Resolving Dependencies ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: httpd x86_64 2.4.48-2.amzn2 amzn2-core 1.3 M Installing for dependencies: apr x86_64 1.6.3-5.amzn2.0.2 amzn2-core 118 k apr-util x86_64 1.6.1-5.amzn2.0.2 amzn2-core 99 k apr-util-bdb x86_64 1.6.1-5.amzn2.0.2 amzn2-core 19 k generic-logos-httpd noarch 18.0.0-4.amzn2 amzn2-core 19 k httpd-filesystem noarch 2.4.48-2.amzn2 amzn2-core 24 k httpd-tools x86_64 2.4.48-2.amzn2 amzn2-core 87 k mailcap noarch 2.1.41-2.amzn2 amzn2-core 31 k mod_http2 x86_64 1.15.19-1.amzn2.0.1 amzn2-core 149 k Transaction Summary ======================================================================================================================== Install 1 Package (+8 Dependent packages) Total download size: 1.9 M Installed size: 5.1 M Is this ok [y/d/N]: y Downloading packages: (1/9): apr-1.6.3-5.amzn2.0.2.x86_64.rpm | 118 kB 00:00:00 (2/9): apr-util-1.6.1-5.amzn2.0.2.x86_64.rpm | 99 kB 00:00:00 (3/9): generic-logos-httpd-18.0.0-4.amzn2.noarch.rpm | 19 kB 00:00:00 (4/9): apr-util-bdb-1.6.1-5.amzn2.0.2.x86_64.rpm | 19 kB 00:00:00 (5/9): httpd-filesystem-2.4.48-2.amzn2.noarch.rpm | 24 kB 00:00:00 (6/9): httpd-tools-2.4.48-2.amzn2.x86_64.rpm | 87 kB 00:00:00 (7/9): httpd-2.4.48-2.amzn2.x86_64.rpm | 1.3 MB 00:00:00 (8/9): mailcap-2.1.41-2.amzn2.noarch.rpm | 31 kB 00:00:00 (9/9): mod_http2-1.15.19-1.amzn2.0.1.x86_64.rpm | 149 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------ Total 6.7 MB/s | 1.9 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.6.3-5.amzn2.0.2.x86_64 1/9 Installing : apr-util-bdb-1.6.1-5.amzn2.0.2.x86_64 2/9 Installing : apr-util-1.6.1-5.amzn2.0.2.x86_64 3/9 Installing : httpd-tools-2.4.48-2.amzn2.x86_64 4/9 Installing : generic-logos-httpd-18.0.0-4.amzn2.noarch 5/9 Installing : mailcap-2.1.41-2.amzn2.noarch 6/9 Installing : httpd-filesystem-2.4.48-2.amzn2.noarch 7/9 Installing : mod_http2-1.15.19-1.amzn2.0.1.x86_64 8/9 Installing : httpd-2.4.48-2.amzn2.x86_64 9/9 Verifying : apr-util-1.6.1-5.amzn2.0.2.x86_64 1/9 Verifying : httpd-2.4.48-2.amzn2.x86_64 2/9 Verifying : apr-util-bdb-1.6.1-5.amzn2.0.2.x86_64 3/9 Verifying : httpd-filesystem-2.4.48-2.amzn2.noarch 4/9 Verifying : httpd-tools-2.4.48-2.amzn2.x86_64 5/9 Verifying : apr-1.6.3-5.amzn2.0.2.x86_64 6/9 Verifying : mailcap-2.1.41-2.amzn2.noarch 7/9 Verifying : generic-logos-httpd-18.0.0-4.amzn2.noarch 8/9 Verifying : mod_http2-1.15.19-1.amzn2.0.1.x86_64 9/9 Installed: httpd.x86_64 0:2.4.48-2.amzn2 Dependency Installed: apr.x86_64 0:1.6.3-5.amzn2.0.2 apr-util.x86_64 0:1.6.1-5.amzn2.0.2 apr-util-bdb.x86_64 0:1.6.1-5.amzn2.0.2 generic-logos-httpd.noarch 0:18.0.0-4.amzn2 httpd-filesystem.noarch 0:2.4.48-2.amzn2 httpd-tools.x86_64 0:2.4.48-2.amzn2 mailcap.noarch 0:2.1.41-2.amzn2 mod_http2.x86_64 0:1.15.19-1.amzn2.0.1 Complete! [ec2-user@ip-xxx-xxx-xxx-xxx ~]$ |
上記のように、Complete が表示されれば、インストール完了です。
apacheを起動します。
1 |
$ sudo systemctl start httpd |
コマンドを実行しても、コンソール上には何も出力されないので、実際に動いているかプロセスを確認します。
下記のコマンドで、active (running) とか表示されているはずです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ sudo systemctl status httpd [ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d mqphp-fpm.conf Active: active (running) since Tue 2021-08-24 09:57:36 JST; 9s ago Docs: man:httpd.service(8) Main PID: 7736 (httpd) Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec" CGroup: /system.slice/httpd.service tq7736 /usr/sbin/httpd -DFOREGROUND tq7742 /usr/sbin/httpd -DFOREGROUND tq7743 /usr/sbin/httpd -DFOREGROUND tq7744 /usr/sbin/httpd -DFOREGROUND tq7745 /usr/sbin/httpd -DFOREGROUND mq7746 /usr/sbin/httpd -DFOREGROUND Aug 24 09:57:36 ip-xxx-xxx-xxx-xxx.ap-northeast-1.compute.internal systemd[1]: Starting The Apache HTTP Server... Aug 24 09:57:36 ip-xxx-xxx-xxx-xxx.ap-northeast-1.compute.internal systemd[1]: Started The Apache HTTP Server. |
phpの変更と再起動
PHPの設定は、 php.ini で行います。
必要に応じて変更します。
1 2 3 4 |
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Asia/Tokyo |
モジュール版のPHPの場合、通常httpdを再起動すると、php.iniの内容が反映されます。
しかしながら、AmazonLinux2で、PHP7.3とhttpd2.4を構築した場合、デフォルトでSever APIが FPM/FastCGI となるため、httpdでは、php.iniの設定が反映されず、php-fpmの再起動が必要となります。
1 |
$ sudo systemctl restart php-fpm |
Composerのインストール
最初に、phpのモジュール管理をするために、Composerをインストールします。
1 2 3 4 5 6 7 8 |
curl -sS https://getcomposer.org/installer | php [ec2-user@ip-xxx-xxx-xxx-xxx ~]$ curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 2.1.6) successfully installed to: /home/ec2-user/composer.phar Use it: php composer.phar |
composer.phar がダウンロードされるので、composer のコマンドで実行できるように、PATHが通っている場所へ移動させます。
1 |
sudo mv composer.phar /usr/local/bin/composer |
上記の手順で composer が利用できるようになったので、Laravelをインストールします。
今回の例では、/var/www/html にインストールしていきます。
1 2 |
$ cd /var/www/html $ composer create-project --prefer-dist laravel/laravel app |
インストール結果
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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
[ec2-user@ip-xxx-xxx-xxx-xxx html]$ /usr/local/bin/composer create-project --prefer-dist laravel/laravel app Creating a "laravel/laravel" project at "./app" Installing laravel/laravel (v8.6.0) - Downloading laravel/laravel (v8.6.0) - Installing laravel/laravel (v8.6.0): Extracting archive Created project in /var/www/html/app > @php -r "file_exists('.env') || copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies Lock file operations: 106 installs, 0 updates, 0 removals - Locking asm89/stack-cors (v2.0.3) - Locking brick/math (0.9.3) - Locking doctrine/inflector (2.0.3) - Locking doctrine/instantiator (1.4.0) - Locking doctrine/lexer (1.2.1) - Locking dragonmantank/cron-expression (v3.1.0) - Locking egulias/email-validator (2.1.25) - Locking facade/flare-client-php (1.8.1) - Locking facade/ignition (2.11.4) - Locking facade/ignition-contracts (1.0.2) - Locking fakerphp/faker (v1.15.0) - Locking filp/whoops (2.14.0) - Locking fruitcake/laravel-cors (v2.0.4) - Locking graham-campbell/result-type (v1.0.1) - Locking guzzlehttp/guzzle (7.3.0) - Locking guzzlehttp/promises (1.4.1) - Locking guzzlehttp/psr7 (2.0.0) - Locking hamcrest/hamcrest-php (v2.0.1) - Locking laravel/framework (v8.55.0) - Locking laravel/sail (v1.10.0) - Locking laravel/sanctum (v2.11.2) - Locking laravel/tinker (v2.6.1) - Locking league/commonmark (1.6.6) - Locking league/flysystem (1.1.5) - Locking league/mime-type-detection (1.7.0) - Locking mockery/mockery (1.4.3) - Locking monolog/monolog (2.3.2) - Locking myclabs/deep-copy (1.10.2) - Locking nesbot/carbon (2.52.0) - Locking nikic/php-parser (v4.12.0) - Locking nunomaduro/collision (v5.8.0) - Locking opis/closure (3.6.2) - Locking phar-io/manifest (2.0.3) - Locking phar-io/version (3.1.0) - Locking phpdocumentor/reflection-common (2.2.0) - Locking phpdocumentor/reflection-docblock (5.2.2) - Locking phpdocumentor/type-resolver (1.4.0) - Locking phpoption/phpoption (1.7.5) - Locking phpspec/prophecy (1.13.0) - Locking phpunit/php-code-coverage (9.2.6) - Locking phpunit/php-file-iterator (3.0.5) - Locking phpunit/php-invoker (3.1.1) - Locking phpunit/php-text-template (2.0.4) - Locking phpunit/php-timer (5.0.3) - Locking phpunit/phpunit (9.5.8) - Locking psr/container (1.1.1) - Locking psr/event-dispatcher (1.0.0) - Locking psr/http-client (1.0.1) - Locking psr/http-factory (1.0.1) - Locking psr/http-message (1.0.1) - Locking psr/log (1.1.4) - Locking psr/simple-cache (1.0.1) - Locking psy/psysh (v0.10.8) - Locking ralouphie/getallheaders (3.0.3) - Locking ramsey/collection (1.2.1) - Locking ramsey/uuid (4.2.1) - Locking sebastian/cli-parser (1.0.1) - Locking sebastian/code-unit (1.0.8) - Locking sebastian/code-unit-reverse-lookup (2.0.3) - Locking sebastian/comparator (4.0.6) - Locking sebastian/complexity (2.0.2) - Locking sebastian/diff (4.0.4) - Locking sebastian/environment (5.1.3) - Locking sebastian/exporter (4.0.3) - Locking sebastian/global-state (5.0.3) - Locking sebastian/lines-of-code (1.0.3) - Locking sebastian/object-enumerator (4.0.4) - Locking sebastian/object-reflector (2.0.4) - Locking sebastian/recursion-context (4.0.4) - Locking sebastian/resource-operations (3.0.3) - Locking sebastian/type (2.3.4) - Locking sebastian/version (3.0.2) - Locking swiftmailer/swiftmailer (v6.2.7) - Locking symfony/console (v5.3.6) - Locking symfony/css-selector (v5.3.4) - Locking symfony/deprecation-contracts (v2.4.0) - Locking symfony/error-handler (v5.3.4) - Locking symfony/event-dispatcher (v5.3.4) - Locking symfony/event-dispatcher-contracts (v2.4.0) - Locking symfony/finder (v5.3.4) - Locking symfony/http-client-contracts (v2.4.0) - Locking symfony/http-foundation (v5.3.6) - Locking symfony/http-kernel (v5.3.6) - Locking symfony/mime (v5.3.4) - Locking symfony/polyfill-ctype (v1.23.0) - Locking symfony/polyfill-iconv (v1.23.0) - Locking symfony/polyfill-intl-grapheme (v1.23.1) - Locking symfony/polyfill-intl-idn (v1.23.0) - Locking symfony/polyfill-intl-normalizer (v1.23.0) - Locking symfony/polyfill-mbstring (v1.23.1) - Locking symfony/polyfill-php72 (v1.23.0) - Locking symfony/polyfill-php73 (v1.23.0) - Locking symfony/polyfill-php80 (v1.23.1) - Locking symfony/polyfill-php81 (v1.23.0) - Locking symfony/process (v5.3.4) - Locking symfony/routing (v5.3.4) - Locking symfony/service-contracts (v2.4.0) - Locking symfony/string (v5.3.3) - Locking symfony/translation (v5.3.4) - Locking symfony/translation-contracts (v2.4.0) - Locking symfony/var-dumper (v5.3.6) - Locking theseer/tokenizer (1.2.1) - Locking tijsverkoyen/css-to-inline-styles (2.2.3) - Locking vlucas/phpdotenv (v5.3.0) - Locking voku/portable-ascii (1.5.6) - Locking webmozart/assert (1.10.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 106 installs, 0 updates, 0 removals - Downloading doctrine/inflector (2.0.3) - Downloading doctrine/lexer (1.2.1) - Downloading symfony/polyfill-ctype (v1.23.0) - Downloading webmozart/assert (1.10.0) - Downloading dragonmantank/cron-expression (v3.1.0) - Downloading symfony/polyfill-php80 (v1.23.1) - Downloading symfony/polyfill-mbstring (v1.23.1) - Downloading symfony/var-dumper (v5.3.6) - Downloading symfony/polyfill-intl-normalizer (v1.23.0) - Downloading symfony/polyfill-intl-grapheme (v1.23.1) - Downloading symfony/string (v5.3.3) - Downloading psr/container (1.1.1) - Downloading symfony/service-contracts (v2.4.0) - Downloading symfony/polyfill-php73 (v1.23.0) - Downloading symfony/deprecation-contracts (v2.4.0) - Downloading symfony/console (v5.3.6) - Downloading psr/log (1.1.4) - Downloading monolog/monolog (2.3.2) - Downloading voku/portable-ascii (1.5.6) - Downloading phpoption/phpoption (1.7.5) - Downloading graham-campbell/result-type (v1.0.1) - Downloading vlucas/phpdotenv (v5.3.0) - Downloading symfony/css-selector (v5.3.4) - Downloading tijsverkoyen/css-to-inline-styles (2.2.3) - Downloading symfony/routing (v5.3.4) - Downloading symfony/process (v5.3.4) - Downloading symfony/polyfill-php72 (v1.23.0) - Downloading symfony/polyfill-intl-idn (v1.23.0) - Downloading symfony/mime (v5.3.4) - Downloading symfony/http-foundation (v5.3.6) - Downloading symfony/http-client-contracts (v2.4.0) - Downloading psr/event-dispatcher (1.0.0) - Downloading symfony/event-dispatcher-contracts (v2.4.0) - Downloading symfony/event-dispatcher (v5.3.4) - Downloading symfony/error-handler (v5.3.4) - Downloading symfony/http-kernel (v5.3.6) - Downloading symfony/finder (v5.3.4) - Downloading symfony/polyfill-iconv (v1.23.0) - Downloading egulias/email-validator (2.1.25) - Downloading swiftmailer/swiftmailer (v6.2.7) - Downloading symfony/polyfill-php81 (v1.23.0) - Downloading ramsey/collection (1.2.1) - Downloading brick/math (0.9.3) - Downloading ramsey/uuid (4.2.1) - Downloading psr/simple-cache (1.0.1) - Downloading opis/closure (3.6.2) - Downloading symfony/translation-contracts (v2.4.0) - Downloading symfony/translation (v5.3.4) - Downloading nesbot/carbon (2.52.0) - Downloading league/mime-type-detection (1.7.0) - Downloading league/flysystem (1.1.5) - Downloading league/commonmark (1.6.6) - Downloading laravel/framework (v8.55.0) - Downloading facade/ignition-contracts (1.0.2) - Downloading facade/flare-client-php (1.8.1) - Downloading facade/ignition (2.11.4) - Downloading fakerphp/faker (v1.15.0) - Downloading asm89/stack-cors (v2.0.3) - Downloading fruitcake/laravel-cors (v2.0.4) - Downloading psr/http-message (1.0.1) - Downloading psr/http-client (1.0.1) - Downloading ralouphie/getallheaders (3.0.3) - Downloading psr/http-factory (1.0.1) - Downloading guzzlehttp/psr7 (2.0.0) - Downloading guzzlehttp/promises (1.4.1) - Downloading guzzlehttp/guzzle (7.3.0) - Downloading laravel/sail (v1.10.0) - Downloading laravel/sanctum (v2.11.2) - Downloading nikic/php-parser (v4.12.0) - Downloading psy/psysh (v0.10.8) - Downloading laravel/tinker (v2.6.1) - Downloading hamcrest/hamcrest-php (v2.0.1) - Downloading mockery/mockery (1.4.3) - Downloading filp/whoops (2.14.0) - Downloading nunomaduro/collision (v5.8.0) - Downloading phpdocumentor/reflection-common (2.2.0) - Downloading phpdocumentor/type-resolver (1.4.0) - Downloading phpdocumentor/reflection-docblock (5.2.2) - Downloading sebastian/version (3.0.2) - Downloading sebastian/type (2.3.4) - Downloading sebastian/resource-operations (3.0.3) - Downloading sebastian/recursion-context (4.0.4) - Downloading sebastian/object-reflector (2.0.4) - Downloading sebastian/object-enumerator (4.0.4) - Downloading sebastian/global-state (5.0.3) - Downloading sebastian/exporter (4.0.3) - Downloading sebastian/environment (5.1.3) - Downloading sebastian/diff (4.0.4) - Downloading sebastian/comparator (4.0.6) - Downloading sebastian/code-unit (1.0.8) - Downloading sebastian/cli-parser (1.0.1) - Downloading phpunit/php-timer (5.0.3) - Downloading phpunit/php-text-template (2.0.4) - Downloading phpunit/php-invoker (3.1.1) - Downloading phpunit/php-file-iterator (3.0.5) - Downloading theseer/tokenizer (1.2.1) - Downloading sebastian/lines-of-code (1.0.3) - Downloading sebastian/complexity (2.0.2) - Downloading sebastian/code-unit-reverse-lookup (2.0.3) - Downloading phpunit/php-code-coverage (9.2.6) - Downloading doctrine/instantiator (1.4.0) - Downloading phpspec/prophecy (1.13.0) - Downloading phar-io/version (3.1.0) - Downloading phar-io/manifest (2.0.3) - Downloading myclabs/deep-copy (1.10.2) - Downloading phpunit/phpunit (9.5.8) - Installing doctrine/inflector (2.0.3): Extracting archive - Installing doctrine/lexer (1.2.1): Extracting archive - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive - Installing webmozart/assert (1.10.0): Extracting archive - Installing dragonmantank/cron-expression (v3.1.0): Extracting archive - Installing symfony/polyfill-php80 (v1.23.1): Extracting archive - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive - Installing symfony/var-dumper (v5.3.6): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive - Installing symfony/string (v5.3.3): Extracting archive - Installing psr/container (1.1.1): Extracting archive - Installing symfony/service-contracts (v2.4.0): Extracting archive - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive - Installing symfony/deprecation-contracts (v2.4.0): Extracting archive - Installing symfony/console (v5.3.6): Extracting archive - Installing psr/log (1.1.4): Extracting archive - Installing monolog/monolog (2.3.2): Extracting archive - Installing voku/portable-ascii (1.5.6): Extracting archive - Installing phpoption/phpoption (1.7.5): Extracting archive - Installing graham-campbell/result-type (v1.0.1): Extracting archive - Installing vlucas/phpdotenv (v5.3.0): Extracting archive - Installing symfony/css-selector (v5.3.4): Extracting archive - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Extracting archive - Installing symfony/routing (v5.3.4): Extracting archive - Installing symfony/process (v5.3.4): Extracting archive - Installing symfony/polyfill-php72 (v1.23.0): Extracting archive - Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive - Installing symfony/mime (v5.3.4): Extracting archive - Installing symfony/http-foundation (v5.3.6): Extracting archive - Installing symfony/http-client-contracts (v2.4.0): Extracting archive - Installing psr/event-dispatcher (1.0.0): Extracting archive - Installing symfony/event-dispatcher-contracts (v2.4.0): Extracting archive - Installing symfony/event-dispatcher (v5.3.4): Extracting archive - Installing symfony/error-handler (v5.3.4): Extracting archive - Installing symfony/http-kernel (v5.3.6): Extracting archive - Installing symfony/finder (v5.3.4): Extracting archive - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive - Installing egulias/email-validator (2.1.25): Extracting archive - Installing swiftmailer/swiftmailer (v6.2.7): Extracting archive - Installing symfony/polyfill-php81 (v1.23.0): Extracting archive - Installing ramsey/collection (1.2.1): Extracting archive - Installing brick/math (0.9.3): Extracting archive - Installing ramsey/uuid (4.2.1): Extracting archive - Installing psr/simple-cache (1.0.1): Extracting archive - Installing opis/closure (3.6.2): Extracting archive - Installing symfony/translation-contracts (v2.4.0): Extracting archive - Installing symfony/translation (v5.3.4): Extracting archive - Installing nesbot/carbon (2.52.0): Extracting archive - Installing league/mime-type-detection (1.7.0): Extracting archive - Installing league/flysystem (1.1.5): Extracting archive - Installing league/commonmark (1.6.6): Extracting archive - Installing laravel/framework (v8.55.0): Extracting archive - Installing facade/ignition-contracts (1.0.2): Extracting archive - Installing facade/flare-client-php (1.8.1): Extracting archive - Installing facade/ignition (2.11.4): Extracting archive - Installing fakerphp/faker (v1.15.0): Extracting archive - Installing asm89/stack-cors (v2.0.3): Extracting archive - Installing fruitcake/laravel-cors (v2.0.4): Extracting archive - Installing psr/http-message (1.0.1): Extracting archive - Installing psr/http-client (1.0.1): Extracting archive - Installing ralouphie/getallheaders (3.0.3): Extracting archive - Installing psr/http-factory (1.0.1): Extracting archive - Installing guzzlehttp/psr7 (2.0.0): Extracting archive - Installing guzzlehttp/promises (1.4.1): Extracting archive - Installing guzzlehttp/guzzle (7.3.0): Extracting archive - Installing laravel/sail (v1.10.0): Extracting archive - Installing laravel/sanctum (v2.11.2): Extracting archive - Installing nikic/php-parser (v4.12.0): Extracting archive - Installing psy/psysh (v0.10.8): Extracting archive - Installing laravel/tinker (v2.6.1): Extracting archive - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive - Installing mockery/mockery (1.4.3): Extracting archive - Installing filp/whoops (2.14.0): Extracting archive - Installing nunomaduro/collision (v5.8.0): Extracting archive - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive - Installing phpdocumentor/type-resolver (1.4.0): Extracting archive - Installing phpdocumentor/reflection-docblock (5.2.2): Extracting archive - Installing sebastian/version (3.0.2): Extracting archive - Installing sebastian/type (2.3.4): Extracting archive - Installing sebastian/resource-operations (3.0.3): Extracting archive - Installing sebastian/recursion-context (4.0.4): Extracting archive - Installing sebastian/object-reflector (2.0.4): Extracting archive - Installing sebastian/object-enumerator (4.0.4): Extracting archive - Installing sebastian/global-state (5.0.3): Extracting archive - Installing sebastian/exporter (4.0.3): Extracting archive - Installing sebastian/environment (5.1.3): Extracting archive - Installing sebastian/diff (4.0.4): Extracting archive - Installing sebastian/comparator (4.0.6): Extracting archive - Installing sebastian/code-unit (1.0.8): Extracting archive - Installing sebastian/cli-parser (1.0.1): Extracting archive - Installing phpunit/php-timer (5.0.3): Extracting archive - Installing phpunit/php-text-template (2.0.4): Extracting archive - Installing phpunit/php-invoker (3.1.1): Extracting archive - Installing phpunit/php-file-iterator (3.0.5): Extracting archive - Installing theseer/tokenizer (1.2.1): Extracting archive - Installing sebastian/lines-of-code (1.0.3): Extracting archive - Installing sebastian/complexity (2.0.2): Extracting archive - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive - Installing phpunit/php-code-coverage (9.2.6): Extracting archive - Installing doctrine/instantiator (1.4.0): Extracting archive - Installing phpspec/prophecy (1.13.0): Extracting archive - Installing phar-io/version (3.1.0): Extracting archive - Installing phar-io/manifest (2.0.3): Extracting archive - Installing myclabs/deep-copy (1.10.2): Extracting archive - Installing phpunit/phpunit (9.5.8): Extracting archive 75 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: facade/ignition Discovered Package: fruitcake/laravel-cors Discovered Package: laravel/sail Discovered Package: laravel/sanctum Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. 75 packages you are using are looking for funding. Use the `composer fund` command to find out more! > @php artisan vendor:publish --tag=laravel-assets --ansi No publishable resources for tag [laravel-assets]. Publishing complete. > @php artisan key:generate --ansi Application key set successfully. [ec2-user@ip-xxx-xxx-xxx-xxx html]$ |
Laravelの各種設定
次に、Laravelのドキュメントに記載がある通りに設定をしていきます。
1 2 3 4 5 |
$ cd /var/www/html/app $ composer update $ chmod -R 777 bootstrap/cache $ chmod -R 777 storage $ php artisan key:generate |
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 |
[ec2-user@ip-xxx-xxx-xxx-xxx app]$ /usr/local/bin/composer update Loading composer repositories with package information Updating dependencies Nothing to modify in lock file Installing dependencies from lock file (including require-dev) Nothing to install, update or remove Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: facade/ignition Discovered Package: fruitcake/laravel-cors Discovered Package: laravel/sail Discovered Package: laravel/sanctum Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. 75 packages you are using are looking for funding. Use the `composer fund` command to find out more! > @php artisan vendor:publish --tag=laravel-assets --ansi No publishable resources for tag [laravel-assets]. Publishing complete. [ec2-user@ip-xxx-xxx-xxx-xxx app]$ [ec2-user@ip-xxx-xxx-xxx-xxx app]$ chmod -R 777 bootstrap/cache [ec2-user@ip-xxx-xxx-xxx-xxx app]$ chmod -R 777 storage [ec2-user@ip-xxx-xxx-xxx-xxx app]$ php artisan key:generate Application key set successfully. |
Apache VirtualHost 設定
最後に、ApacheのVirtualHost設定を行います。
Virtual Hostの記述は、自動で設定が読み込まれる httpd/conf.d 配下にファイルを作成して記述します。
ファイル名は任意ですが、vhost.confで作成します。
今回のドメイン名は、hogehoge.com を仮定しています。適宜変更ください。
1 2 3 |
$ sudo su - # cd httpd/conf.d # vim vhost.conf |
今回のドメイン名は、hogehoge.com を仮定しています。適宜変更ください。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
vhost.conf <VirtualHost *:80> DocumentRoot /home/hogehoge/html/public ServerName hogehoge.com ServerAlias hogehoge.com <Directory "/home/hogehoge/html/public"> #.htaccessを利用可能にする AllowOverride All # Laravelで利用する環境変数を development に設定 SetEnv APP_ENV development #アクセス許可 Require all granted </Directory> </VirtualHost> |
上記の設定を変更し、httpd を再起動します。
1 |
$ sudo systemctl restart httpd |
動作確認
上記のURLにアクセスし、画像の画面が表示されれば、動作完了となります。