1、安装 Nginx Proxy Manager ,打开 Windows Terminal 命令行,按照以下指示进入 Ubuntu 系统。如图1
2、进入用户根目录,新建目录:proxy-manager,进入 目录:proxy-manager,创建文件:docker-compose.yml。如图2
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、编辑文件:docker-compose.yml,Nano 的保存并退出,按下 Ctrl+O,再按下 Enter。再按下 Ctrl+X。HTTP & HTTPS 都是使用预设值。Post 81 用于 Admin 页面,让我们能设置 Laravel Ssil 的 Proxy。假如你的项目数量不多的话,使用 SQLite 已经足够了的。开发环境一般我都禁用 IPv6。保存接着就能启动容器了。如图3
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、运行命令:docker-compose up -d ,报错:ERROR: yaml.scanner.ScannerError。最终决定还是使用 vi 重新编辑再保存。如图4
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、看到最后提示为绿色,表示容器创建成功。现在打开网址:http://localhost:81 。邮箱:admin@example.com 密码:changeme 。登录成功,如图5
6、创建 Laravel Sail 项目一,执行命令:curl -s https://laravel.build/sail-project-1 | bash
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、打开编辑器,编辑 .env 文件,将以下配置项加入。这些皆是 Sail 的预设服务,其端口不能够重复,且与其他容器也不能够重复。一般来说端口 49152 到 65535 都是闲置的能够使用。如图6
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、进入目录:sail-project-1 ,执行命令:sail up -d。如图7
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、第一个 Sail 项目启动完成。如图8
10、接着开始第二个 Sail 项目,执行命令:curl -s https://laravel.build/sail-project-2 | bash。步骤是一样的,只不过 .env 文件的内容有所差异。所有端口号全部加1,未报端口冲突错误。如图9
APP_PORT=48081 FORWARD_DB_PORT=43307 FORWARD_REDIS_PORT=46380 FORWARD_MEILISEARCH_PORT=47701 FORWARD_MAILHOG_PORT=41026 FORWARD_MAILHOG_DASHBOARD_PORT=48026
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、在两个项目中,编辑视图文件,以未区分。http://localhost:48080/ 、http://localhost:48081/ 。如图10
12、现在分别设置两个项目的域名。编辑 C:/Windows/System32/Drivers/etc/hosts 文件,指定 IP 与域名之间的映射关系。
127.0.0.1 sail-project-1.test 127.0.0.1 sail-project-2.test
13、打开 Nginx Proxy Manager ,Hosts – Proxy Hosts – Add Proxy Host。如图11
14、添加完毕
15、分别打开:http://sail-project-1.test 、http://sail-project-2.test ,如图12
16、从本地宿主机连接到 MySQL 数据库,可以直接通过 127.0.0.1 和 43306 端口连接到 MySQL 数据库容器。如图13
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250692.html