没有不值得去解决的问题,也没有不值得去学习的技术!

Set Custom Domains for Multiple Laravel Sail Environments in Windows 10 Pro

Open http://sail-project-1.test and http://sail-project-2.test respectively.

1. Install Nginx Proxy Manager. Open the Windows Terminal command line and follow the instructions below to enter the Ubuntu system. See Figure 1.

Install Nginx Proxy Manager. Open the Windows Terminal command line and follow the instructions below to enter the Ubuntu system.
Figure 1

2. Go to the user’s home directory, create a new directory named proxy-manager, enter the proxy-manager directory, and create a file named docker-compose.yml. See Figure 2.

Go to the user's home directory, create a new directory named proxy-manager, enter the proxy-manager directory, and create a file named docker-compose.yml.
Figure 2
Plaintext

wangqiang@DESKTOP-QLPK8QM:/mnt/c/Users/Lenovo$ cd ~
wangqiang@DESKTOP-QLPK8QM:~$ mkdir proxy-manager
wangqiang@DESKTOP-QLPK8QM:~$ ls
proxy-manager
wangqiang@DESKTOP-QLPK8QM:~$ cd proxy-manager/
wangqiang@DESKTOP-QLPK8QM:~/proxy-manager$ nano docker-compose.yml

3. Edit the docker-compose.yml file. To save and exit in Nano, press Ctrl+O, then press Enter, and finally press Ctrl+X. Both HTTP & HTTPS use the default values. Port 81 is used for the Admin page, allowing us to configure the proxy for Laravel Sail. If you do not have many projects, SQLite is sufficient. I generally disable IPv6 in development environments. After saving, you can start the container. See Figure 3.

Edit the docker-compose.yml file. To save and exit in Nano, press Ctrl+O, then press Enter, and finally press Ctrl+X. Both HTTP & HTTPS use the default values. Port 81 is used for the Admin page, allowing us to configure the proxy for Laravel Sail. If you do not have many projects, SQLite is sufficient. I generally disable IPv6 in development environments. After saving, you can start the container.
Figure 3
YAML

version: '3'
services:
    app:
        image: 'jc21/nginx-proxy-manager:latest'
        restart: always
        ports:
            # Public HTTP Port:
            - '80:80'
            # Public HTTPS Port:
            - '443:443'
            # Admin Web Port:
            - '81:81'
        environment:
            # These are the settings to access your db
            DB_SQLITE_FILE: '/data/database.sqlite'
            # Uncomment this if IPv6 is not enabled on your host
            DISABLE_IPV6: 'true'
        volumes:
            - './data:/data'
            - './letsencrypt:/etc/letsencrypt'

4. Run the command docker-compose up -d, which throws the error ERROR: yaml.scanner.ScannerError. I ultimately decided to re-edit and save the file using vi. See Figure 4.

Run the command docker-compose up -d, which throws the error ERROR: yaml.scanner.ScannerError. I ultimately decided to re-edit and save the file using vi.
Figure 4
Plaintext

wangqiang@DESKTOP-QLPK8QM:~/proxy-manager$ docker-compose up -d
ERROR: yaml.scanner.ScannerError: while scanning for the next token
found character '\t' that cannot start any token
  in "./docker-compose.yml", line 5, column 1
wangqiang@DESKTOP-QLPK8QM:~/proxy-manager$ vi docker-compose.yml
wangqiang@DESKTOP-QLPK8QM:~/proxy-manager$ docker-compose up -d
Creating network "proxy-manager_default" with the default driver
Pulling app (jc21/nginx-proxy-manager:latest)...
latest: Pulling from jc21/nginx-proxy-manager
72a69066d2fe: Pull complete
6aacc5ddb486: Pull complete
e7c90551cea0: Pull complete
f3fbe2c2c4ff: Pull complete
4437e5607361: Pull complete
ac0af67384ba: Pull complete
70e9cf3ce040: Pull complete
20ca9bfa0d5d: Pull complete
3d5ed869606f: Pull complete
3d8d02d01e35: Pull complete
eb6a6398e23f: Pull complete
44ce8be92956: Pull complete
df1a765de003: Pull complete
a59ede055db9: Pull complete
536e2fa9b52d: Pull complete
a83af78253da: Pull complete
75e669cb8e7a: Pull complete
1dcb53004e40: Pull complete
d96b3a386f37: Pull complete
59e305e29011: Pull complete
3bbeaee21d7f: Pull complete
b65ab8da1424: Pull complete
fac215856462: Pull complete
6aaf9d409d6a: Pull complete
09b699c9559f: Pull complete
0d0f50cd276a: Pull complete
Digest: sha256:09316a7c425270f62600552d3d3115a2a98ea55397e26b43bdfd4b138f9a2ac2
Status: Downloaded newer image for jc21/nginx-proxy-manager:latest
Creating proxy-manager_app_1 ... done
wangqiang@DESKTOP-QLPK8QM:~/proxy-manager$

5. Seeing the final prompt in green indicates that the container was created successfully. Now open the URL http://localhost:81. Email: admin@example.com Password: changeme. Login successful, as shown in Figure 5.

Seeing the final prompt in green indicates that the container was created successfully. Now open the URL http://localhost:81. Email: admin@example.com Password: changeme. Login successful.
Figure 5

