Build a Laravel Sail development environment in Windows 10 Professional

在浏览器中打开网址:http://example-app.test/ 。响应 200。
1. Laravel Sail requires Windows 10 systems that support WSL 2. The 2004 version released in May 2020 only supports the WSL 2 function, so our system needs to be updated to the 2004 version equal to or greater than the 2004 version. To view the system version, you can use the winver command, refer to Windows 10 Release Information, the release time of the version is greater than 1909. The system version meets the requirements. as shown in Figure 1
查看系统版本,可以使用 winver 命令,参考 Windows 10 release information ,版本的发布时间大于 1909 即可。
Figure 1
2. First upgrade to: the latest 21H1 version based on 360. as shown in Figure 2
先基于 360 升级至:最新的 21H1 的版本。
Figure 2
3. Check the system version, it has been upgraded to: 21h1 version. as shown in Figure 3
查看系统版本,已经升级至:21H1 的版本。
Figure 3
4. Search to open the windows function management window to ensure that the two places in the red box in the figure below are enabled: Windows subsystem for Linux, remote differential compression API support. as shown in Figure 4
搜索打开 Windows 功能管理 窗口,确保下图红框框住的两个地方都已开启:适用于 Linux 的 Windows 子系统、远程差分压缩 API 支持。
Figure 4
5. In order to better access the Windows subsystem, it is recommended to use Windows Terminal as a command line tool. Open the Microsoft store, search for the keyword Windows Terminal, and click Install in the search results. as shown in Figure 5
为了更好地访问 Windows 的子系统,推荐使用 Windows Terminal 作为命令行工具。打开微软商店,搜索关键字 Windows Terminal ,在搜索结果中点击安装即可。
Figure 5
6. Download and install the subsystem: Ubuntu. Open the Microsoft store, search for ubuntu, the first and second can be, select the second one: ubuntu 20.04 LTS. as shown in Figure 6
下载和安装子系统:Ubuntu 。打开微软商店,搜索关键词 Ubuntu,第一和第二个都可以,选择第二个:Ubuntu 20.04 LTS。
Figure 6
7. Prompt to create a user of the Ubuntu system, enter the user name, and then enter the password to complete the installation of the Ubuntu subsystem. This Ubuntu is a subsystem of the current Windows system, and our Docker will run based on this system. as shown in Figure 7
提示创建一个 Ubuntu 系统的用户,输入用户名,接下来输入密码即可完成 Ubuntu 子系统的安装。这个 Ubuntu 为当前 Windows 系统的子系统,接下来我们的 Docker 会基于此系统运行。
Figure 7
8. Go to Docker official website to download Docker Desktop: https://hub.docker.com/editions/community/docker-ce-desktop-windows After the download is complete, click the installation package to install, and you can go all the way. 9. Tips: WSL 2 Installation is incomplete. WSL 2 installation is incomplete. as shown in Figure 8
提示:WSL 2 installation is incomplete. WSL 2 安装不完整。
8


WSL 2 installation is incomplete.
The WSL 2 Linux kernel is now installed using a separate MSI update package. Please click the link and follow the instructions to install the kernel update:https://aka.ms/wsl2kernel

Press restart after installing the Linux kernel


10. Click the link and follow the instructions to install the kernel update: https://aka.ms/wsl2kernel . Download and install the Linux kernel update package. as shown in Figure 9
点击链接并按照说明安装内核更新:https://aka.ms/wsl2kernel 。下载并安装 Linux 内核更新包。
Figure 9
11. Restart the computer, open Docker Desktop again, and report an error: Docker failed to initialize. Ignore it for now. As shown in Figure 10
重启电脑,再次打开 Docker Desktop,报错:Docker failed to initialize。暂时不用理会。
Figure 10
12. After restarting the computer again. Open Docker Desktop, no errors are reported again. Go to the configuration page – General, Use the WSL 2 based engine is checked by default, and enable WSL2 mode. as shown in Figure 11
再次重启电脑后。打开 Docker Desktop,未再报错。进入配置页面 - General,默认已勾选 Use the WSL 2 based engine,开启 WSL2 模式。
Figure 11
13. Configuration – Resources – WSL Integration, select the Ubuntu system we installed in the previous step, but the Ubuntu option does not exist. as shown in Figure 12
配置 - Resources - WSL Integration,选择我们上一步安装的 Ubuntu 系统,但是不存在 ubuntu 选项。
Figure 12
14. Reference URL: https://learnku.com/articles/54890. Open: Windows Terminal, convert to WSL 2. as shown in Figure 13
参考网址:https://learnku.com/articles/54890 。打开:Windows Terminal,转换为 WSL 2。
Figure 13


