Linode是一個主機商專業提供XEN虛擬vps了,有不少國內朋友使用都覺得非常的不錯,下文我們來看看Linode XEN虛擬vps安裝配置Ghost方法.
我的 vps 情況:
操作系統 – CentOS 7 64 位,web 服務器軟件 – Apache,Ghost1 基于 Node.js,它本身自帶 web 服務器,不需要 Apache.
安裝 Ghost
主要參照 Ghost 官方幫助2
下載 Ghost:$ curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
解壓 Ghost:$ unzip -uo ghost.zip -d ghost
安裝 Ghost:
- $ cd ghost
- $ npm install --production
啟動 Ghost:$ npm start --production
現在,你可以在 vps 上通過 127.0.0.1:2368 路徑訪問到 Ghost 博客了.
配置 Apache 與 Ghost,當然,你的目的可不是在 vps 上訪問 Ghost,而是通過域名訪問 Ghost,ghost 目錄下有一個 config.example.js 文件,用于配置相關信息3,比如域名,端口等.
執行以下操作前,請先確保你在 DNS 服務器上把域名綁定到 vps 的 ip 地址.
復制一個 config.js:
- $ cd ghost
- $ cp config.example.js config.js
修改 config.js:將 config.js 里 production 部分里的 url: 'http://my-ghost-blog.com' 改為 url: 'http://Vevb.com',這是我要使用的域名.
重啟 Ghost:按 CTRL - C 關閉 Ghost,再執行 npm start --production 啟動它,這時你能看到如下信息:
- Migrations: Up to date at version 003
- Ghost is running...
- Your blog is now available on http://Vevb.com
- Ctrl+C to shut down1
但這信息并不意味著我們能訪問到 Ghost 了,因為 11cn.net 域名訪問的是 80 端口,在這個端口上監聽的是 Apache 而不是 Node.js – 它是在 2368 端口監聽著.
所以我們還需要配置 Apache,打開 /etc/httpd/conf.d/vhost.conf 文件,CentOS 系統的情況,添加如下內容:
- <VirtualHost *:80>
- ServerName m.survivalescaperooms.com
- ServerAlias Vevb.com
- ProxyPreserveHost on
- ProxyPass / http://localhost:2368/
- ProxyPassReverse / http://localhost:2368/
- </VirtualHost>
重啟 apache:$ sudo service httpd restart
這樣,Apache 充當代理,會把它監聽到的流量轉發給 Node.js 監聽的端口,這時訪問 http://Vevb.com,我們就能打開 Ghost 博客了.
新聞熱點
疑難解答