Config

For self-hosted Ghost users, a custom configuration file can be used to override Ghost's default behaviour. This provides you with a range of options to configure your publication to suit your needs.

对于自承载的Ghost用户,可以使用自定义配置文件覆盖Ghost的默认行为。这为您提供了一系列选项来配置您的发布以满足您的需要。

Overview概述

When you install Ghost using the supported and recommended method using ghost-cli, a custom configuration file is created for you by default. There are some configuration options which are required by default, and many optional configurations.

The three required options are url and database which are configured during setup, and mail which needs to be configured once you've installed Ghost.

This article explains how to setup your mail config, as well as walk you through all of the available config options.

当您使用支持和推荐的使用Ghost -cli的方法安装Ghost时,默认情况下会为您创建一个自定义配置文件。默认情况下需要一些配置选项和许多可选配置。

三个必需的选项是在安装过程中配置的url和数据库,以及安装Ghost后需要配置的邮件。

本文将解释如何设置邮件配置,并介绍所有可用的配置选项。

Custom configuration files自定义配置文件

The configuration is managed by nconf. A custom configuration file must be a valid JSON file located in the root folder and changes to the file can be implemented using ghost restart.

Since Node.js has the concept of environments built in, Ghost supports two environments: development and production. All public Ghost publications run in production mode, while development mode can be used to test or build on top of Ghost locally.

配置由nconf管理。自定义配置文件必须是位于根文件夹中的有效JSON文件,可以使用ghost restart实现对该文件的更改。

因为Node.js有内建环境的概念,所以Ghost支持两种环境:开发和生产。所有的公共Ghost出版物都是在生产模式下运行,而开发模式可以在本地测试或构建Ghost。

Check out the official install guides for development and production.

查看开发和生产的官方安装指南。

The configuration files reflect the environment you are using:

配置文件反映了你使用的环境

  • config.development.json
  • config.production.json

Ghost in development

If you would like to start Ghost in development, you don't have to specify any environment, because development is default. To test Ghost in production, you can use:

如果您想在开发中启动Ghost,您不必指定任何环境,因为development是默认的。要在生产中测试Ghost,可以使用:

  1. NODE_ENV=production node index.js

Debugging the configuration output 调试配置输出

Start Ghost with:

  1. DEBUG=ghost:*,ghost-config node index.js

Running Ghost with config env variables  使用配置环境变量运行Ghost

Start Ghost using environment variables which match the name and case of each config option:

使用与每个配置选项的名称和大小写匹配的环境变量启动Ghost

  1. url=http://ghost.local:2368 node index.js

For nested config options, separate with two underscores:

嵌套的配置选项,用两个下划线分开:

  1. database__connection__host=mysql node index.js

Configuration options

There are a number of configuration options which are explained in detail in this article. Below is an index of all configuration options:

有许多配置选项将在本文中详细解释。以下是所有配置选项的索引:

Name Required? Description
url In production Set the public URL for your blog
database In production Type of database used (default: MySQL)
mail In production Add a mail service
admin Optional Set the protocol and hostname for your admin panel
server Optional Host and port, or socket for Ghost to listen on
privacy Optional Disable features set in privacy.md
paths Optional Customise internal paths
referrerPolicy Optional Control the content attribute of the meta referrer tag
useMinFiles Optional Generate assets url with .min notation
storage Optional Set a custom storage adapter
scheduling Optional Set a custom scheduling adapter
logging Optional Configure logging for Ghost
spam Optional Configure spam settings
caching Optional Configure caching settings
compress Optional Disable compression of server responses
imageOptimization Optional Configure image manipulation and processing

URL

(Required in production)

Once a Ghost publication is installed, the first thing to do is set a url. When installing using ghost-cli the install process request the URL during the setup process.

Enter the URL that is used to access your publication. If using a subpath, enter the full path, https://example.com/blog/. If using SSL, always enter the URL with https://.