PS C:\Users\Lenovo> wsl --list --verbose
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         1
  docker-desktop-data    Running         2
  docker-desktop         Running         2
PS C:\Users\Lenovo> wsl --set-version Ubuntu-20.04 2
正在进行转换,这可能需要几分钟时间...
有关与 WSL 2 的主要区别的信息,请访问 https://aka.ms/wsl2
转换完成。
PS C:\Users\Lenovo>


15. Click the button Refresh, the option ubuntu-20.04 has appeared, turn on. Figure 14
点击按钮 Refresh,选项 Ubuntu-20.04 已经出现,开启。
Figure 14
16. Create a test project, open the Windows Terminal command line, and follow the instructions below to enter the Ubuntu system. as shown in Figure 15
创建测试项目,打开 Windows Terminal 命令行,按照以下指示进入 Ubuntu 系统。
Figure 15
17. Ubuntu, as a Windows subsystem, can access the hard disk under the main system. In order to facilitate the management code, I have already created the wwwroot directory under the E drive. After entering this directory, I use the following command to create a test Laravel project. as shown in Figure 16
Ubuntu 作为 Windows 子系统,可以访问到主系统下的硬盘。为了方便管理代码,我在 E 盘下早已创建了 wwwroot 目录,进入此目录后,使用以下命令进行创建一个测试的 Laravel 项目。
Figure 16


wangqiang@DESKTOP-QLPK8QM:/mnt/c/Users/Lenovo$ cd /mnt/e
wangqiang@DESKTOP-QLPK8QM:/mnt/e$ ls
'$RECYCLE.BIN'  'System Volume Information'   cms   pagefile.sys    phpuploadtmp
 Develop         c                            css   phpsessiontmp   wwwroot
wangqiang@DESKTOP-QLPK8QM:/mnt/e$ cd wwwroot/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$ curl -s https://laravel.build/example-app | bash
Unable to find image 'laravelsail/php81-composer:latest' locally
latest: Pulling from laravelsail/php81-composer
eff15d958d66: Pull complete
933427dc39f7: Pull complete
35bb08dc7ee2: Pull complete
58a3f26800d7: Pull complete
28803bfad74c: Pull complete
341a482d0bd3: Pull complete
03c4148389b1: Pull complete
fa3a9bfc7793: Pull complete
024907232600: Pull complete
df5987d70de6: Pull complete
e2a72a518bd8: Pull complete
b1ba689993c8: Pull complete
3bd142ab0b85: Pull complete
872fe34989f0: Pull complete
Digest: sha256:b27920b769ad8dc036a9ede3ae36f51a280d370ec7d125e77ca1924c9fa21dbb
Status: Downloaded newer image for laravelsail/php81-composer:latest

 _                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V /  __/ |
|______\__,_|_|  \__,_| \_/ \___|_|

