0
0

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.

UbuntuでLaravel8

Last updated at Posted at 2021-02-21

AWS EC2にて

Ubuntu 18.04.5 LTS

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

パッケージ確認

ii  php7.2                           7.2.24-0ubuntu0.18.04.7             all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.2-cli                       7.2.24-0ubuntu0.18.04.7             amd64        command-line interpreter for the PHP scripting language
ii  apache2                          2.4.29-1ubuntu4.14                  amd64        Apache HTTP Server
ii  mysql-server-5.7                 5.7.33-0ubuntu0.18.04.1             amd64        MySQL database server binaries and system database setup

Laravel8サーバー条件

php7.3以上
MySQL5.7以上(migrationの ('email')->unique()がこけるので実質5.7)
nodejs v12.14以上(npmでこけるものがあるのでこれも実質12.14)

php7.4をインストール

php7.2を残したまま切り替えできる
https://www.souichi.club/wordpress/php-version-up/
何故か入っていない、mbstringとdomをインストール

apt install php7.4-mbstring php7.4-xml php7.4-mysqlnd php7.4-curl

php.iniにてタイムゾーンだけ設定しておく

/etc/php/7.4/apache2/php.ini
timezone = Asia/Tokyo

nodejs アップグレード

nvmで入っているので、インストールするだけ

nvm install v15.8.0
nvm 

Laravel8 インストール

composerインストールする

composerコマンド、ここから(https://getcomposer.org/download/)

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

mkdir ~/bin
mv composer.phar ~/bin/composer

composer インストール

composer create-project laravel/laravel example-app 

Apache2設定

デフォルトのドキュメントルートを付け替える

ubuntu:~/example-app $ sudo mv /var/www/html /var/www/html_org                                                                                         
ubuntu:~/example-app $ sudo ln -s /home/ubuntu/example-app/public /var/www/html 

パーミッション設定
https://qiita.com/engulisyu/items/ad819d06ea0cd31411df

sudo usermod -a -G www-data ubuntu
sudo chown -R ubuntu:www-data ~/example-app
sudo find ~/example-app -type d -exec chmod 750 {} \;
sudo find ~/example-app -type f -exec chmod 640 {} \;
sudo chmod -R 770 ~/example-app/storage/ ~/example-app/bootstrap/cache/

ここまでで画面でる
スクリーンショット 2021-02-16 16.50.45.png

データベース設定

# mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO devuser@localhost IDENTIFIED BY '1234' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> CREATE DATABASE devdb CHARACTER SET utf8mb4;
mysql> \q
.env
DB_DATABASE=devdb
DB_USERNAME=devuser
DB_PASSWORD=1234

Laravel Starter Kits (Breeze)インストール

cd example-app
php artisan migrate
composer require laravel/breeze --dev
php artisan breeze:install
npm install
npm run dev

Apache2のrewriteが効かない

a2enmod rewrite して、/var/wwwのoverride Allする
https://qiita.com/ryokurosu/items/7bae243614c0894e048d
/dashboardへアクセス
スクリーンショット 2021-02-16 18.09.36.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?