1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EC2 Amazon Linux 2 + nginx で Laravel の環境構築の際によく使うコマンド

Last updated at Posted at 2020-08-07

yumアップデート

sudo yum update -y

nginxのインストール

sudo amazon-linux-extras install nginx1.12 -y

// nginxの起動
sudo systemctl start nginx

// 自動起動設定(これをやっておくとEC2再起動などの際に自動で起動してくれる)
sudo systemctl enable nginx

// nginxのステータス確認(起動失敗時などに調査で使用する)
systemctl status nginx.service

// nginxでPHPを動かす際はこの設定ファイル内のapacheをnginxに変える
sudo vi /etc/php-fpm.d/www.conf

PHPのインストール

sudo amazon-linux-extras install php7.3 -y

// Laravelを動かすためには php-xmlとphp-mbstringが必要
sudo yum install php-xml php-mbstring -y

MySQLのインストール

sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm -y
sudo yum install mysql-community-server -y
sudo systemctl start mysqld.service
sudo systemctl enable mysqld.service

Composerのインストール

sudo curl -sS https://getcomposer.org/installer | php

// パスを通す
sudo mv composer.phar /usr/local/bin/composer

Laravelのインストール

// インストール先のディレクトリに権限を付与する
sudo chmod -R 777 /usr/share/nginx/html

cd /usr/share/nginx/html

composer create-project --prefer-dist laravel/laravel app_name

Laravelのセットアップ

cd app_name

cp .env.example .env

php artisan コマンドを使えるようにする

composer install
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?