Warning: TTY mode requires /dev/tty to be read/writable.
    Creating a "laravel/laravel" project at "./example-app"
    Installing laravel/laravel (v8.6.9)
      - Downloading laravel/laravel (v8.6.9)
      - Installing laravel/laravel (v8.6.9): Extracting archive
    Created project in /opt/example-app
    > @php -r "file_exists('.env') || copy('.env.example', '.env');"
    Loading composer repositories with package information
    Updating dependencies
    Lock file operations: 110 installs, 0 updates, 0 removals
      - Locking asm89/stack-cors (v2.0.3)
  - Locking brick/math (0.9.3)
      - Locking dflydev/dot-access-data (v3.0.1)
  - Locking doctrine/inflector (2.0.4)
      - 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.9.1)
      - Locking facade/ignition (2.17.2)
      - Locking facade/ignition-contracts (1.0.2)
      - Locking fakerphp/faker (v1.17.0)
      - Locking filp/whoops (2.14.4)
      - Locking fruitcake/laravel-cors (v2.0.4)
      - Locking graham-campbell/result-type (v1.0.4)
  - Locking guzzlehttp/guzzle (7.4.1)
  - Locking guzzlehttp/promises (1.5.1)
  - Locking guzzlehttp/psr7 (2.1.0)
      - Locking hamcrest/hamcrest-php (v2.0.1)
  - Locking laravel/framework (v8.76.2)
  - Locking laravel/sail (v1.12.12)
  - Locking laravel/sanctum (v2.13.0)
  - Locking laravel/serializable-closure (v1.0.5)
      - Locking laravel/tinker (v2.6.3)
  - Locking league/commonmark (2.1.0)
  - Locking league/config (v1.1.1)
  - Locking league/flysystem (1.1.9)
  - Locking league/mime-type-detection (1.9.0)
      - Locking mockery/mockery (1.4.4)
  - Locking monolog/monolog (2.3.5)
      - Locking myclabs/deep-copy (1.10.2)
  - Locking nesbot/carbon (2.55.2)
      - Locking nette/schema (v1.2.2)
      - Locking nette/utils (v3.2.6)
      - Locking nikic/php-parser (v4.13.2)
      - Locking nunomaduro/collision (v5.10.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.3.0)
      - Locking phpdocumentor/type-resolver (1.5.1)
      - Locking phpoption/phpoption (1.8.1)
  - Locking phpspec/prophecy (v1.15.0)
      - Locking phpunit/php-code-coverage (9.2.10)
  - Locking phpunit/php-file-iterator (3.0.6)
      - 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.10)
      - Locking psr/container (1.1.2)
      - 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 (2.0.0)
  - Locking psr/simple-cache (1.0.1)
      - Locking psy/psysh (v0.10.12)
  - Locking ralouphie/getallheaders (3.0.3)
      - Locking ramsey/collection (1.2.2)
      - Locking ramsey/uuid (4.2.3)
  - 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.4)
      - 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.3.0)
      - Locking symfony/console (v5.4.1)
      - Locking symfony/css-selector (v6.0.1)
  - Locking symfony/deprecation-contracts (v3.0.0)
      - Locking symfony/error-handler (v5.4.1)
      - Locking symfony/event-dispatcher (v6.0.1)
      - Locking symfony/event-dispatcher-contracts (v3.0.0)
      - Locking symfony/finder (v5.4.0)
  - Locking symfony/http-foundation (v5.4.1)
      - Locking symfony/http-kernel (v5.4.1)
  - Locking symfony/mime (v5.4.0)
      - 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.4.0)
      - Locking symfony/routing (v5.4.0)
      - Locking symfony/service-contracts (v2.4.1)
      - Locking symfony/string (v6.0.1)
  - Locking symfony/translation (v6.0.1)
      - Locking symfony/translation-contracts (v3.0.0)
      - Locking symfony/var-dumper (v5.4.1)
      - Locking theseer/tokenizer (1.2.1)
      - Locking tijsverkoyen/css-to-inline-styles (2.2.4)
      - Locking vlucas/phpdotenv (v5.4.1)
      - 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: 110 installs, 0 updates, 0 removals
      - Downloading doctrine/inflector (2.0.4)
      - Downloading doctrine/lexer (1.2.1)
      - Downloading dragonmantank/cron-expression (v3.1.0)
      - Downloading symfony/var-dumper (v5.4.1)
      - Downloading symfony/string (v6.0.1)
      - Downloading psr/container (1.1.2)
      - Downloading symfony/service-contracts (v2.4.1)
      - Downloading symfony/console (v5.4.1)
      - Downloading psr/log (2.0.0)
      - Downloading monolog/monolog (2.3.5)
      - Downloading voku/portable-ascii (1.5.6)
      - Downloading phpoption/phpoption (1.8.1)
      - Downloading graham-campbell/result-type (v1.0.4)
      - Downloading vlucas/phpdotenv (v5.4.1)
      - Downloading symfony/css-selector (v6.0.1)
      - Downloading tijsverkoyen/css-to-inline-styles (2.2.4)
      - Downloading symfony/routing (v5.4.0)
      - Downloading symfony/polyfill-php72 (v1.23.0)
      - Downloading symfony/polyfill-intl-idn (v1.23.0)
      - Downloading symfony/mime (v5.4.0)
      - Downloading symfony/http-foundation (v5.4.1)
      - Downloading psr/event-dispatcher (1.0.0)
      - Downloading symfony/event-dispatcher-contracts (v3.0.0)
      - Downloading symfony/event-dispatcher (v6.0.1)
      - Downloading symfony/error-handler (v5.4.1)
      - Downloading symfony/http-kernel (v5.4.1)
      - Downloading symfony/finder (v5.4.0)
      - Downloading symfony/polyfill-iconv (v1.23.0)
      - Downloading egulias/email-validator (2.1.25)
      - Downloading swiftmailer/swiftmailer (v6.3.0)
      - Downloading symfony/polyfill-php81 (v1.23.0)
      - Downloading ramsey/collection (1.2.2)
      - Downloading brick/math (0.9.3)
      - Downloading ramsey/uuid (4.2.3)
      - Downloading psr/simple-cache (1.0.1)
      - Downloading opis/closure (3.6.2)
      - Downloading symfony/translation-contracts (v3.0.0)
      - Downloading symfony/translation (v6.0.1)
      - Downloading nesbot/carbon (2.55.2)
      - Downloading league/mime-type-detection (1.9.0)
      - Downloading league/flysystem (1.1.9)
      - Downloading nette/utils (v3.2.6)
      - Downloading nette/schema (v1.2.2)
      - Downloading dflydev/dot-access-data (v3.0.1)
      - Downloading league/config (v1.1.1)
      - Downloading league/commonmark (2.1.0)
      - Downloading laravel/serializable-closure (v1.0.5)
      - Downloading laravel/framework (v8.76.2)
      - Downloading facade/ignition-contracts (1.0.2)
      - Downloading facade/flare-client-php (1.9.1)
      - Downloading facade/ignition (2.17.2)
      - Downloading fakerphp/faker (v1.17.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.1.0)
      - Downloading guzzlehttp/promises (1.5.1)
      - Downloading guzzlehttp/guzzle (7.4.1)
      - Downloading laravel/sail (v1.12.12)
      - Downloading laravel/sanctum (v2.13.0)
      - Downloading nikic/php-parser (v4.13.2)
      - Downloading psy/psysh (v0.10.12)
      - Downloading laravel/tinker (v2.6.3)
      - Downloading hamcrest/hamcrest-php (v2.0.1)
      - Downloading mockery/mockery (1.4.4)
      - Downloading filp/whoops (2.14.4)
      - Downloading nunomaduro/collision (v5.10.0)
      - Downloading phpunit/php-file-iterator (3.0.6)
      - Downloading phpunit/php-code-coverage (9.2.10)
      - Downloading phpspec/prophecy (v1.15.0)
      - Installing doctrine/inflector (2.0.4): 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.4.1): 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 (v6.0.1): Extracting archive
      - Installing psr/container (1.1.2): Extracting archive
      - Installing symfony/service-contracts (v2.4.1): Extracting archive
      - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive
      - Installing symfony/deprecation-contracts (v3.0.0): Extracting archive
      - Installing symfony/console (v5.4.1): Extracting archive
      - Installing psr/log (2.0.0): Extracting archive
      - Installing monolog/monolog (2.3.5): Extracting archive
      - Installing voku/portable-ascii (1.5.6): Extracting archive
      - Installing phpoption/phpoption (1.8.1): Extracting archive
      - Installing graham-campbell/result-type (v1.0.4): Extracting archive
      - Installing vlucas/phpdotenv (v5.4.1): Extracting archive
      - Installing symfony/css-selector (v6.0.1): Extracting archive
      - Installing tijsverkoyen/css-to-inline-styles (2.2.4): Extracting archive
      - Installing symfony/routing (v5.4.0): Extracting archive
      - Installing symfony/process (v5.4.0): 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.4.0): Extracting archive
      - Installing symfony/http-foundation (v5.4.1): Extracting archive
      - Installing psr/event-dispatcher (1.0.0): Extracting archive
      - Installing symfony/event-dispatcher-contracts (v3.0.0): Extracting archive
      - Installing symfony/event-dispatcher (v6.0.1): Extracting archive
      - Installing symfony/error-handler (v5.4.1): Extracting archive
      - Installing symfony/http-kernel (v5.4.1): Extracting archive
      - Installing symfony/finder (v5.4.0): Extracting archive
      - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive
      - Installing egulias/email-validator (2.1.25): Extracting archive
      - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
      - Installing symfony/polyfill-php81 (v1.23.0): Extracting archive
      - Installing ramsey/collection (1.2.2): Extracting archive
      - Installing brick/math (0.9.3): Extracting archive
      - Installing ramsey/uuid (4.2.3): Extracting archive
      - Installing psr/simple-cache (1.0.1): Extracting archive
      - Installing opis/closure (3.6.2): Extracting archive
      - Installing symfony/translation-contracts (v3.0.0): Extracting archive
      - Installing symfony/translation (v6.0.1): Extracting archive
      - Installing nesbot/carbon (2.55.2): Extracting archive
      - Installing league/mime-type-detection (1.9.0): Extracting archive
      - Installing league/flysystem (1.1.9): Extracting archive
      - Installing nette/utils (v3.2.6): Extracting archive
      - Installing nette/schema (v1.2.2): Extracting archive
      - Installing dflydev/dot-access-data (v3.0.1): Extracting archive
      - Installing league/config (v1.1.1): Extracting archive
      - Installing league/commonmark (2.1.0): Extracting archive
      - Installing laravel/serializable-closure (v1.0.5): Extracting archive
      - Installing laravel/framework (v8.76.2): Extracting archive
      - Installing facade/ignition-contracts (1.0.2): Extracting archive
      - Installing facade/flare-client-php (1.9.1): Extracting archive
      - Installing facade/ignition (2.17.2): Extracting archive
      - Installing fakerphp/faker (v1.17.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.1.0): Extracting archive
      - Installing guzzlehttp/promises (1.5.1): Extracting archive
      - Installing guzzlehttp/guzzle (7.4.1): Extracting archive
      - Installing laravel/sail (v1.12.12): Extracting archive
      - Installing laravel/sanctum (v2.13.0): Extracting archive
      - Installing nikic/php-parser (v4.13.2): Extracting archive
      - Installing psy/psysh (v0.10.12): Extracting archive
      - Installing laravel/tinker (v2.6.3): Extracting archive
      - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
      - Installing mockery/mockery (1.4.4): Extracting archive
      - Installing filp/whoops (2.14.4): Extracting archive
      - Installing nunomaduro/collision (v5.10.0): Extracting archive
      - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive
      - Installing phpdocumentor/type-resolver (1.5.1): Extracting archive
      - Installing phpdocumentor/reflection-docblock (5.3.0): 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.4): 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.6): 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.10): Extracting archive
      - Installing doctrine/instantiator (1.4.0): Extracting archive
      - Installing phpspec/prophecy (v1.15.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.10): Extracting archive
    76 package suggestions were added by new dependencies, use `composer suggest` to see details.
    Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
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.
    77 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 --force
    No publishable resources for tag [laravel-assets].
