更新-这些说明已过时!(UPDATE - These instructions are out of date!)

一键安装Ghost到Azure技术。 (GO HERE for a one-click installation of Ghost to Azure technique.)

Like many folks, I watched the recent Kickstarter for the nodejs-based Ghost Blogging Platform with great interest. There are lots of folks, myself included, who believe that WordPress has jumped from blog to complete and complex CMS, and there's value in a simple platform for "just blogging."

像许多人一样,我对基于nodejs的Ghost Blogging平台最近的Kickstarter感兴趣。 有很多人,包括我自己在内,都相信WordPress已经从博客跃升为完整而复杂的CMS,并且一个简单的平台(“仅博客”)具有价值。

SIDE NOTE: Every time a post something I get at least 4 emails from well-meaning readers about how my spelling and grammar sucks. And I appreciate you all. For a few posts, I'm trying an online service called Grammarly that promises to be 10x better than word processors in proofreading. 10x is like 9 x's more than 1 x and it's clearly a much more bigger number. We shall be seeing how it do. ;) (Of course, Grammarly HATED this paragraph.)

旁注:每次发帖时,我都会收到至少4封来自好心读者的有关我的拼写和语法如何糟糕的电子邮件。 我感谢大家。 对于一些帖子,我正在尝试一个名为Grammarly的在线服务,该服务在校对方面比文字处理程序好10倍。 10倍比9倍多1倍,显然是更大的数字。 我们将看到它的工作方式。 ;) (当然,语法禁止此段。)

Ghost is very minimal, evocative of Medium in style and essence. Ghost is basic and clean publishing, plus it's open source and being very actively developed on GitHub. As of the time of this writing, it's version 0.3.3, and I will do my best to keep this blog post up to date. Things are moving fast.

鬼魂极少,令人回味中等风格。 Ghost是基本且干净的发布方式,另外它是开源的,并且正在GitHub上非常活跃地开发。 在撰写本文时,它的版本为0.3.3,我将尽力使此博客文章保持最新状态。 事情发展很快。

It'd be nice to get Ghost running on Azure, and since it's a reasonably complex node application, it's good exercise for everyone. Jeremiah Billmann and a number of others have been working on some of the small compatibility issues (like image uploads and pathing), and soon we'll be able to get Ghost up and running in just a few commands. Jeremiah has a great writeup here. He and I spent part of the afternoon Skyping and pairing and trying alternate ways to get Ghost running. My instructions are different and not meant to take away from his. There's more than one way to deploy a site.

让Ghost在Azure上运行非常好,并且由于它是一个相当复杂的节点应用程序,因此对所有人来说都是不错的练习。 耶利米·比尔曼( Jeremiah Billmann)和其他一些人一直在解决一些小的兼容性问题(例如图像上传和路径),很快我们就可以通过几个命令启动并运行Ghost。 耶利米在这里有很多文章。 我和他度过了整个下午的一部分,进行了Skyping和配对,并尝试了其他方法使Ghost运行。 我的指示是不同的,并不意味着要摆脱他的指导。 部署网站有多种方法。

I'll point out workarounds, and again, remove them (strike them out) as Ghost takes PRs. (BTW, the Ghost Team is SO NICE. So nice.)

我将指出解决方法,然后在Ghost进行PR时将其删除(删除)。 (顺便说一句,Ghost团队非常棒。太好了。)

在Azure网站上安装Ghost (Installing Ghost on Azure Web Sites)

I'm using Windows, but these commands should also work on Macs.

我正在使用Windows,但是这些命令在Mac上也应该可以使用。

IMPORTANT CHOICE: You can just go download Ghost at https://ghost/download/ and everything comes pre-built. If you download it, you can SKIP getting Grunt, Ruby, Sass, below. Just get node, and move to the Configuring Ghost before you Deploy section further down! Otherwise, if you "git clone" like I did, you're doing stuff manually, certainly more than is needed, but perhaps learning more about node. So, want it prebuilt and ready to go? Download Ghost. Learning, hacking? git clone https://github/TryGhost/Ghost.git.

