首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在与ssh连接时运行本地主机地址

如何在与ssh连接时运行本地主机地址
EN

Stack Overflow用户
提问于 2020-09-26 05:51:37
回答 2查看 339关注 0票数 0

首先,对于这个最愚蠢的问题,我很抱歉,我在这个领域完全是个初学者。我通过ssh连接到一个AWS服务器,并且我已经成功地安装了Elasticsearch并传输了一个应用程序,我想用npm来运行它。在我的本地机器上,当我运行npm start时,我被转移到http://localhost:3000/,一切都运行得很好。如果应用程序也在AWS服务器上运行,我如何查看?有没有办法打开浏览器或类似的东西?到目前为止,我只与终端交互。

谢谢你!!

编辑:命令curl http://localhost:3000/输出以下内容:

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="/logo192.png" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="/manifest.json" />
    <!--
      Notice the use of  in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  <script src="/static/js/bundle.js"></script><script src="/static/js/0.chunk.js"></script><script src="/static/js/main.chunk.js"></script></body>
</html>
EN

回答 2

Stack Overflow用户

发布于 2020-09-26 06:32:04

尝试curl http://localhost:3000/以确认您可以连接。这是一个很好的快速测试,用来确认你是否有一个正常工作的服务。

票数 0
EN

Stack Overflow用户

发布于 2020-09-26 15:54:51

npm build在您的localhost上启动一个开发服务器并加载页面。您的package.json文件的脚本部分将指示其中是否有构建脚本(您很可能有)。

在您的package.json文件中,应该有一个如下所示的对象:

代码语言:javascript
复制
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "test:cov": "npm test -- --coverage --watchAll=false",
    "test:debug": "react-scripts --inspect-brk test --runInBand",
    "eject": "react-scripts eject"
}

(您的启动和构建行可能看起来不同,但这很好)

您的构建脚本将创建一个产品构建,并可能在构建脚本完成后将其放入/build或/public目录中。

因此,在本地计算机上的命令行中尝试使用npm build,而不是npm start。然后,您可以将您的/build (或/public)目录的内容放到您的亚马逊网络服务服务器上(作为via服务器运行,端口80和443对公众开放),然后您可以通过IP地址或域名(如果您已通过Route53将A记录映射到服务器的IP地址)访问网站。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64071710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档