SSL

We always recommend using SSL to run your Ghost publication in production. Ghost has a number of configuration options for working with SSL, and securing the URLs for the admin /ghost/ and the frontend of your publication. Without SSL your username and password are sent in plaintext.

ghost-cli prompts to setup SSL during the installation process. After a successful ssl setup, you can find your ssl certificate in /etc/letsencrypt.

If you see errors such as access denied from url, then the provided URL in your config file is incorrect and needs to be updated.

Database

(Required in production)

Ghost is configured using MySQL by default:

  1. "database": {
  2. "client": "mysql",
  3. "connection": {
  4. "host": "127.0.0.1",
  5. "port": 3306,
  6. "user": "your_database_user",
  7. "password": "your_database_password",
  8. "database": "your_database_name"
  9. }
  10. }

Alternatively you can configure sqlite3:

  1. "database": {
  2. "client": "sqlite3",
  3. "connection": {
  4. "filename": "content/data/ghost-test.db"
  5. },
  6. "useNullAsDefault": true,
  7. "debug": false
  8. }

Number of connections

It's possible to limit the number of simultaneous connections using the pool setting. The default values are a minimum of 2 and a maximum of 10, which means Ghost always maintains two active database connections. You can set the minimum to 0 to prevent this:

  1. "database": {
  2. "client": ...,
  3. "connection": { ... },
  4. "pool": {
  5. "min": 2,
  6. "max": 20
  7. }
  8. }

SSL

In a typical Ghost installation the MySQL database will be on the same server as Ghost itself. With cloud computing and database-as-a-service providers you might want to enable SSL connections to the database.

If your Certificate CA or the CA of your database provider is in the Mozilla trusted CA list you can enable SSL by adding "ssl": true to the database connection configuration:

  1. "database": {
  2. "client": "mysql",
  3. "connection": {
  4. "host": "your_cloud_database",
  5. "port": 3306,
  6. "user": "your_database_user",
  7. "password": "your_database_password",
  8. "database": "your_database_name",
  9. "ssl": true
  10. }
  11. }

This has been confirmed to work with Azure Database for MySQL. To find out if your provider is supported see the Mozilla Included CA Certificate List.

For Amazon RDS you'll need to configure the connection with "ssl": "Amazon RDS":

  1. "database": {
  2. "client": "mysql",
  3. "connection": {
  4. "host": "your_cloud_database",
  5. "port": 3306,
  6. "user": "your_database_user",
  7. "password": "your_database_password",
  8. "database": "your_database_name",
  9. "ssl": "Amazon RDS"
  10. }
  11. }

Custom or self-signed certificates are a little more advanced. You'll need to output your CA certificate (not your CA private key) as a single line string including literal new line characters \n (you can get the single line string with awk '{printf "%s\\n", $0}' CustomRootCA.crt) and add it to the configuration:

  1. "database": {
  2. "client": "mysql",
  3. "connection": {
  4. "host": "your_cloud_database",
  5. "port": 3306,
  6. "user": "your_database_user",
  7. "password": "your_database_password",
  8. "database": "your_database_name",
  9. "ssl": {
  10. "ca": "-----BEGIN CERTIFICATE-----\nMIIFY... truncated ...pq8fa/a\n-----END CERTIFICATE-----\n"
  11. }
  12. }
  13. }

For a certificate chain, include all CA certificates in the single line string:

  1. "database": {
  2. "client": "mysql",
  3. "connection": {
  4. "host": "your_cloud_database",
  5. "port": 3306,
  6. "user": "your_database_user",
  7. "password": "your_database_password",
  8. "database": "your_database_name",
  9. "ssl": {
  10. "ca": "-----BEGIN CERTIFICATE-----\nMIIFY... truncated ...pq8fa/a\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\nMIIFY... truncated ...wn8v90/a\n-----END CERTIFICATE-----\n"
  11. }
  12. }
  13. }

