【问题标题】:How to Set up Ghost Blog Framework on Laptop Server如何在笔记本电脑服务器上设置 Ghost 博客框架
【发布时间】:2014-01-29 09:27:31
【问题描述】:

我正在尝试在我的本地笔记本电脑开发机器上设置 Ghost 博客框架。我已成功遵循(基本安装说明)[http://docs.ghost.org/installation/mac/]。我可以通过直接访问 IP 来加载页面,即http://127.0.0.1:2368。然而,我正在努力让页面通过 url 加载,即 mysite.localmachine.net。在 config.js 文件中,我进行了如下设置:

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        url: 'http://myurl',

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://myurl',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },
    ...
    ...
    ...

当我像这样npm start --production 启动博客时,我收到以下显然成功的加载消息:

> ghost@0.4.0 start /Users/ethan/Sites/ghost
> node index

Ghost is running... 
Your blog is now available on http://myurl 

Ctrl+C to shut down

但是,如果我随后在浏览器中导航到 http://myurl,则会收到站点不可用消息。我还尝试将端口设置为 80,我认为这是一个可能的解决方案(此处)[http://www.howtoinstallghost.com/how-to-install-ghost-on-a-mac-os-x- 10-8-mountain-lion/],但这会产生如下所示的错误:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1020:19)
    at listen (net.js:1061:10)
    at net.js:1143:9
    at dns.js:72:18
    at process._tickCallback (node.js:415:13)
    at process._tickFromSpinner (node.js:390:15)
npm ERR! ghost@0.4.0 start: `node index`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the ghost@0.4.0 start script.
npm ERR! This is most likely a problem with the ghost package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node index
npm ERR! You can get their info via:
npm ERR!     npm owner ls ghost
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/Cellar/node/0.10.25/bin/node" "/usr/local/bin/npm" "start" "--production"
npm ERR! cwd /Users/ethan/Sites/ghost
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/****/Sites/ghost/npm-debug.log
npm ERR! not ok code 0

在这一点上我有点难过,无法找到一个清晰的解释来解释在任何地方考虑配置的方式。如果有人有任何想法,那就太好了。

【问题讨论】:

    标签: node.js ghost-blog


    【解决方案1】:

    您不能将程序绑定到端口 80,除非您以 root 身份运行该程序,并且出于安全原因,您不应使用应用服务器这样做。

    如果您绑定到 0.0.0.0 或您的实际 IP 地址,您将能够使用 http://yourhost:2368/ 访问博客

    要在端口 80 上运行博客,请将 ip 和端口保持为 127.0.0.1:2368 并运行 apache 或 nginx 作为前端代理,这是以 root 身份运行的,但放弃了工作进程的权限。然后代理请求访问本地主机上的 node.js 服务器。

    另请注意,您的博客在http://yourhostname:2368/ 不可用的消息并不意味着它真的可以在那里访问,它只是配置中配置的 url(即哪个 url 将用于像 rss 这样的绝对链接)

    【讨论】:

      【解决方案2】:

      尝试将您的主机从 127.0.0.1 更改为 myurl:

      production: {
          url: 'http://myurl',
          mail: {},
          database: {
              client: 'sqlite3',
              connection: {
                  filename: path.join(__dirname, '/content/data/ghost.db')
              },
              debug: false
          },
          server: {
              // Host to be passed to node's `net.Server#listen()`
              // *** Change host value here ****
              host: 'myurl',
              // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
              port: '2368'
          }
      },
      

      在某些情况下,使用localhost 代替127.0.0.1 作为主机值也可以。

      这是我的 Ghost 开发设置过程:http://seanvbaker.com/a-ghost-workflow/

      【讨论】:

        猜你喜欢
        • 2016-03-28
        • 2013-09-12
        • 1970-01-01
        • 1970-01-01
        • 2012-12-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多