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 1 year has passed since last update.

phpでLaravel開発をAuth認証と共に開始する (2023/04/17)

Posted at

はじめに

Laravelを始めるときのインストールを忘れそうなので備忘録。
試験的に作成するときや、テストのためにパスワードやセキュリティについては最小限にしているため、そのままの使用は推奨しない

Versions

$ php -v
PHP 8.1.2-1ubuntu2.11 (cli)...

$ composer -V
Composer 2.2.6 2022-02-04 17:00:38

$ n -V
v9.1.0

$ node -v
v19.9.0

$ npm -v
9.6.3

$ mysql -V
mysql Ver 8.0.32-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubunut))

Bash

  # Install required apt
$ sudo apt-get update
$ sudo apt install -y php php-curl php-mysql php-bcmath php-mbstring php-xml php-zip
$ sudo apt install -y composer mysql-server npm vim
$ sudo npm install -g n
    # n ls-remote
    # sudo n 16.20.0	
$ sudo n latest
$ exit
    # RESTRT TERMINAL

  # Install mysql
$ sudo service mysql start
$ sudo service mysql status
$ sudo mysql_secure_installation
  :y # YES
  :0 # LOW=0
  :a # PASSWORD
  :a # CONFIRM
  ^C # Force Exit
$ sudo mysql -u root -p
Enter password: # none
  mysql> set global validate_password.length=4;
  mysql> set global validate_password.policy=LOW;
  mysql> alter user 'root'@'localhost' identified by '0000';
  mysql> create user 'user'@'localhost' identified by '0000';
  mysql> grant all privileges on *.* to 'user'@'localhost';
  mysql> flush privileges;
  mysql> create database laravel;
  mysql> exit
$ sudo service mysql restart

  # Create Laravel Project
$ cd ~
$ composer create-project --prefer-dist laravel/laravel SampleProject
$ cd SampleProject

  # Database Connection Settings in Laravel
$ vim .env
    # DB_HOST=localhost
    # DB_USERNAME=user
    # DB_PASSWORD=0000
    # :wq <- Save & Exit

  # Add Auth authentication function
$ composer require laravel/ui
$ php artisan ui vue --auth
$ npm install
$ npm run dev
    # Move to new window while keeping run

  # Migrate database and run Laravel
$ php artisan migrate
$ php artisan serve

Reference

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?