Mail

(Required in production)

The most important piece of configuration once you've been through the install process is to setup mail. Mail configuration allows Ghost to send emails such as lost password and user invite emails, or member signup emails if you're running a membership publication with Ghost.

Ghost uses Nodemailer 0.7 under the hood, and tries to use the direct mail service if available - but a more reliable solution is to setup mail using an external service.

Setup an email sending account

Choose an external email service and sign up and verify your account. We highly recommend using Mailgun which allows up to 10,000 emails per month for free.

Configure mail with Mailgun

Mailgun allows you to use your own domain for sending transactional emails. Otherwise you can use a subdomain that Mailgun provide you with (also known as the sandbox domain, limited to 300 emails per day). You can change this at any time.

Make a note of your domain information

Once your domain is setup, find your new email service SMTP username and password that has been created for you (this is not the ones you used to sign up for Mailgun with). You can find this under "Domain Information" and make a note of the following details:

  • Default SMTP login
  • Default password

Update your config.production.json file

Open your production config file in any code editor and paste the username and password you just copied into the defined fields, for example:

  1. "mail": {
  2. "transport": "SMTP",
  3. "options": {
  4. "service": "Mailgun",
  5. "auth": {
  6. "user": "postmaster@example.mailgun.org",
  7. "pass": "1234567890"
  8. }
  9. }
  10. }

Once you are finished, hit save and then run ghost restart for your changes to take effect. It is possible to reuse your settings for a development environment if you have both, by making the same changes to config.development.json.

Secure connection

According your Mailgun settings you may want to force secure connection and the SMTP port.

  1. "mail": {
  2. "transport": "SMTP",
  3. "options": {
  4. "service": "Mailgun",
  5. "host": "smtp.eu.mailgun.org",
  6. "port": 465,
  7. "secureConnection": true,
  8. "auth": {
  9. "user": "postmaster@example.mailgun.org",
  10. "pass": "1234567890"
  11. }
  12. }
  13. }

Amazon SES

It's also possible to use Amazon Simple Email Service. Use the SMTP username and password given when signing up and configure your config.[env].json file as follows:

  1. "mail": {
  2. "transport": "SMTP",
  3. "options": {
  4. "host": "YOUR-SES-SERVER-NAME",
  5. "port": 465,
  6. "service": "SES",
  7. "auth": {
  8. "user": "YOUR-SES-ACCESS-KEY-ID",
  9. "pass": "YOUR-SES-SECRET-ACCESS-KEY"
  10. }
  11. }
  12. }

From address

By default the 'from' address for mail sent from Ghost is set to the title of your publication, for example <noreply@your-publication.com>. To override this to something different, use:

  1. "mail": {
  2. "from": "support@example.com",
  3. }

A custom name can also optionally be provided:

  1. "mail": {
  2. "from": "'Acme Support' <support@example.com>",
  3. }

Try to use a real, working email address - as this greatly improves delivery rates for important emails sent by Ghost (Like password reset requests and user invitations). If you have a company support email address, this is a good place to use it.

Admin URL

Admin can be used to specify a different protocol for your admin panel or a different hostname (domain name). It can't affect the path at which the admin panel is served (this is always /ghost/).

  1. "admin": {
  2. "url": "http://example.com"
  3. }

Server

The server host and port are the IP address and port number that Ghost listens on for requests. By default, requests are routed from port 80 to Ghost by nginx (recommended), or apache.

  1. "server": {
  2. "host": "127.0.0.1",
  3. "port": 2368
  4. }

Unix Sockets

Ghost can also be configured to listen on a unix socket by changing the server config:

  1. "server": {
  2. "socket": "path/to/socket.sock"
  3. }

The default permissions are 0660, but this can be configured by expanding the socket config:

  1. "server": {
  2. "socket": {
  3. "path": "path/to/socket.sock",
  4. "permissions": "0666"
  5. }
  6. }

