阿里云安装配置Ghost

阿里云手动重装系统N次了,折腾不止。  系统环境 CentOS 6.3 X64 , 两块硬盘 系统 +数据盘

#重新挂载硬盘
[root@AY14040623435015772eZ ~]# fdisk -l

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

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

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

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

#挂载数据盘
[root@AY14040623435015772eZ ~]# mount /dev/xvdb1 /opt/

#查看挂载情况

[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

数据也回来了

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
#配置环境变量
#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

你可能感兴趣的:(host)