Ghost博客搭建步骤

搭建环境:腾讯云ECS + ubuntu14.04 64位LTS系统

1. 安装Node.js

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

2. 安装Nginx

sudo apt-get install nginx   
sudo service nginx restart   

3. 安装MySQL

sudo apt-get install mysql-server mysql-client   
sudo mysql_secure_installation   只有第一个输n   
sudo vim /etc/mysql/my.cnf  add like below    
[mysqld]   
collation-server = utf8_unicode_ci  
init-connect='SET NAMES utf8'  
character-set-server = utf8   
sudo service mysql restart  

进入 MySQL 命令行界面:mysql -uroot -p
输入指令: show variables like ‘char%’;
show variables like ‘collation%’;

4. 安装Ghost

mysql -uroot -p -e 'create database ghost;'  
cd /etc/nginx/sites-available/  
sudo touch ghost.conf  
sudo vim ghost.conf  

server {
    listen 80;
    server_name 119.29.72.227 mlingdu.com www.mlingdu.com blog.mlingdu.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}
sudo touch code.conf
sudo vim code.conf
server {
    listen 80;
    server_name mantis.mlingdu.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:8080;
    }
}
server {
    listen 80;
    server_name code.mlingdu.com;

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

sudo ln -s /etc/nginx/sites-available/ghost.conf   /etc/nginx/sites-enabled/ghost.conf 
sudo ln -s /etc/nginx/sites-available/code.conf   /etc/nginx/sites-enabled/code.conf 

sudo npm install forever -g  
sudo apt-get install unzip  
cd /srv/  
sudo curl -L http://dl.ghostchina.com/Ghost-0.7.4-zh-full.zip -o ghost.zip 集成 node_modules  
sudo unzip ghost.zip -d ghost  
cd /srv/ghost/  
sudo cp config.example.js config.js  
sudo vi config.js  
    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://ghostchina.com', //替换为你自己的域名。
        mail: {},
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'root', //我们暂且用 MySQL 的 root 账户
                password : '123456', //输入你的 MySQL 密码
                database : 'ghost', //我们前面为 Ghost 创建的数据库名称
                charset  : 'utf8'
            }
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            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'
        }
    },
sudo vim package.json  delete "sqlite3": "2.2.0",

sudo service nginx restart  
sudo NODE_ENV=production forever start index.js 

5. 安装主题

cd /srv/ghost/content/themes/  
sudo git clone https://github.com/foru17/Yasuko.git  

进入后台修改主题、Logo、封面背景(img width < 899)、个人介绍、头像,OK !

6. 遇到的问题

  • 如何嵌入视频
    目前MarkDown只支持HTML的video标签。
<video id="video" controls="" preload="none" poster="http://media.w3.org/2010/05/sintel/poster.png">
      <source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4">
      <source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm">
      <source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg">
      <p>Your user agent does not support the HTML5 Video element.p>
    video>
  • 封面图片水平分辨率定为850,为了用户体验,垂直分辨率定为400。
  • 嵌入封面
<img src="http://7tsz20.com1.z0.glb.clouddn.com/s5.jpg?imageView2/0/w/900/format/webp" height="0" width="0" />
  • 文章配图
<img src="http://7tsz20.com1.z0.glb.clouddn.com/s5.jpg?imageView2/0/format/webp" height="0" width="0" />
  • 域名code.mlingdu.com访问gerrit,添加ssh出错

你可能感兴趣的:(nginx)