Publishing complete.
    > @php artisan key:generate --ansi
    Application key set successfully.

Application ready! Build something amazing.
Sail scaffolding installed successfully.

Please provide your password so we can make some final adjustments to your application's permissions.

[sudo] password for wangqiang:

Thank you! We hope you build something incredible. Dive in with: cd example-app && ./vendor/bin/sail up
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$


18. Finally create a successful interface. as shown in Figure 17
最终创建成功的界面。
Figure 17
19. Open the E:\wwwroot\example-app directory. as shown in Figure 18
打开 E:\wwwroot\example-app 目录。
18
20. To view the Dockerfile file, Laravel 8 uses the Dockerfile under the vendor/Laravel/sail/runtimes/8.0 directory by default. as shown in Figure 19
查看 Dockerfile 文件,Laravel 8 默认用的是 vendor/laravel/sail/runtimes/8.0 目录下的 Dockerfile。
Figure 19
21. Run the container, and in the root directory of the project, execute the following command: ./vendor/bin/sail up. The first time it runs, the container is initialized. It is recommended to turn over the wall. I generally don’t tend to use domestic mirrors. report an error. As shown in Figure 20
运行容器,在项目的根目录下,执行以下命令:./vendor/bin/sail up。第一次运行的时候,会初始化容器。建议翻墙。我一般不倾向于使用国内的镜像。报错。
Figure 20