Privacy

All features inside the privacy.md file are enabled by default. It is possible to turn these off in order to protect privacy:

  • Update check
  • Gravatar
  • RPC ping
  • Structured data

For more information about the features, read the privacy.md page.

To turn off all of the features, use:

  1. "privacy": {
  2. "useTinfoil": true
  3. }

Alternatively, configure each feature individually:

  1. "privacy": {
  2. "useUpdateCheck": false,
  3. "useGravatar": false,
  4. "useRpcPing": false,
  5. "useStructuredData": false
  6. }

Paths

The configuration of paths can be relative or absolute. To use a content directory that does not live inside the Ghost folder, specify a paths object with a new contentPath:

  1. "paths": {
  2. "contentPath": "content/"
  3. },

When using a custom content path, the content directory must exist and contain sub directories for data, images, themes, logs and adapters.

If using an Sqlite database, you'll also need to update the path to your database to match the new location of the data folder.

Referrer Policy

Set the value of the content attribute of the meta referrer HTML tag by adding referrerPolicy to your config. origin-when-crossorigin is default. Read through all possible options.

Logging

Configure how Ghost should log, for example:

  1. "logging": {
  2. "path": "something/",
  3. "level": "info",
  4. "rotation": {
  5. "enabled": true,
  6. "count": 15,
  7. "period": "1d"
  8. },
  9. "transports": ["stdout", "file"]
  10. }

level

The default log level is info which prints all info, warning and error logs. Set it to errorto only print errors.

rotation

Tell Ghost to rotate your log files. By default Ghost keeps 10 log files and rotates every day. Rotation is enabled by default in production and disabled in development.

transports

Define where Ghost should log to. By default Ghost writes to stdout and into file for production, and to stdout only for development.

path

Log your content path, e.g. content/logs/. Set any path but ensure the permissions are correct to write into this folder.

Spam

Tell Ghost how to treat spam requests.

Caching

Configure caching for sitemaps, redirects or assets.

Compress

The compression flag is turned on by default using "compress": true. Alternatively you can turn it off with "compress": false.

Image optimisation

When uploading images into the Ghost editor, they are automatically processed and compressed by default. This can be disabled in your config.[env].json file using:

  1. "imageOptimization": {
  2. "resize": false
  3. }

Image compression details:

  • Resize the image to 2000px max width
  • JPEG's are compressed to 80% quality.
  • Meta data removed

The original image is kept with the suffix _o.

Summary

You've explored how to configure a self-hosted Ghost publication with the required config options, as well as discovered how to make use of the optional config options that are available in the config.[env].json file.

If you run into any issues when configuring your publication, try searching this site to find information about common error messages and issues.