6. Create Laravel Sail project 1 by executing the command: curl -s https://laravel.build/sail-project-1 | bash

Plaintext

wangqiang@DESKTOP-QLPK8QM:/mnt$ cd e
wangqiang@DESKTOP-QLPK8QM:/mnt/e$ cd wwwroot/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$ curl -s https://laravel.build/sail-project-1 | bash

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

Warning: TTY mode requires /dev/tty to be read/writable.
    Creating a "laravel/laravel" project at "./sail-project-1"
    Installing laravel/laravel (v8.6.9)
      - Downloading laravel/laravel (v8.6.9)
      - Installing laravel/laravel (v8.6.9): Extracting archive
    Created project in /opt/sail-project-1
    > @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.77.1)
      - 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.77.1)
      - 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.77.1): 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 sail-project-1 && ./vendor/bin/sail up
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$

7. Open the editor, edit the .env file, and add the following configuration items. These are all preset Sail services, and their ports cannot conflict with each other or with other containers. Generally, ports 49152 to 65535 are idle and available for use. See Figure 6.

Open the editor, edit the .env file, and add the following configuration items. These are all preset Sail services, and their ports cannot conflict with each other or with other containers. Generally, ports 49152 to 65535 are idle and available for use.
Figure 6
Plaintext

APP_PORT=48080
FORWARD_DB_PORT=43306
FORWARD_REDIS_PORT=46379
FORWARD_MEILISEARCH_PORT=47700
FORWARD_MAILHOG_PORT=41025
FORWARD_MAILHOG_DASHBOARD_PORT=48025

8. Enter the sail-project-1 directory and execute the command sail up -d. See Figure 7.

Enter the sail-project-1 directory and execute the command sail up -d.
Figure 7
Plaintext

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$ cd sail-project-1/
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-1$ ls
README.md  bootstrap      config              package.json  resources   storage  webpack.mix.js
app        composer.json  database            phpunit.xml   routes      tests
artisan    composer.lock  docker-compose.yml  public        server.php  vendor
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-1$
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-1$
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-1$ alias sail='bash vendor/bin/sail'
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-1$ sail up -d
Creating network "sail-project-1_sail" with driver "bridge"
Creating volume "sail-project-1_sailmysql" with local driver
Creating volume "sail-project-1_sailredis" with local driver
Creating volume "sail-project-1_sailmeilisearch" with local driver
Creating sail-project-1_meilisearch_1 ... done
Creating sail-project-1_selenium_1    ... done
Creating sail-project-1_mysql_1       ... done
Creating sail-project-1_mailhog_1     ... done
Creating sail-project-1_redis_1       ... done
Creating sail-project-1_laravel.test_1 ... done
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-1$

9. The first Sail project has been started. See Figure 8.

The first Sail project has been started.
Figure 8

10. Next, start the second Sail project by executing the command curl -s https://laravel.build/sail-project-2 | bash. The steps are the same, except the contents of the .env file differ. All port numbers are incremented by 1, and no port conflict errors are reported. See Figure 9.

Next, start the second Sail project by executing the command curl -s https://laravel.build/sail-project-2 | bash. The steps are the same, except the contents of the .env file differ. All port numbers are incremented by 1, and no port conflict errors are reported.
Figure 9
Plaintext

APP_PORT=48081
FORWARD_DB_PORT=43307
FORWARD_REDIS_PORT=46380
FORWARD_MEILISEARCH_PORT=47701
FORWARD_MAILHOG_PORT=41026
FORWARD_MAILHOG_DASHBOARD_PORT=48026

Plaintext

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/sail-project-2$ sail up -d
Creating network "sail-project-2_sail" with driver "bridge"
Creating sail-project-2_redis_1       ... done
Creating sail-project-2_mailhog_1      ... done
Creating sail-project-2_meilisearch_1 ... done
Creating sail-project-2_selenium_1    ... done
Creating sail-project-2_mysql_1       ... done
Creating sail-project-2_laravel.test_1 ... done

11. In both projects, edit the view files to differentiate them. http://localhost:48080/ , http://localhost:48081/ . See Figure 10.

In both projects, edit the view files to differentiate them. http://localhost:48080/ , http://localhost:48081/ .
Figure 10

12. Now set the domains for the two projects respectively. Edit the C:/Windows/System32/Drivers/etc/hosts file to specify the mapping between IPs and domains.

Plaintext

127.0.0.1 sail-project-1.test
127.0.0.1 sail-project-2.test

13. Open Nginx Proxy Manager, then go to Hosts – Proxy Hosts – Add Proxy Host. See Figure 11.

Open Nginx Proxy Manager, then go to Hosts - Proxy Hosts - Add Proxy Host.
Figure 11

14. Addition completed.

15. Open http://sail-project-1.test and http://sail-project-2.test respectively. See Figure 12.

Open http://sail-project-1.test and http://sail-project-2.test respectively.
Figure 12

16. To connect to the MySQL database from the local host machine, you can directly connect to the MySQL database container via 127.0.0.1 and port 43306. See Figure 13.

To connect to the MySQL database from the local host machine, you can directly connect to the MySQL database container via 127.0.0.1 and port 43306.
Figure 13

 

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系