这周摸索着网站的建设,终于在今天成功上线!这里要谢谢ghost中文网和群里的网友,他的博客在这opengiser。他们的帮助太重要了。现在把过程记录下来,共同学习。试运营地址在edwardesire。 现在放ACE上了


  1. 下载安装包

    总共需要下载2个东西。
  1. 新建BAE工程

    在百度开发云平台的管理控制台下一次点击:开发者服务管理->创建工程->创建->应用引擎-添加部署-创建。这样nodejs的环境就建好了。这里一起把数据库也建立起来。这里我使用的是mysql,点击应用引擎中的扩展服务即可,添加新服务当然使用免费版的咯。

  2. 配置

    接下来就是在本地把源码配置好咯。将工程clone下来后,用ghost源码覆盖掉。在本地运行命令npm install,后将下载好的mysql覆盖掉node_modules下原有的。然后打开根目录的config.example.js将database段修改为如下:

      production: {
    database: {
    client: 'mysql',
    connection: {
    host: 'sqld.duapp.com',
    port: 4050,
    user: '#####', //你的ak
    password: '#####', //你的sk
    database: '#####',//数据库名
    charset: 'utf8'
    },
    debug: false
    },
    server: {
    host: '127.0.0.1',
    port: '18080'
    }
    }

    最后再修改根目录的config.example.js。修改启动命令,将"start": "node index"改为"start": "node index.js"。并去掉依赖dependencies、optionalDependencies、devDependencies这三项。

  3. 修改5.0中与BAE不兼容的部分

    按照q友悟道所说需要注释掉core/server/index.js中305行的ghostStartMessages()。原因是这个方法的内部与BAE不兼容。

  4. 图像存储问题

    在package.json中的dependencies添加七牛的依赖包,在config.example.js中production和添加:

     qiniu: {
    bucketname: '#####', //七牛云的目录名
    ACCESS_KEY: '#####', //七牛云的ak
    SECRET_KEY: '#####', //七牛云的sk
    root: '/image/',
    prefix: 'http://' //七牛的空间域名
    }

最后在core/server/storage做两个操作

+ 覆盖index.js文件

        var errors = require('../errors'),