重要选择:可以在https://ghost/download/上下载Ghost,所有内容均已预先构建。 如果下载它,则可以跳过下面的Grunt,Ruby,Sass。 只需获取节点,然后再向下部署部分,移至“配置Ghost” ! 否则,如果像我一样“ git clone”,那么您将手动进行操作,这肯定比需要做的要多,但是也许会更多地了解节点。 因此,是否要对其进行预建并准备就绪? 下载Ghost 。 学习,黑客? git clone https://github/TryGhost/Ghost.git 。

先决条件 (Prerequisites)

To start, you'll want these things locally:

首先,您需要在本地进行以下操作:

  • nodejs - Get 0.10 or above. Install from http://nodejs

    nodejs-获得0.10或更高从http://nodejs安装

    • Then get the node Azure command line

      然后获取节点Azure命令行

      • npm install azure-cli --g

        npm安装azure-cli –g

    nodejs - Get 0.10 or above. Install from http://nodejs

    nodejs-获得0.10或更高从http://nodejs安装

  • Git - Get it from http://git-scm/downloads

    Git-从http://git-scm/downloads获取

        Git - Get it from http://git-scm/downloads

        Git-从http://git-scm/downloads获取

      • Get Grunt

        发牢骚

        • npm install grunt-cli --g

          npm安装grunt-cli –g
      • ruby - Get 2.0 or above. Install from https://www.ruby-lang

        Ruby-获得2.0或以上。 从https://www.ruby-lang安装

            ruby - Get 2.0 or above. Install from https://www.ruby-lang

            Ruby-获得2.0或以上。 从https://www.ruby-lang安装

          • Bourbon and Sass. Bourbon brings in Sass.

            波旁威士忌和萨斯。 波旁威士忌带来萨斯。

            • gem install bourbon

              宝石安装波旁威士忌
          • Get an Azure Trial if you don't have one.

            如果没有,请进行一次Azure试用。

            • You get 10 websites free and can run whatever you want, node, php, ASP.NET, etc.

              您可以免费获得10个网站,并且可以运行任何您想要的网站,节点,php,ASP.NET等。

            Get an Azure Trial if you don't have one.

            如果没有,请进行一次Azure试用。

          设置Azure命令行 (Setup the Azure Command Line)

          Connect the Azure CLI (command line interface) to your account like this:

          像这样将Azure CLI(命令行界面)连接到您的帐户:

          • azure account download

            天蓝色帐户下载

            • launches browser, sign in, get cert

              启动浏览器,登录,获取证书
          • azure account  import

            天蓝色帐户导入

          • [optional] azure account set "account name"

            [可选]天蓝色帐户设置“帐户名称”

          变鬼 (Getting Ghost)

          You can either download Ghost prebuilt or get the source and build it. Here's both ways. The Source is harder, but I learned some things.

          您可以下载预先构建的Ghost或获取源代码并进行构建。 这是两种方式。 Source比较难,但是我学到了一些东西。

          从下载获取幽灵 (Getting Ghost from Download)

          Download Ghost and unzip it into a folder.

          下载Ghost并将其解压缩到文件夹中。

          > azure site create [Site Name] --location "West US" --git
          # note that this line setups the "git remote add..." and you can confirm with "git remote show"
          > azure site config add NODE_ENV=production
          # sets an env var for node, up in azure
          > npm install
          # get all the modules locally, only needed if you are running locally
          > copy con server.js
          var GhostServer = require('./index');
          CTRL-Z, ENTER
          # Ghost uses index.js, not server.js. Make a server.js.

          Now, skip over this to the Configuring section. The --git switch above set up your remote git repo in Azure.

          现在,将其跳过到“配置”部分。 上面的--git开关在Azure中设置远程git存储库。

          从源头获取鬼魂 (Getting Ghost from Source)

          Now, run these commands from the command line. Read carefully, and think. You can change Site Name, Location. You can confirm the git remote. Things with # are my comments, don't type them. Note the copy con. Don't like it? Use a text editor.

          现在,从命令行运行这些命令。 仔细阅读,然后思考。 您可以更改站点名称,位置。 您可以确认git remote。 带#号的内容是我的评论,请不要输入。 注意副本副本。 不喜欢吗使用文本编辑器。

          > git clone https://github/TryGhost/Ghost.git
          > azure site create [Site Name] --location "West US" --git
          # note that this line setups the "git remote add..." and you can confirm with "git remote show"
          > azure site config add NODE_ENV=production
          # sets an env var for node, up in azure
          > npm install
          # get all the modules locally
          > grunt init
          > grunt prod
          #preps your CSS and JS
          > copy con server.js
          var GhostServer = require('./index');
          CTRL-Z, ENTER
          # Ghost uses index.js, not server.js. Make a server.js.

          At this point, you have a site running in Azure with nothing in it.

          此时,您有一个没有任何内容在Azure中运行的网站。

          You currently have a local Git repo with a Git Remote pointing to Azure.

          当前,您有一个本地Git存储库,其中有一个指向Azure的Git Remote。

          部署之前配置Ghost (Configuring Ghost before you Deploy)

          Your cloned Ghost includes a config.example.js. I renamed it to config.js and made a few changes.

          您克隆的Ghost包含config.example.js。 我将其重命名为config.js并进行了一些更改。

          production: {
          url: 'http://YOURSITE.azurewebsites/',
          mail: {
          transport: 'SMTP',
          options: {
          auth: {
          user: 'poop',
          pass: 'alsopoop'
          }
          }
          },
          database: {
          client: 'sqlite3',
          connection: {
          filename: path.join(__dirname, '/content/data/ghost.db')
          },
          debug: false
          },
          server: {
          host: '127.0.0.1',
          port: process.env.PORT
          }
          }

          Go to the production section, check your URL, your user/pass for mail (mine is invalid, I'll do it later), and check the port: section. Make it "process.env.PORT" which is what Azure uses to get the Port number.

          转到生产部分,检查您的URL,您的用户/密码是否通过(我的是无效的,稍后再处理),然后检查port:部分。 将其设置为“ process.env.PORT”,Azure会使用它来获取端口号。

          Now open your .gitignore, comment out these lines. enabling you to check in these files and directories.

          现在打开您的.gitignore,注释掉这些行。 使您可以检入这些文件和目录。

          # /core/client/assets/css
          # /core/built
          # /core/client/assets/fonts
          # config.js

          When you ran grunt prod earlier, it built files into /core/built, that's why we need that checked in.

          早先运行grunt prod时,它会将文件内置到/ core / built中,这就是为什么我们需要将其签入的原因。

          NOTE: Of course, we are using Git for deployment. If you don't want to use Git, you can just FTP the files into Azure.

          注意:当然,我们使用Git进行部署。 如果您不想使用Git,则可以将文件通过FTP传输到Azure。

          部署 (Deploy)

          Now, add, commit, push.

          现在,添加,提交,推送。

          > git add .
          > git commit -m "hope this works"
          > git push azure master

          Azure (specifically the Kudu subsystem) will run npm install, so this deployment may take a while. You can watch it live in the Azure Portal if you like.

          Azure(特别是Kudu子系统)将运行npm install,因此此部署可能需要一段时间。 如果愿意,可以在Azure门户中实时观看。

          You can also look at deployments from the command line:

          您还可以从命令行查看部署:

          C:\Ghost>azure site deployment list hanselmanghost
          info: Executing command site deployment list
          + Getting deployments
          data: Time Commit id Status Author Message
          data: ------------------- ---------- ------ --------------- ----------------
          data: 2013-10-23 15:59:38 783746f6a1 Active Scott Hanselman adding server.js
          info: site deployment list command OK

          OK. It's deployed...except, today...there's a bug.

          好。 它已经部署了……除了今天……有一个错误。

          截至10月23日的大黑客... 此事件已关闭并合并! ( The Big Hack as of October 23rd... THIS HAS BEEN CLOSED AND MERGED!)

          Here's the hack/workaround. There's a node module called Express-HBS that is a handlebars template engine that supports partials. It has a caching bug, but there's been a Pull Request opened for express-hbs with the fix. As soon as that fix gets merged in, this whole workaround just goes away.

          这是hack /解决方法。 有一个称为Express-HBS的节点模块,它是一个支持局部的车把模板引擎。 它具有一个缓存错误,但 已为 带有修复的 express-hbs打开了“拉取请求 ”。 一旦修复程序被合并,整个解决方法就消失了。

          But, for now, you need to patch the express-hbs/lib/hbs.js with this version ( link to RAW file )

          但是,现在,您需要 使用此版本 修补express-hbs / lib / hbs.js ( 链接到RAW文件 )

          How do you patch this in Azure? You can either FTP it, or use this super-secret Azure Kudu DebugConsole that is public but no one has noticed it yet.

          您如何在Azure中对此进行修补? 您可以通过FTP, 或者使用超级秘密天青捻DebugConsole是公众,但没有人注意到它。

          Visit https://YOURSITEHERE.scm.azurewebsites/DebugConsole/ in your browser. The name and password are the same as your Git Deployment name and password.

          在浏览器中 访问 https://YOURSITEHERE.scm.azurewebsites/DebugConsole/ 名称和密码与您的Git部署名称和密码相同。

          Navigate to site/wwwroot/node_modules/express-hbs/lib by clicking folders . Click the Edit button, which brings you to a live multiline textbox. Copy paste the patched hbs.js into the textbox, and click Save.

          通过单击文件夹导航到site / wwwroot / node_modules / express-hbs / lib 单击编辑按钮,这将带您进入实时多行文本框。 复制将修补的hbs.js粘贴到文本框中,然后单击“保存”。

          Once you've patched hbs.js, you're all good. Go hit http://YOURSITE.azurewebsites/ghost and sign in.

          修补好hbs.js后,一切都很好。 转到http://YOURSITE.azurewebsites/ghost并登录。

          Where are the images for my posts stored? They are right there on the file system where Ghost put them. Here's me remoted into the Azure WebSite with the Kudu Debug Console. There's the images.

          我的帖子的图像存储在哪里? 它们就在Ghost放置它们的文件系统上。 这是我使用Kudu调试控制台远程访问Azure WebSite的方法。 有图像。

          You might not want to scale this website out to more than once instance, as you'll have file contention, but you could certainly scale it up. Since it does so little, I don't see Ghost having much trouble scaling to the average blog's traffic.

          您可能不希望将该网站扩展到多个实例,因为您将遇到文件争用,但是您当然可以将其扩展。 既然它做的很少,我认为Ghost在扩展到平均博客流量方面不会有太大麻烦。

          Myself, Jeremiah, and lots of other folks are going to work on getting Ghost up and running even easier. Once that hack is gone, there's about 2 or 3 steps could be removed and this will be really quite streamlined. I've got some ideas about using Custom Azure Websites Deployment Scripts to move the Grunt build steps into Azure. They would happen after the push. We'll see!

          我自己,耶利米和其他许多人将致力于使Ghost的启动和运行变得更加轻松。 骇客破解之后,大约2到3步可以删除,这实际上是非常简化的。 我对使用自定义Azure网站部署脚本将Grunt构建步骤移到Azure中有一些想法。 他们将在推动之后发生。 我们拭目以待!

          Have fun, I am! Also, check out http://friday.azure, my new show where I learn Azure from the folks that built it..ing soon!

          玩得开心,我是! 另外,请访问http://friday.azure ,这是我的新节目,我在这里从构建Azure的人们那里学习Azure ...即将推出!

          UPDATE: Felix Rieseberg built an Azure Ghost Updater! Try using it to update your Ghost installations on Azure!

          更新: Felix Rieseberg构建了一个Azure Ghost更新器! 尝试使用它来更新Azure上的Ghost安装!

          翻译自: https://www.hanselman/blog/how-to-install-the-nodejs-ghost-blogging-software-on-azure-websites

          更多推荐

          如何在Azure网站上安装Node.js Ghost博客软件