0

我的 linode 使用 nginx 和乘客运行 rails 应用程序运行。现在我创建了一个名为blog.domain.com我使用ghost blogger创建了一个博客的新域 我无法理解如何将我的博客域指向 ghost blog。我需要更改 nginx 配置或config.js在 ghost blogger 中。

这是我的 config.js

var path = require('path'),
    config;

config = {
    development: {
        url: 'http://my-ghost-blog.com',

``

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            port: '2368'
        }
    },
    production: {
        url: 'http://my-ghost-blog.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            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'
        }
    },
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },
    travis: {
        url: 'http://127.0.0.1:2368',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-travis.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    }
};
module.exports = config;
4

2 回答 2

2

您可以在此处查看我的操作方法,但基本思想是:

如果您当前有一个网站在 Nginx Web 服务器上运行,并且您有兴趣在子域上安装 Ghost,您只需对您的 nginx default.conf 添加一个小改动。

您网站的 Nginx 默认位置是 /usr/share/nginx/html,所以我们将坚持使用它。我们将在目录 /usr/share/nginx/html/example.com 中创建主网站,在 /usr/share/nginx/html/blog.example.com 中创建 Ghost 博客。

为了告诉 Nginx 我们的新博客,我们需要编辑 nginx default.conf 文件。该文件默认位于 /etc/nginx/conf.d/default.conf。编辑该文件:

sudo vi /etc/nginx/conf.d/default.conf

现在在文件的最底部添加以下内容(将 server_name 更改为您的站点):

 #Following section for blog.example.com
 server {
     listen 80;
     server_name  blog.example.com;

     location / {
             proxy_pass http://127.0.0.1:2368/;
             proxy_set_header Host $host;
             proxy_buffering off;

     }
 }

现在只需重新启动 nginx,您的更改就会生效。

sudo service nginx restart

于 2013-12-12T07:13:07.583 回答
1

要为您的博客启用自定义域,您需要更改 Ghost 和 nginx 的配置。

首先,您必须将url:config.js 中的值更改为您的域名。

development: {
    url: 'http://blog.domain.com',
...
production: {
    url: 'http://blog.domain.com',

其次,nginx需要向博客传递请求。配置应该在/etc/nginx/.

server {

    listen   80;
    listen   [::]:80;

    server_name  blog.domain.com;

    location / {
        proxy_pass          http://localhost:2368/;
        proxy_set_header    Host $host;
        proxy_buffering     off;
   }
} 

更改配置后,Ghost 和 nginx 需要重新启动。

于 2013-11-15T20:31:52.897 回答