GHOST CMS - 配置 Config的更多相关文章

  1. PHP 后台程序配置config文件,及form表单上传文件

    一,配置config文件 1获取config.php文件数组, 2获取form 表单提交的值 3保存更新config.php文件,代码如下: $color=$_POST['color']; $back ...

  2. cms配置使用

    在早期完成了页面的切图之后,需要配置cms来实现小编上传数据更新页面的流程,在取得SEO的官网URL规则之后,就能开始官网在cms的基本配置了. 下面介绍cms的特点: 类别,决定内容与内容对应的路径 ...

  3. Git 的配置 config

    Git 的配置 config Git 的配置 config config 文件简述 config 文件位置 信息查询 修改 config 文件 编辑配置文件 增加指定配置项 删除指定配置项 自助餐   ...

  4. 延迟对象$q和供应商配置config

    1.angular总的$q和jquery中的延迟对象很类似,用法也差不多 m1.controller('meng',['$scope','$q',function($scope,$q){ var df ...

  5. thinkphp 完整配置config.php

    ThinkPHP的系统配置都采用数组形式,配置文件地址:Bin/Conf/config.php CHECK_FILE_CASE -- windows环境下面的严格检查大小写.     /* 项目设定 ...

  6. git安装后配置--config

    安装git后需要配置一下环境,每台计算机上只需要配置一次,程序升级时会保留配置信息. 你可以在任何时候再次通过运行命令来修改它们. 通过git config命令来配置环境变量,这些变量存储在三个不同的 ...

  7. TP-Link 路由器配置 config.bin 解密工具 python 代码 (转载)

    转自吾爱破解 https://www.52pojie.cn/forum.php?mod=viewthread&tid=574222 需要安装crypto #!/usr/bin/env pyth ...

  8. git配置config文件

    1.Git有一个工具被称为git config,它允许你获取和设置变量:这些变量可以控制Git的外观和操作的各个方面.这些变量以等级的不同可以被存储在三个不同的位置: (1) /etc/gitconf ...

  9. Flask系列05--Flask的配置config

    一.flask配置 示例说明, 就是使用config进行配置 from flask import Flask ​ app = Flask(__name__) # type:Flask app.conf ...

随机推荐

  1. ecryptfs

    ecryptfs是一种加密文件系统.该文件系统的内容在传输和储存时以密文形式存在.只有在mount时用密钥解密才能得到明文.利用这个特性,我们可以用他来对软件镜像中的部分敏感文件系统进行加密,然后打包 ...

  2. 扛把子组20191010-1 Alpha阶段贡献分配规则

    此作业的要求参见[https://edu.cnblogs.com/campus/nenu/2019fall/homework/8744] 队名:扛把子 组长:迟俊文 组员:宋晓丽 梁梦瑶 韩昊 刘信鹏 ...

  3. 关于Java中2.0-1.1!=0.9的问题

    关于Java中2.0-1.1!=0.9的问题 问题引出: 在<Java核心技术>中关于浮点数值计算部分提到,System.out.println(2.0-1.1)这条语句并不是想当然的0. ...

  4. Selenium网页自动登录项目(基于Python从0到1)

    Selenium是一个自动化测试工具,利用它我们可以驱动浏览器执行特定的动作,如点击.下拉等操作. 本文讲述的是通过自动化的方式登陆某一网站,其中包含Selenium+python自动化项目环境如何部 ...

  5. UCloud 云服务内容审核 Java 版本实现

    前言 最近不少小伙伴反映上传小黄图偶尔性的异常,并且不能上传动态图片,很是苦恼!无她,鉴黄API还没有这么智能,毕竟是自己训练的,不是那么专业!为了更好的服务广大网友,撸主决定接入更加智能快速的鉴黄服 ...

  6. 图解 Spring:HTTP 请求的处理流程与机制【5】

    5. HTTP 请求处理相关配置文件说明 HTTP 请求穿越的整个空间是分层的,包括:Web 容器.Web 应用.Spring 框架等,它们每层都是通过配置文件配置初始化的,这是一种松耦合的架构设计. ...

  7. JSP内置对象详解及示例

    目录 JSP 内置对象 out request response config application session pageContext page exception JSP 内置对象 jsp一 ...

  8. Python和Java的区别

    这里是我的一些总结,有些是参考别人的(在这里谢谢!!!) 区别: 1.Python比Java简单,学习成本低,开发效率高2.Java运行效率高于Python,尤其是纯Python开发的程序,效率极低3 ...

  9. Hbase初识

    简介 数据模型 相关数据库 典型应用 优势 劣势 key-value Redis 缓存 快速查询 存储数据缺乏结构化 列族 Cassandra,Hbase 分布式的文件系统,大规模的数据存储 易于分布 ...

  10. CCNA 之 十二 Frame Relay 帧中继

    Fram Relay 帧中继 帧中继简介 VC.LMI.DLCI的概念 帧中继映射 Inverse-ARP的操作 帧中继配置 帧中继简介 分组交换广域网接入方式的一个代表,分组交换是以分组的形式在广域 ...