storage; var qiniuConfig = require('../config/').qiniu; function get_storage() {
// TODO: this is where the check for storage apps should go
// Local file system is the default
var storageChoice = qiniuConfig? 'qiniu':'localfilesystem';
if (storage) {
return storage;
}
try {
// TODO: determine if storage has all the necessary methods
storage = require('./' + storageChoice);
} catch (e) {
errors.logError(e);
}
return storage;
}
module.exports.get_storage = get_storage;
+ 并添加一个qiniu.js文件 // # Local File System Image Storage module
// The (default) module for storing images, using the local file system var _ = require('lodash'),
express = require('express'),
fs = require('fs-extra'),
nodefn = require('when/node/function'),
path = require('path'),
when = require('when'),
config = require('../config'),
errors = require('../errors'),
baseStore = require('./base'),
crypto = require('crypto'),
qiniu = require('qiniu'),
qiniuConfig = config.qiniu,
qiniuStore;
qiniu.conf.ACCESS_KEY = qiniuConfig.ACCESS_KEY;
qiniu.conf.SECRET_KEY = qiniuConfig.SECRET_KEY;
qiniu.conf.USER_AGENT = 'Ghost 0.4.2';
var putPolicy = new qiniu.rs.PutPolicy(qiniuConfig.bucketname),
uptoken = putPolicy.token();
qiniuStore = _.extend(baseStore, {
// ### Save
// Saves the image to storage (the file system)
// - image is the express image object
// - returns a promise which ultimately returns the full url to the uploaded image
'save': function (image) {
var saved = when.defer(),
md5sum = crypto.createHash('md5'),
ext = path.extname(image.name),
targetDirRoot = qiniuConfig.root,
targetFilename,
key,
extra = new qiniu.io.PutExtra();
var savedpath = path.join(config.paths.imagesPath, image.name);
nodefn.call(fs.copy, image.path, savedpath).then(function(){
return nodefn.call(fs.readFile, savedpath);
}).then(function(data) {
md5 = md5sum.update(data).digest('hex');
targetFilename = path.join(targetDirRoot, md5.replace(/^(\w{1})(\w{2})(\w+)$/, '$1/$2/$3')) + ext;
targetFilename = targetFilename.replace(/\\/g, '/');
key = targetFilename.replace(/^\//, '');
return nodefn.call(qiniu.io.put, uptoken, key, data, extra);
}).then(function () {
return nodefn.call(fs.unlink, savedpath).then(function(){
return nodefn.call(fs.unlink, image.path);
}).otherwise(errors.logError);
}).then(function () {
// prefix + targetFilename
var fullUrl = qiniuConfig.prefix + targetFilename;
return saved.resolve(fullUrl);
}).otherwise(function (e) {
errors.logError(e);
return saved.reject(e);
});
return saved.promise;
},
'exists': function (filename) {
// fs.exists does not play nicely with nodefn because the callback doesn't have an error argument
var done = when.defer();
fs.exists(filename, function (exists) {
done.resolve(exists);
});
return done.promise;
},
// middleware for serving the files
'serve': function () {
var ONE_HOUR_MS = 60 * 60 * 1000,
ONE_YEAR_MS = 365 * 24 * ONE_HOUR_MS;
// For some reason send divides the max age number by 1000
return express['static'](config.paths.imagesPath, {maxAge: ONE_YEAR_MS});
}
}); module.exports = qiniuStore; 最后注释掉fonts.googleapis相关的字体加载,就可以上传代码、发布咯。
  1. Next

    个人觉得需要文章分类归档archive评论区,接下来就是搞定他们了。

!参考学习

  1. 开源GIS人上的ghost5.0部署文章
  2. 中文网教程
  3. BAE新手入门

成功在BAE上部署ghost 5.0的更多相关文章

  1. BAE上部署Ghost 0.5.1注意事项

    BAE上部署Ghost可参考基本安装上述安装使用的是ghost0.4.7版本 在ghost 0.5 中为了解决测试时事件侦听器过多引发的警告,在注册single事件时,将代码由原先的 process. ...

  2. 在CentOS 7上部署Ghost博客

    作者:waringid 一.简介 跟静态博客不同的是,Ghost 这种轻量级的动态博客,有一个管理后台,可以直接写作和管理博客.本质上,跟 WordPress 是相通的,只是 Ghost 搭建在 No ...

  3. 在BAE上部署Pomelo

    BAE升级到3.0后顿时感觉好用了很多,俨然云主机的感觉. 底下我将分享我在BAE上部署Pomelo的过程. 首先需要拥有一个BAE的执行单元.没有的可以自行百度并部署. 接着svn得出代码到本地.此 ...

  4. 关于在BAE上部署ThinkPHP框架的问题

    现在有点小兴奋,因为在在BAE上部署ThinkPHP框架的问题快折腾一天了,午觉都没睡,不过没白整总算有点结果.不扯淡了,直入正题吧. 之前熟悉ThinkPHP框架,想在BAE上用ThinkPHP做点 ...

  5. Coding上部署Ghost博客

    Ghost构建于Node.js平台之上.支持0.10.*版本号的Node.js. 在你的本地计算机上执行Ghost事实上非常easy,前提是你已经安装了Node.js. 什么是Node.js? 略过 ...

  6. 那些在BAE上部署node.js碰到的坑

    在BAE上使用node.js半年多了,其中碰到了不少因为BAE云环境限制碰到的坑 写下来大家碰到了,也不用那么麻烦的去看好几天代码了,直接对症下药 官方公布的坑有: BAE是使用package.jso ...

  7. IIS 6.0上部署.NET 4.0网站

    最近需要把VS2010开发的网站部署到Windows Server 2003的服务器上去, Windows Server 2003操作系统自带的为IIS 6.0,IIS 6.0一般只支持.NET 2. ...

  8. 在CentOS上部署kubernetes1.9.0集群

    原文链接: https://jimmysong.io/kubernetes-handbook/cloud-native/play-with-kubernetes.html (在CentOS上部署kub ...

  9. Ubuntu上部署Ghost博客

    所有文章搬运自我的个人主页:sheilasun.me 刚刚成功把自己的ghost博客部署到Linode VPS上了,在这里回顾并顺便整理一下从购买域名到部署代码到服务器的整个过程. 购买域名 万网或者 ...

随机推荐

  1. onClick(View) of type new View.OnClickListener(){} must override a superclass method

    原地址:http://blog.csdn.net/aeolus1019/article/details/8014798 Android开发过程中代码错误报错如下: - implements andro ...

  2. python time相关操作

    1.获取当前时间的两种方法: 代码如下: import datetime,timenow = time.strftime("%Y-%m-%d %H:%M:%S")print now ...

  3. 【leetcode】Longest Substring Without Repeating Characters (middle)

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  4. Spring mvc 模式小结

    http://www.taobaotesting.com/blogs/2375 1.spring mvc简介 Spring MVC框架是一个MVC框架,通过实现Model-View-Controlle ...

  5. ubuntu12 开机自动转到命令行

    命令: sudo gedit /etc/default/grub 找到这一行 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"改成 GRUB_CM ...

  6. MAT使用总结

    最近在做项目的时候遇到一个内存泄漏,最后通过MAT定位了问题, 先介绍一下MAT的一些基本概念: Shallow Heap:对象本身占用内存的大小,不包含对其他对象的引用,也就是对象头加成员变量(不是 ...

  7. shell中截取字符串的方法总结

    shell中截取字符串的方法有很多种, ${expression}一共有9种使用方法. ${parameter:-word} ${parameter:=word} ${parameter:?word} ...

  8. 李洪强iOS开发之静态库

    iOS开发拓展篇—静态库 一.简单介绍 1.什么是库? 库是程序代码的集合,是共享程序代码的一种方式 2.库的分类 根据源代码的公开情况,库可以分为2种类型 (1)开源库 公开源代码,能看到具体实现 ...

  9. ArcGIS学习记录—Arcgis中点、线、面的相互转换方法

    本文使用的工具在Arctoolbox.Data Management Tools.Features (一)面--面转线.面转点 面转线  Polygon To Line .Feature To Lin ...

  10. cache设计,以及多核造成的不一致性以及解决方案

    http://www.360doc.com/content/11/1013/00/1317564_155625188.shtml http://blog.csdn.net/muxiqingyang/a ...