阿里雲安裝配置Ghost

阿里雲手動重裝系統N次了,折騰不止。  系統環境 CentOS 6.3 X64 , 兩塊硬盤 系統 +數據盤php

#從新掛載硬盤
[root@AY14040623435015772eZ ~]# fdisk -l
html

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00073f45
node

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1        2611    20970496   83  Linux
mysql

Disk /dev/xvdb: 10.7 GB, 10737418240 bytes
255 heads, 56 sectors/track, 1468 cylinders
Units = cylinders of 14280 * 512 = 7311360 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb3338ad8
linux

Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        1468    10481492   83  Linux
nginx

#掛載數據盤
[root@AY14040623435015772eZ ~]# mount /dev/xvdb1 /opt/
c++

#查看掛載狀況sql

[root@AY14040623435015772eZ ~]# df -l
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda1            20641404   1062512  18530368   6% /
tmpfs                   509400         0    509400   0% /dev/shm
/dev/xvdb1            10316940    238316   9554552   3% /opt
數據庫

數據也回來了npm

image

#安裝NodeJS環境
#yum update
#yum install wget
#wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz
#tar zxvf node-v0.10.28-linux-x64.tar.gz

https://nodejs.org/dist/v4.4.1/node-v4.4.1-linux-x64.tar.xz
tar -xvf node-v4.4.1-linux-x64.tar.xz

#配置環境變量
#vi /etc/profile
#輸入保存

#set for nodejs
export NODE_HOME=/opt/node-v0.10.28-linux-x64
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH

#保存退出
#:wq
#重啓生效
#source /etc/profile
#檢查是否安裝成功
#node -v
#npm –v
#安裝Chost
cd /opt
wget http://dl.ghostchina.com/Ghost-0.4.2.zip  (官網須要牆)
unzip -uo ghost-0.4.2.zip -d ghost
cd ghost

更換NPM鏡像(或http://registry.npm.taobao.org)
npm config set strict-ssl false
npm config set registry http://registry.cnpmjs.org

#強制編譯 SQLite3
npm install sqlite3 --build-from-source
#npm install --production
#以開發模式啓動Ghost
npm start

前面提到的啓動 Ghost 使用 npm start 命令。這是一個在開發模式下啓動和測試的不錯的選擇,可是經過這種命令行啓動的方式有個缺點,即當你關閉終端窗口或者從 SSH 斷開鏈接時,Ghost 就中止了。爲了防止 Ghost 中止工做,有兩種方式解決這個問題
Ghost 一直運行
經過 npm install forever -g 安裝 forever
爲了讓 forever 從 Ghost 安裝目錄運行,輸入 NODE_ENV=production forever start index.js
經過 forever stop index.js 中止 Ghost
經過 forever list 檢查 Ghost 當前是否正在運行

#安裝Nginx

yum -y install gcc gcc-c++ autoconf automake make  zlib zlib-devel openssl openssl--devel pcre pcre-devel
cd /opt
wget http://nginx.org/download/nginx-1.7.1.tar.gz
mkdir nginx
tar zxvf nginx-1.7.1.tar.gz
cd nginx-1.7.1
./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_gzip_static_module
make && make install

配置Nginx

#user nobody;
worker_processes  1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;
 events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main;
 sendfile on; #tcp_nopush on; #keepalive_timeout 0;
    keepalive_timeout  5; gzip on; server { listen       80; server_name localhost; #charset koi8-r; #root /alidata1/ghost; #access_log logs/host.access.log main;
 location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header HOST $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:2368; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html #
        error_page   500 502 503 504  /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #}
 } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}
 }

安裝MySQL

查看系統是否安裝了MySQL
rpm -qa | grep mysql
卸載已安裝的MySQL
rpm -qa | grep mysql
rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64

#可下載的版本
yum list | grep mysql
#安裝Mysql
yum install -y mysql-server mysql mysql-deve
#查看
rpm -qi mysql-server
#啓動mysql服務  首先會初始化配置
service mysqld start
#重啓Mysql的服務
service mysqld restart
#開機自動啓動
chkconfig --list | grep mysqld
chkconfig mysqld on
#爲root帳號設置密碼
mysqladmin -u root password '123456'

#修改編碼
vi /etc/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
default-character-set = utf8   
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

#登陸Mysql查看編碼

mysql -u root -p
show variables like 'char%';
show variables like 'collation%';

配置Chost的數據庫爲Mysql

首先註釋掉packages.json總得sqlite3 ,還有就是CentOS中默認的glibc版本太低,須要強制源碼編譯sqlite,現換mysql,就沒有必要安裝了。

#建立數據庫
mysql -uroot -p -e 'create database ghost;'
#配置Mysql鏈接(只修改 production 一節的配置信息)
cp config.example.js config.js

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://zhouyongtao.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'
        }
    },

#安裝Chost
npm install --production


#查詢數據庫

Refer:
http://www.bokeyy.com/post/ghost-install-in-vps-solution-in-china.html
http://www.oschina.net/news/53128/public-cd

相關文章
相關標籤/搜索