ERROR: for mysql  Cannot start service mysql: Ports are not available: listen tcp 0.0.0.0:3306: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
ERROR: Encountered errors while bringing up the project.


22. The reason should be that the local MySQL database has used port 3306, and it is decided to first modify the port of the local MySQL database to 3307. Open the directory C:\ProgramData\MySQL\MySQL Server 5.7, and edit the my.ini file.


[client]

# pipe
# socket=0.0
port=3307


[mysqld]

# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking

# enable-named-pipe

# shared-memory

# shared-memory-base-name=MYSQL

# The Pipe the MySQL Server will use
# socket=MYSQL

# The TCP/IP Port the MySQL Server will listen on
port=3307


23. After restarting the computer, the connection to the local MySQL database is successful based on port 3307. as shown in Figure 21
重启电脑后,基于端口 3307 连接本地 mysql 数据库成功。
Figure 21
24. Run the command again: ./vendor/bin/sail up. It will start running from MySQL, and the total time it takes 20 minutes. After the Sail up command runs successfully, the real-time log interface of the software will always be displayed. Figure 22
再次运行命令:./vendor/bin/sail up。会从 mysql 处开始运行,总计耗费时长:。sail up 命令运行成功后,会一直显示软件的实时日志界面。
Figure 22
25. At this time, you can run Ctrl+C interrupts. When running again, you can use the -d parameter to make the Sail up command run in the background. Figure 23
此时你可以 ctrl+c 中断运行,再次运行时,可以使用 -d 参数让 sail up 命令在后台运行。
Figure 23


