Laravel 7.20.0 PHP 7.4 MYSQL 8.0.21 Windows version 2004
--Introduction of Ubuntu --Updated / introduced to WSL2 --docker installation --Laradock introduced
The goal of this article is to build a Linux environment using WSL2 on a Windows environment, install Laradock, and display the screen + Migration.
• Select "Settings (start button gear icon)"-"Update and Security"-"For Developers" • Select "Developer Mode" in the "Use Developer Features" column to enable it
• Select "Control Panel"-"Programs"-"Turn Windows features on or off" • Check "Windows Subsystem for Linux (Beta)" from the list.
For windows version 2004, the notation has been changed to "Windows subsystem for Linux", so please enable it.
Ubuntu is one of the Linux distributions and is provided as free software
Install ubunntu at Microsoft store.
Type bash at the command prompt. (Successful if you can log in to Ubuntu)
Next, update the state of Ubuntu.
$ sudo apt-get update $ sudo apt-get dist-upgrade $ sudo apt-get autoremove
If you install normally, an old version of Git will be installed, so add a repository to get the latest version.
Execute the following command.
$ sudo apt-get install build-essential $ sudo add-apt-repository ppa:git-core/ppa $ sudo apt-get update $ sudo apt-get install git $ git --version // OK if it's up to date git version 2.28.0
＄sudo apt-get install php7.4 php7.4-fpm php7.4-mysql php7.4-mbstring php7.4-gd $ php -v // Check if the specified version is installed PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
WSL2 is a "real Linux environment" where the Linux kernel runs
PS C:\>dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
PS C:\>dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your PC
C:¥> ver Microsoft Windows [Version 10.0.19041.84]
Make sure the version is 10.0.18917 or higher
Execute the following command to set the default to WSL2.
C:¥> wsl --set-version ubuntu 2
Check if it has switched to WSL2.
C:¥> wsl -l -v NAME STATE VERSION * Ubuntu Stopped 2
What is Docker? An open source containerization technology that enables you to create and use Linux containers.
After restarting, select "setting" from the docker icon on the taskbar Check "Enable the experimental WSL2 based engine" and click "Appli & Restart"
OK when notification is displayed after restarting
Then click "Enable WSL Integration" in WSL Integration of Resources
Select "Ubuntu" and click "Appli & Restart"
C:\Users\magic>wsl -d ubuntu $ docker -v Docker version 19.03.5, build 633a0ea838
$ docker run hello-world To run a command as administrator (user "root"), use "sudo
". See "man sudo_root" for details. Hello from Docker!
Provides the packages you need for your production environment. It's like a finer division of Homestead
I want to manage it in 1 project and 1 repository including Laradock, so it has the following configuration.
──project_dir ├ app // laravel directory │ ├ app │ │ bootstrap │ └ .env │ └ Laradock
$git clone https://github.com/Laradock/laradock.git
$ cd laradock $ cp env-example .env
APP_CODE_PATH_HOST=../ APP_CODE_PATH_HOST = ../project name / pre>
#### Specify the data storage directoryDATA_PATH_HOST=~/.laradock/data + DATA_PATH_HOST=.laradock/data
Project name setting
When creating multiple projects using laradock, if the project name is the same, the container image with the same name created in the past will be overwritten, so set a name that does not coverCOMPOSE_PROJECT_NAME=laradock + COMPOSE_PROJECT_NAME=
MySQL seems to have changed the password generation method in 8 series and can not be operated from Laravel, so add the following description.
Add the following to <project_dir> /lardock/mysqmy.cnf// Add to the [mysqld] area (at the bottom by default) default_authentication_plugin=mysql_native_password
Change the DB settings according to
DB_CONNECTION=mysql DB_HOST = mysql (I think it is 127.001 if it already exists, so modify it to mysql) DB_PORT=3306 DB_DATABASE=default DB_USERNAME=default DB_PASSWORD=secret
Start laradock with the following command. Specify the middleware you want to start in the argument
If the project does not exist, it will be created with root privileges, so be sure to start it in the created state.
$ docker-compose up -d nginx mysql workspace
$ docker-compose ps
How to install laravel from inside docker container and settings.
Enter the Workspace container with the following command.
- Specify the user with the user option.
$ docker-compose exec --user=laradock workspace /bin/bash
Install Laravel by doing the following in the container.
/var/www$ composer create-project --prefer-dist laravel/laravel .
Check the operation when the installation is completed. (* 3306 If you are using port elsewhere, port conflicts, so please terminate the port with task manager etc.)
Access http: // localhost with a browser on the Windows side.
Confirm migration Let's check with migration whether the MySQL settings are complete.
Success if the table is created in the DB as shown below
/var/www$ php artisan migrate Migration table created successfully. Migrating: 2014_10_１９_000000_create_users_table Migrated: 2014_10_１９_000000_create_users_table (0.36 seconds) Migrating: 2014_10_１９_100000_create_password_resets_table Migrated: 2014_10_１９_100000_create_password_resets_table (0.35 seconds) Migrating: 2019_１０_19_000000_create_failed_jobs_table Migrated: 2019_１０_19_000000_create_failed_jobs_table (0.1 seconds)
This time I posted an article about the flow of introducing Laradock in a Windows environment.
Also, it's been a year since I started programming next month, and my knowledge has deepened from the beginning, so I'll publish technical articles little by little from now on. Thank you m (._.) M