Ghost 是优秀的开源CMS系统,长期保持开源内容管理系统关注度首位。自2013年上线以来,一直保持快速增长,特别是从3.0版本以后,定位更加清晰,为独立出版商提供技术平台。在文本编辑、发布功能完善之后,最近上线了会员、订阅、评论等一系列帮助创作者引流、读沉淀、变现等实用功能。
Ghost 作为开源软件本身不收费,但要把它部署在服务器上,需要支付云资源使用费。Ghost背后的开发商提供一站式托管服务。当然,我们也可以把Ghost部署在自己的服务器上。对于独立创作者而言,流量一般不大,而可选择国内厂家的轻量主机和亚马逊的Lightsail。
Lightsail 包含虚拟主机、数据库、DNS托管、静态IP、CDN等功能,还可以一键部署Wordpres、Ghost等常用网络应用。非常适合中小开发者和意外爱好者。作为Ghost的长期用户,作者也选择把服务器迁移到Lightsail上。为方便有同样需求的爱好者使用方便,特把详细迁移过程记录下来。
sudo chmod 400 Lightsail-Key.pem
ssh -i Lightsail-Key.pem bitnami@ip
我们计划使用Lightsail CDN服务,还进行一些额外设置。
⒎Bitnami镜像Ghost站点的默认用户名user@example.com,登录密码通过以下命令获得。
cat bitnami_application_password
⒏通过7获得用户名和密码在过http://ip/ghost登录系统,并在个人账号设置下修改用户名和密码。
⒐配置邮箱服务器,以便发送密码修改、会员通知等。具体参考Ghost设置Mailgun指引。把在mailgun获得的密钥等信息,写入Ghost配置文件config.production.json。
cd /opt/bitnami/ghost
sudo vim config.production.json
// config.production.json
"mail": {
"transport": "SMTP",
"options": {
"service": "Mailgun",
"host": "smtp.mailgun.org",
"port": 465,
"secure": true,
"auth": {
"user": "发信邮箱",
"pass": "密码"
}
}
},
配置完后,重启Ghost
sudo /opt/bitnami/ctlscript.sh restart ghost
在Ghost后台Setting/Email newsletter中配置Mailgun configuration。根据页面指引获得Mailgun domain和Mailgun Private API key。
⒑设置CDN:在Lightsail首页“联网”中“创建分配”选择实例对应实例作为数据源,缓存行为选择“最适合Wordpress”(aws问题,其他模式无法进行高级缓存设置),选择“不缓存任何内容”,缓存行为先保持默认,在高级缓存设置,编辑“我指定的标头”,设置两个新项目X-Forwarded-Proto / X-Forwarded-For。其他保持不变。
此时,把Ghost后台域名改为自己的网站域名,在config.production.json 中把server修改服务器地址为http://your.domain.com。先设置为http访问,直接设置为https格式,会失败。
cd /opt/bitnami/ghost
sudo vim config.production.json
// config.production.json
"url": "http://your.domain.com",
配置完后,重启Ghost
sudo /opt/bitnami/ctlscript.sh restart ghost
设置ssl:编辑Apache配置,传递在CDN中设置的标头。
sudo vi /opt/bitnami/apache2/conf/httpd.conf
在如下位置添加RequestHeader set X-Forwarded-Proto "https"
#
# Avoid passing HTTP_PROXY environment to CGI's on this or
# backend servers which have lingering "httpoxy" defects.
# 'Proxy' request header is undefined by the IETF, not list
#
RequestHeader unset Proxy early
RequestHeader set X-Forwarded-Proto "https"
配置完后,重启Ghost
sudo /opt/bitnami/ctlscript.sh restart ghost
sudo /opt/bitnami/ctlscript.sh restart apache
cd /opt/bitnami/ghost
sudo vim config.production.json
// config.production.json
"url": "https://your.domain.com",
配置完后,重启Ghost
sudo /opt/bitnami/ctlscript.sh restart ghost
cd /opt/bitnami/ghost
sudo su ghost -c "ghost update"
镜像为V4.44.0,先升级到V4.48,再升级到V5。
sudo su ghost -c "ghost update v4"
sudo su ghost -c "ghost update v5"
如遇.ghost-cli权限不足,按如下修复
sudo chmod 777 /opt/bitnami/ghost
sudo chown -R ghost:ghost /opt/bitnami/ghost/.ghost-cli
sudo /opt/bitnami/ctlscript.sh restart ghost
sudo /opt/bitnami/ctlscript.sh restart apache
如遇如下升级错误
Knex: run
$ npm install mysql --save
Cannot find module 'mysql'
Require stack:
在ghost 文件夹执行如下命令后,再次升级
sudo npm install mysql --force
cd /opt/bitnami/ghost
sudo chmod 775 content/images
sudo chown sftpuser:sftpuser content/images
sudo /opt/bitnami/ctlscript.sh restart ghost
An error occurred.Message: 'EACCES: permission denied, open '/opt/bitnami/ghost/.ghost-cli'' /opt/bitnami/ghost/content/images/2022/09/
需要赋予ghost操作权限。
cd /opt/www/ghost
sudo chmod 777 content/images
sudo chown -R ghost:ghost content/images
sudo /opt/bitnami/ctlscript.sh restart
css|js|jpg|jpeg|gif|ico|png|bmp|pict|csv|doc|pdf|pls|ppt|tif|tiff|eps|ejs|swf|midi|mid|ttf|eot|woff|otf|svg|svgz|webp|docx|xlsx|xls|pptx|ps|class|jar
至此,在亚马逊lightsail上部署Ghost完成。
页面更新:2024-04-29
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号