背景,有一台不能直连的服务器,网络是通的,需要向服务器上面传文件,通过http是最简单的方式。所以想有什么简单方法可以启动一个web服务。
如果电脑已经安装了node,那么anywhere 安装非常简单
安装命令
npm install -g anywhere
这里要注意,mac可能会执行失败,因为没有权限,这时要加上sudo 前缀执行, 输入密码后可以正常安装。
web % sudo npm install -g anywhere Password: /usr/local/bin/anywhere -> /usr/local/lib/node_modules/anywhere/bin/anywhere + anywhere@1.5.0 added 37 packages from 25 contributors in 9.72s ╭───────────────────────────────────────────────────────────────╮ │ │ │ New major version of npm available! 6.13.4 → 8.1.3 │ │ Changelog: https://github.com/npm/cli/releases/tag/v8.1.3 │ │ Run npm install -g npm to update! │ │ │ ╰───────────────────────────────────────────────────────────────╯
安装完成之后直接在想要启动服务的文件夹下,打开命令行,输入anywhere+端口然后回车即可启动。
web % anywhere 9090 Running at http://10.2.147.28:9090/ Also running at https://10.2.147.28:9091/
然后在其他服务器就可以通过http地址访问启动目录下的文件了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)