laravel:artisan serve指定ip和端口(10.27.0)

发布时间 2023-10-18 08:24:28作者: 刘宏缔的架构森林

一,查看serve的帮助文档:

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan help serve
Description:
  Serve the application on the PHP development server

Usage:
  serve [options]

Options:
      --host[=HOST]     The host address to serve the application on [default: "127.0.0.1"]
      --port[=PORT]     The port to serve the application on
      --tries[=TRIES]   The max number of ports to attempt to serve from [default: 10]
      --no-reload       Do not reload the development server on .env file changes
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

二,执行命令:

说明:如果不用host参数指定ip,laravel会默认使用127.0.0.1

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan serve --host=192.168.219.6 --port=8004
   INFO  Server running on [http://192.168.219.6:8004].  
  Press Ctrl+C to stop the server

三,测试效果

说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/10/16/laravel-artisan-serve-zhi-ding-ip-he-duan-kou-10-27/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com

四,查看当前laravel框架的版本:

liuhongdi@lhdpc:/data/laravel/dignews$ php artisan --version
Laravel Framework 10.27.0