meilisearch_1   | [2021-12-21T03:09:36Z INFO  actix_web::middleware::logger] 127.0.0.1:51806 "GET /health HTTP/1.1" 200 22 "-" "Wget" 0.000297
^CGracefully stopping... (press Ctrl+C again to force)
Stopping example-app_laravel.test_1 ... done
Stopping example-app_mailhog_1      ... done
Stopping example-app_mysql_1        ... done
Stopping example-app_selenium_1     ... done
Stopping example-app_redis_1        ... done
Stopping example-app_meilisearch_1  ... done
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/example-app$ ./vendor/bin/sail up -d
example-app_laravel.test_1   start-container                  Exit 137
Shutting down old Sail processes...
Creating network "example-app_sail" with driver "bridge"
Creating example-app_redis_1       ... done
Creating example-app_mailhog_1     ... done
Creating example-app_meilisearch_1 ... done
Creating example-app_selenium_1    ... done
Creating example-app_mysql_1       ... done
Creating example-app_laravel.test_1 ... done
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/example-app$


26. Open Docker Desktop, there is a container in the container list: example-app, and the status is running. Figure 24
打开 Docker Desktop,容器列表中存在容器:example-app,状态为运行中。
Figure 24
27. Open the URL in the browser: http://localhost/ , and the response is 200. Laravel v8.76.2 (PHP v8.1.0). The development environment is successfully deployed. as shown in Figure 25
在浏览器中打开网址:http://localhost/ ,响应 200 。Laravel v8.76.2 (PHP v8.1.0)。开发环境部署成功。
Figure 25
28. In response to the problem of port 3306 being occupied, there is another solution, that is, the port of modifying the container is 43306. The local MySQL database still uses port 3306. The plan is subsequently implemented based on Nginx Proxy Manager. 29. Edit the C:/Windows/System32/drivers/etc/hosts file, and specify the mapping relationship between IP and domain name.


127.0.0.1 example-app.test


30. Open the URL in the browser: http://example-app.test/ . Response 200. Figure 26
在浏览器中打开网址:http://example-app.test/ 。响应 200。
Figure 26

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.