Ghost Blog

本文详细介绍了如何在Linux系统上部署Ghost博客平台,包括安装Node.js、Ghost、SASS、Javascript依赖,设置Ruby和RVM,安装Grunt,安装SASS和bourbon,以及使用Forever作为后台任务管理器。此外,还提供了初始化脚本和设置域名的方法。

##安装nodejs

sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

##安装Ghost

git clone https://github.com/TryGhost/Ghost.git
cd Ghost
npm install --production

##安装SASS和Javascript依赖 ###安装ruby和rvm Install RVM Run the following command from your terminal. curl -L https://get.rvm.io | bash -s stable --ruby Be sure to follow any subsequent instructions as guided by the installation process. source /usr/local/rvm/scripts/rvm Install Ruby 1.9.3 Next install Ruby 1.9.3 and you'll be all set. rvm install 1.9.3 rvm use 1.9.3 rvm rubygems latest Run ruby --version to be sure you're using Ruby 1.9.3 ###安装 Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-contrib-sass --save-dev Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: grunt.loadNpmTasks('grunt-contrib-sass'); ###安装sass和bourbon

gem install sass
gem install bourbon

###Installation / Setup Instructions Check you have the pre-requisites listed above! Clone the git repo cd into the project folder Run git submodule update --init Run npm install -g grunt-cli Run npm install. If the install fails with errors to do with "node-gyp rebuild" or "SQLite3", follow the SQLite3 install instructions below this list Usually if you're within vagrant, and have installed the guest plugins and updated that, this will not happen Run grunt init from the root - this generates the Bourbon directory, compiles SASS and compiles Handlebars templates Run npm start from the root to start the server. Front-end can be located at http://localhost:2368, Admin is at http://localhost:2368/ghost/.

##Forever (https://npmjs.org/package/forever) You can use forever to run Ghost as a background task. forever will also take care of your Ghost installation and it will restart the node process if it crashes. To install forever type npm install forever -g To start Ghost using forever from the Ghost installation directory type NODE_ENV=production forever start index.js To stop Ghost type forever stop index.js To check if Ghost is currently running type forever list 这个Forever我这使用有问题。

###Init Script Linux systems use init scripts to run on system boot. These scripts exist in /etc/init.d. To make Ghost run forever and even survive a reboot you could set up an init script to accomplish that task. The following example will work on Ubuntu and was tested on Ubuntu 12.04.

Create the file /etc/init.d/ghost with the following command:

$ sudo curl https://raw.github.com/TryGhost/Ghost-Config/master/init.d/ghost \ -o /etc/init.d/ghost Open the file with nano /etc/init.d/ghost and check the following:

Change the GHOST_ROOT variable to the path where you installed Ghost

Check if the DAEMON variable is the same as the output of which node 我这里把node更改为npm The Init script runs with it's own Ghost user and group on your system, let's create them with the following: $ sudo useradd -r ghost -U Let's also make sure the Ghost user can access the installation: $ sudo chown -R ghost:ghost /path/to/ghost Change the execution permission for the init script by typing $ sudo chmod 755 /etc/init.d/ghost Now you can control Ghost with the following commands:

$ sudo service ghost start
$ sudo service ghost stop
$ sudo service ghost restart
$ sudo service ghost status

To start Ghost on system start the newly created init script has to be registered for start up. Type the following two commands in command line:

$ sudo update-rc.d ghost defaults
$ sudo update-rc.d ghost enable

Let's make sure your user can change files, config.js for example in the Ghost directory, by assigning you to the ghost group: $ sudo adduser USERNAME ghost

If you now restart your server Ghost should already be running for you.

##Setting up Ghost with a domain name

If you have setup up Ghost to run forever you can also setup a web server as a proxy to serve your blog with your domain. In this example we assume you are using Ubuntu 12.04 and use nginx as a web server. It also assumes that Ghost is running in the background with one of the above mentioned ways.

Install nginx

$ sudo apt-get install nginx This will install nginx and setup all necessary directories and basic configurations.

Configure your site

Create a new file in /etc/nginx/sites-available/ghost.conf Open the file with a text editor (e.g. sudo nano /etc/nginx/sites-available/ghost.conf) and paste the following

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}

Change server_name to your domain

Symlink your configuration in sites-enabled:

$ sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf Restart nginx $ sudo service nginx restart

转载于:https://my.oschina.net/sandylaw/blog/186096

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值