Install Ghost on CentOS 7
GHost是一个用NodeJS写的博客系统。
官网:
https://www.ghost.org
Github:
https://github.com/TryGhost/Ghost
一、安装Node支持:
可以参考我之前的日志,安装NODEJS:http://d-prototype.com/archives/6985
安装好了之后检查是否安装成功:
1 2 3 4 5 |
[root@adamhuan-info-center software]# node -v v6.11.1 [root@adamhuan-info-center software]# npm -v 3.10.10 [root@adamhuan-info-center software]# |
修改NPM源:npm config set registry https://registry.npm.taobao.org/
二、安装GHOST
从官网获得下载介质,并上传服务器:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[root@adamhuan-info-center software]# mkdir ghost [root@adamhuan-info-center software]# cd ghost/ [root@adamhuan-info-center ghost]# pwd /software/ghost [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# ls -ltr total 0 [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0 100 95 100 95 0 0 35 0 0:00:02 0:00:02 --:--:-- 35 0 0 0 604 0 0 128 0 --:--:-- 0:00:04 --:--:-- 483 100 2296k 100 2296k 0 0 106k 0 0:00:21 0:00:21 --:--:-- 317k [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# ls -ltr total 2300 -rw-r--r-- 1 root root 2351962 Aug 4 14:23 ghost.zip [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# du -sh 2.3M . [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# du -sh * 2.3M ghost.zip [root@adamhuan-info-center ghost]# |
解压:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[root@adamhuan-info-center ghost]# unzip -uo ghost.zip -d ghost-unzip [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# ls -ltr total 2304 -rw-r--r-- 1 root root 2351962 Aug 4 14:23 ghost.zip drwxr-xr-x 4 root root 4096 Aug 4 14:24 ghost-unzip [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# ls -ltr ghost-unzip/ total 256 -rw-r--r-- 1 root root 194493 Aug 2 11:12 yarn.lock -rw-r--r-- 1 root root 4080 Aug 2 11:12 README.md -rw-r--r-- 1 root root 2968 Aug 2 11:12 PRIVACY.md -rw-r--r-- 1 root root 453 Aug 2 11:12 MigratorConfig.js -rw-r--r-- 1 root root 1065 Aug 2 11:12 LICENSE -rw-r--r-- 1 root root 1394 Aug 2 11:12 index.js -rw-r--r-- 1 root root 32821 Aug 2 11:12 Gruntfile.js -rw-r--r-- 1 root root 4281 Aug 2 11:13 package.json drwxr-xr-x 4 root root 46 Aug 2 11:15 core drwxr-xr-x 8 root root 80 Aug 2 11:15 content [root@adamhuan-info-center ghost]# |
移动到希望的目录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@adamhuan-info-center ghost]# mkdir /ghost_home [root@adamhuan-info-center ghost]# mv ghost-unzip/* /ghost_home/ [root@adamhuan-info-center ghost]# ls -ltr ghost-unzip/ total 0 [root@adamhuan-info-center ghost]# [root@adamhuan-info-center ghost]# ls -ltr /ghost_home/ total 256 -rw-r--r-- 1 root root 194493 Aug 2 11:12 yarn.lock -rw-r--r-- 1 root root 4080 Aug 2 11:12 README.md -rw-r--r-- 1 root root 2968 Aug 2 11:12 PRIVACY.md -rw-r--r-- 1 root root 453 Aug 2 11:12 MigratorConfig.js -rw-r--r-- 1 root root 1065 Aug 2 11:12 LICENSE -rw-r--r-- 1 root root 1394 Aug 2 11:12 index.js -rw-r--r-- 1 root root 32821 Aug 2 11:12 Gruntfile.js -rw-r--r-- 1 root root 4281 Aug 2 11:13 package.json drwxr-xr-x 4 root root 46 Aug 2 11:15 core drwxr-xr-x 8 root root 80 Aug 2 11:15 content [root@adamhuan-info-center ghost]# |
安装GHOST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@adamhuan-info-center ghost]# cd /ghost_home/ [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# npm install --production (过多的输出) │ │ └── concat-map@0.0.1 │ ├─┬ once@1.3.3 │ │ └── wrappy@1.0.2 │ ├─┬ readable-stream@2.1.5 │ │ ├── buffer-shims@1.0.0 │ │ ├── core-util-is@1.0.2 │ │ ├── inherits@2.0.3 │ │ ├── isarray@1.0.0 │ │ ├── process-nextick-args@1.0.7 │ │ ├── string_decoder@0.10.31 │ │ └── util-deprecate@1.0.2 │ └── uid-number@0.0.6 ├─┬ superagent@3.5.2 │ ├── component-emitter@1.2.1 │ ├── cookiejar@2.1.1 │ ├── extend@3.0.1 │ ├─┬ form-data@2.2.0 │ │ └── asynckit@0.4.0 │ ├── formidable@1.1.1 │ ├── mime@1.3.4 │ └── qs@6.5.0 ├── unidecode@0.1.8 ├── uuid@3.1.0 ├── validator@6.3.0 └── xml@1.0.1 [root@adamhuan-info-center ghost_home]# |
安装:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@adamhuan-info-center ghost_home]# npm install -g knex-migrator (过多的输出) │ ├── balanced-match@0.4.2 │ └── concat-map@0.0.1 ├─┬ once@1.3.3 │ └── wrappy@1.0.2 ├─┬ readable-stream@2.1.5 │ ├── buffer-shims@1.0.0 │ ├── core-util-is@1.0.2 │ ├── inherits@2.0.3 │ ├── isarray@1.0.0 │ ├── process-nextick-args@1.0.7 │ ├── string_decoder@0.10.31 │ └── util-deprecate@1.0.2 └── uid-number@0.0.6 [root@adamhuan-info-center ghost_home]# |
初始化:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@adamhuan-info-center ghost_home]# knex-migrator init [2017-08-04 06:38:01] INFO Creating table: posts [2017-08-04 06:38:01] INFO Creating table: users [2017-08-04 06:38:01] INFO Creating table: roles [2017-08-04 06:38:01] INFO Creating table: roles_users [2017-08-04 06:38:01] INFO Creating table: permissions [2017-08-04 06:38:01] INFO Creating table: permissions_users [2017-08-04 06:38:01] INFO Creating table: permissions_roles [2017-08-04 06:38:01] INFO Creating table: permissions_apps [2017-08-04 06:38:01] INFO Creating table: settings [2017-08-04 06:38:01] INFO Creating table: tags [2017-08-04 06:38:01] INFO Creating table: posts_tags [2017-08-04 06:38:01] INFO Creating table: apps [2017-08-04 06:38:01] INFO Creating table: app_settings [2017-08-04 06:38:02] INFO Creating table: app_fields [2017-08-04 06:38:02] INFO Creating table: clients [2017-08-04 06:38:02] INFO Creating table: client_trusted_domains [2017-08-04 06:38:02] INFO Creating table: accesstokens [2017-08-04 06:38:02] INFO Creating table: refreshtokens [2017-08-04 06:38:02] INFO Creating table: subscribers [2017-08-04 06:38:02] INFO Creating table: invites [2017-08-04 06:38:02] INFO Creating table: brute [2017-08-04 06:38:02] INFO Model: Post [2017-08-04 06:38:02] INFO Model: Tag [2017-08-04 06:38:02] INFO Model: Client [2017-08-04 06:38:02] INFO Model: Role [2017-08-04 06:38:02] INFO Model: Permission [2017-08-04 06:38:02] INFO Model: User [2017-08-04 06:38:07] INFO Relation: Role to Permission [2017-08-04 06:38:07] INFO Relation: Post to Tag [2017-08-04 06:38:07] INFO Relation: User to Role [2017-08-04 14:38:07] INFO Finished database init! [root@adamhuan-info-center ghost_home]# |
启动GHOST:
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@adamhuan-info-center ghost_home]# npm start > ghost@1.4.0 start /ghost_home > node index [2017-08-04 06:38:59] INFO Ghost is running in development... [2017-08-04 06:38:59] INFO Listening on: 127.0.0.1:2368 [2017-08-04 06:38:59] INFO Url configured as: http://localhost:2368/ [2017-08-04 06:38:59] INFO Ctrl+C to shut down [2017-08-04 06:38:59] INFO Ghost boot 3.517s (会话挂起) |
访问:
博客主页:
http://localhost:2368/
管理界面:
http://localhost:2368/ghost
——————————
到这里,其实GHOST的安装就结束了。
但是上面的GHOST启动命令可以看到在会话中断后,GHOST的运行就终端了。
为了让GHOST一只运行,我们还需要做一些配置:
NPM安装Forever:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
[root@adamhuan-info-center ghost_home]# npm install forever -g (过多的输出) │ │ └── through@2.3.8 │ └── strip-json-comments@0.1.3 ├── timespan@2.3.0 ├─┬ utile@0.2.1 │ ├── async@0.2.10 │ ├── deep-equal@1.0.1 │ ├── i@0.3.5 │ ├─┬ mkdirp@0.5.1 │ │ └── minimist@0.0.8 │ ├── ncp@0.4.2 │ └─┬ rimraf@2.6.1 │ └─┬ glob@7.1.2 │ ├── fs.realpath@1.0.0 │ ├─┬ inflight@1.0.6 │ │ └── wrappy@1.0.2 │ └── once@1.4.0 └─┬ winston@0.8.3 ├── cycle@1.0.3 ├── isstream@0.1.2 ├── pkginfo@0.3.1 └── stack-trace@0.0.10 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/forever/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# |
安装后检查:
1 2 3 4 5 6 7 8 |
[root@adamhuan-info-center ghost_home]# whereis forever forever: /usr/bin/forever [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# forever list info: No forever processes running [root@adamhuan-info-center ghost_home]# pwd /ghost_home [root@adamhuan-info-center ghost_home]# |
启动:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@adamhuan-info-center ghost_home]# pwd /ghost_home [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# ls -ltr | grep index -rw-r--r-- 1 root root 1394 Aug 2 11:12 index.js [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# NODE_ENV=production forever start index.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: index.js [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# forever list info: Forever processes running data: uid command script forever pid id logfile uptime data: [0] tXxT /usr/bin/node index.js 87358 87433 /root/.forever/tXxT.log 0:0:0:1.459 [root@adamhuan-info-center ghost_home]# |
查看端口:
1 2 3 |
[root@adamhuan-info-center ghost_home]# netstat -tupln | grep node tcp 0 0 127.0.0.1:2368 0.0.0.0:* LISTEN 89518/node [root@adamhuan-info-center ghost_home]# |
启停:
在Ghost目录中:
forever start index.js
forever stop index.js
设置开机启动:
安装:pm2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
[root@adamhuan-info-center ghost]# npm install pm2 -g /usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2 /usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev /usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker /usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime /usr/lib └─┬ pm2@2.6.1 ├─┬ async@2.5.0 │ └── lodash@4.17.4 ├── blessed@0.1.81 ├─┬ chalk@1.1.3 │ ├── ansi-styles@2.2.1 │ ├── escape-string-regexp@1.0.5 │ ├─┬ has-ansi@2.0.0 │ │ └── ansi-regex@2.1.1 │ ├── strip-ansi@3.0.1 │ └── supports-color@2.0.0 ├─┬ chokidar@1.7.0 │ ├─┬ anymatch@1.3.2 │ │ ├─┬ micromatch@2.3.11 │ │ │ ├─┬ arr-diff@2.0.0 │ │ │ │ └── arr-flatten@1.1.0 │ │ │ ├── array-unique@0.2.1 │ │ │ ├─┬ braces@1.8.5 │ │ │ │ ├─┬ expand-range@1.8.2 │ │ │ │ │ └─┬ fill-range@2.2.3 │ │ │ │ │ ├── is-number@2.1.0 │ │ │ │ │ ├── isobject@2.1.0 │ │ │ │ │ ├─┬ randomatic@1.1.7 │ │ │ │ │ │ ├─┬ is-number@3.0.0 │ │ │ │ │ │ │ └── kind-of@3.2.2 │ │ │ │ │ │ └── kind-of@4.0.0 │ │ │ │ │ └── repeat-string@1.6.1 │ │ │ │ ├── preserve@0.2.0 │ │ │ │ └── repeat-element@1.1.2 │ │ │ ├─┬ expand-brackets@0.1.5 │ │ │ │ └── is-posix-bracket@0.1.1 │ │ │ ├── extglob@0.3.2 │ │ │ ├── filename-regex@2.0.1 │ │ │ ├─┬ kind-of@3.2.2 │ │ │ │ └── is-buffer@1.1.5 │ │ │ ├─┬ object.omit@2.0.1 │ │ │ │ ├─┬ for-own@0.1.5 │ │ │ │ │ └── for-in@1.0.2 │ │ │ │ └── is-extendable@0.1.1 │ │ │ ├─┬ parse-glob@3.0.4 │ │ │ │ ├── glob-base@0.3.0 │ │ │ │ └── is-dotfile@1.0.3 │ │ │ └─┬ regex-cache@0.4.3 │ │ │ ├── is-equal-shallow@0.1.3 │ │ │ └── is-primitive@2.0.0 │ │ └─┬ normalize-path@2.1.1 │ │ └── remove-trailing-separator@1.0.2 │ ├── async-each@1.0.1 │ ├── glob-parent@2.0.0 │ ├── inherits@2.0.3 │ ├─┬ is-binary-path@1.0.1 │ │ └── binary-extensions@1.9.0 │ ├─┬ is-glob@2.0.1 │ │ └── is-extglob@1.0.0 │ ├── path-is-absolute@1.0.1 │ └─┬ readdirp@2.1.0 │ ├── graceful-fs@4.1.11 │ ├─┬ minimatch@3.0.4 │ │ └─┬ brace-expansion@1.1.8 │ │ ├── balanced-match@1.0.0 │ │ └── concat-map@0.0.1 │ ├─┬ readable-stream@2.3.3 │ │ ├── core-util-is@1.0.2 │ │ ├── isarray@1.0.0 │ │ ├── process-nextick-args@1.0.7 │ │ ├── safe-buffer@5.1.1 │ │ ├── string_decoder@1.0.3 │ │ └── util-deprecate@1.0.2 │ └── set-immediate-shim@1.0.1 ├── cli-table-redemption@1.0.1 ├── commander@2.11.0 ├─┬ cron@1.2.1 │ └── moment-timezone@0.5.13 ├─┬ debug@2.6.8 │ └── ms@2.0.0 ├── eventemitter2@1.0.5 ├── fclone@1.0.11 ├── gkt@1.0.0 ├─┬ mkdirp@0.5.1 │ └── minimist@0.0.8 ├── moment@2.18.1 ├─┬ needle@1.6.0 │ └── iconv-lite@0.4.18 ├─┬ nssocket@0.6.0 │ ├── eventemitter2@0.4.14 │ └── lazy@1.0.11 ├── pidusage@1.1.6 ├─┬ pm2-axon@3.0.2 │ ├── amp@0.3.1 │ ├── amp-message@0.1.2 │ ├─┬ debug@2.2.0 │ │ └── ms@0.7.1 │ └── escape-regexp@0.0.1 ├─┬ pm2-axon-rpc@0.4.5 │ └── fclone@1.0.8 ├─┬ pm2-deploy@0.3.5 │ ├── async@1.5.2 │ └── tv4@1.3.0 ├─┬ pm2-multimeter@0.1.2 │ └── charm@0.1.2 ├─┬ pmx@1.2.0 │ ├── json-stringify-safe@5.0.1 │ └─┬ vxx@1.2.2 │ ├─┬ continuation-local-storage@3.2.0 │ │ ├── async-listener@0.6.7 │ │ └─┬ emitter-listener@1.0.1 │ │ └── shimmer@1.0.0 │ ├── extend@3.0.1 │ ├── is@3.2.1 │ ├── lodash.findindex@4.6.0 │ ├── lodash.isequal@4.5.0 │ ├── lodash.merge@4.6.0 │ ├── methods@1.1.2 │ ├── shimmer@1.1.0 │ └── uuid@3.1.0 ├─┬ promptly@2.2.0 │ └─┬ read@1.0.7 │ └── mute-stream@0.0.7 ├── semver@5.4.1 ├─┬ shelljs@0.7.8 │ ├─┬ glob@7.1.2 │ │ ├── fs.realpath@1.0.0 │ │ ├─┬ inflight@1.0.6 │ │ │ └── wrappy@1.0.2 │ │ └── once@1.4.0 │ ├── interpret@1.0.3 │ └─┬ rechoir@0.6.2 │ └─┬ resolve@1.4.0 │ └── path-parse@1.0.5 ├─┬ source-map-support@0.4.15 │ └── source-map@0.5.6 ├── sprintf-js@1.1.1 ├─┬ vizion@0.2.13 │ └── async@1.5.2 └─┬ yamljs@0.3.0 └─┬ argparse@1.0.9 └── sprintf-js@1.0.3 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) [root@adamhuan-info-center ghost]# |
配置:pm2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
[root@adamhuan-info-center ghost_home]# NODE_ENV=production pm2 start index.js --name "ghost" ------------- __/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____ _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___ _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__ _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___ _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____ _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________ _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________ _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_ _\///______________\///______________\///__\///////////////__ Production Process Manager for Node.js apps with a built-in Load Balancer. Start and Daemonize any application: $ pm2 start app.js Load Balance 4 instances of api.js: $ pm2 start api.js -i 4 Monitor in production: $ pm2 monitor Make pm2 auto-boot at server restart: $ pm2 startup To go further checkout: http://pm2.io ------------- [PM2] Spawning PM2 daemon with pm2_home=/root/.pm2 [PM2] PM2 Successfully daemonized [PM2] Starting /ghost_home/index.js in fork_mode (1 instance) [PM2] Done. ┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬──────┬───────────┬──────┬──────────┐ │ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │ ├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼──────┼───────────┼──────┼──────────┤ │ ghost │ 0 │ fork │ 90112 │ online │ 0 │ 0s │ 112% │ 11.9 MB │ root │ disabled │ └──────────┴────┴──────┴───────┴────────┴─────────┴────────┴──────┴───────────┴──────┴──────────┘ Use `pm2 show <id|name>` to get more details about an app [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# pm2 show ghost Describing process with id 0 - name ghost ┌───────────────────┬───────────────────────────────────┐ │ status │ online │ │ name │ ghost │ │ restarts │ 13 │ │ uptime │ 17s │ │ script path │ /ghost_home/index.js │ │ script args │ N/A │ │ error log path │ /root/.pm2/logs/ghost-error-0.log │ │ out log path │ /root/.pm2/logs/ghost-out-0.log │ │ pid path │ /root/.pm2/pids/ghost-0.pid │ │ interpreter │ node │ │ interpreter args │ N/A │ │ script id │ 0 │ │ exec cwd │ /ghost_home │ │ exec mode │ fork_mode │ │ node.js version │ 6.11.1 │ │ watch & reload │ ✘ │ │ unstable restarts │ 0 │ │ created at │ 2017-08-04T08:19:50.418Z │ └───────────────────┴───────────────────────────────────┘ Code metrics value ┌────────────┬──────────┐ │ Loop delay │ 109.94ms │ └────────────┴──────────┘ Add your own code metrics: http://bit.ly/code-metrics Use `pm2 logs ghost [--lines 1000]` to display logs Use `pm2 monit` to monitor CPU and Memory usage ghost [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# pm2 startup centos [PM2] Init System found: systemd ----------------------------------------------------------- PM2 detected systemd but you precised centos Please verify that your choice is indeed your init system If you arent sure, just run : pm2 startup ----------------------------------------------------------- Platform centos Template [Unit] Description=PM2 process manager Documentation=https://pm2.keymetrics.io/ After=network.target [Service] Type=forking User=root LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin Environment=PM2_HOME=/root/.pm2 PIDFile=/root/.pm2/pm2.pid ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill [Install] WantedBy=multi-user.target Target path /etc/systemd/system/pm2-root.service Command list [ 'chmod +x /etc/systemd/system/pm2-root.service', 'systemctl enable pm2-root', 'systemctl start pm2-root', 'systemctl daemon-reload', 'systemctl status pm2-root' ] [PM2] Writing init configuration in /etc/systemd/system/pm2-root.service [PM2] Making script booting at startup... >>> Executing chmod +x /etc/systemd/system/pm2-root.service [DONE] >>> Executing systemctl enable pm2-root [DONE] >>> Executing systemctl start pm2-root [DONE] >>> Executing systemctl daemon-reload [DONE] >>> Executing systemctl status pm2-root pm2-root.service - PM2 process manager Loaded: loaded (/etc/systemd/system/pm2-root.service; enabled) Active: active (running) since Fri 2017-08-04 16:18:15 CST; 2min 12s ago Docs: https://pm2.keymetrics.io/ Main PID: 90102 (PM2 v2.6.1: God) CGroup: /system.slice/pm2-root.service ‣ 90102 PM2 v2.6.1: God Daemon (/root/.pm2) Aug 04 16:18:15 adamhuan-info-center pm2[90261]: [PM2] Restoring processes located in /root/.pm2/dump.pm2 Aug 04 16:18:15 adamhuan-info-center pm2[90261]: [PM2][ERROR] No processes saved; DUMP file doesn't exist Aug 04 16:18:15 adamhuan-info-center pm2[90261]: ┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐ Aug 04 16:18:15 adamhuan-info-center pm2[90261]: │ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │ Aug 04 16:18:15 adamhuan-info-center pm2[90261]: ├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤ Aug 04 16:18:15 adamhuan-info-center pm2[90261]: │ ghost │ 0 │ fork │ 90225 │ online │ 5 │ 2s │ 95% │ 60.4 MB │ root │ disabled │ Aug 04 16:18:15 adamhuan-info-center pm2[90261]: └──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘ Aug 04 16:18:15 adamhuan-info-center pm2[90261]: Use `pm2 show <id|name>` to get more details about an app Aug 04 16:18:15 adamhuan-info-center systemd[1]: Started PM2 process manager. Aug 04 16:20:28 adamhuan-info-center systemd[1]: Started PM2 process manager. [DONE] +---------------------------------------+ [PM2] Freeze a process list on reboot via: $ pm2 save [PM2] Remove init script via: $ pm2 unstartup centos [root@adamhuan-info-center ghost_home]# [root@adamhuan-info-center ghost_home]# pm2 save [PM2] Saving current process list... [PM2] Successfully saved in /root/.pm2/dump.pm2 [root@adamhuan-info-center ghost_home]# |
这样,以后启停Ghost:
pm2 start/stop/restart/show ghost
启动PM2的监控:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@adamhuan-info-center ghost_home]# pm2 monitor __ __ __ _ / //_/__ __ ______ ___ ___ / /______(_)_________ / ,< / _ \/ / / / __ `__ \/ _ \/ __/ ___/ / ___/ ___/ / /| / __/ /_/ / / / / / / __/ /_/ / / / /__(__ ) /_/ |_\___/\__, /_/ /_/ /_/\___/\__/_/ /_/\___/____/ /____/ A Node.js monitoring solution you will love Now registering to Keymetrics Username: ad***** Email: dk*****@****.com Password: ******** ⠧ Connecting ⠏ Conn ⠹ Connect ⠼ C ⠴ Connecting ⠧ Conn ⠋ Connect [Monitoring Enabled] Dashboard access: https://app.keymetrics.io/#/r/txr8bt*****iihx [root@adamhuan-info-center ghost_home]# |
然后就可以按照上面命令行反馈的地址去查看性能信息了:
配置域名:
安装NGINX:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
[root@adamhuan-info-center ~]# yum install -y nginx Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.10.2-1.el7 will be installed --> Processing Dependency: nginx-filesystem = 1:1.10.2-1.el7 for package: 1:nginx-1.10.2-1.el7.x86_64 --> Processing Dependency: nginx-all-modules = 1:1.10.2-1.el7 for package: 1:nginx-1.10.2-1.el7.x86_64 --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.10.2-1.el7.x86_64 --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.10.2-1.el7.x86_64 --> Running transaction check ---> Package gperftools-libs.x86_64 0:2.4-8.el7 will be installed --> Processing Dependency: libunwind.so.8()(64bit) for package: gperftools-libs-2.4-8.el7.x86_64 ---> Package nginx-all-modules.noarch 1:1.10.2-1.el7 will be installed --> Processing Dependency: nginx-mod-stream = 1:1.10.2-1.el7 for package: 1:nginx-all-modules-1.10.2-1.el7.noarch --> Processing Dependency: nginx-mod-mail = 1:1.10.2-1.el7 for package: 1:nginx-all-modules-1.10.2-1.el7.noarch --> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.10.2-1.el7 for package: 1:nginx-all-modules-1.10.2-1.el7.noarch --> Processing Dependency: nginx-mod-http-perl = 1:1.10.2-1.el7 for package: 1:nginx-all-modules-1.10.2-1.el7.noarch --> Processing Dependency: nginx-mod-http-image-filter = 1:1.10.2-1.el7 for package: 1:nginx-all-modules-1.10.2-1.el7.noarch --> Processing Dependency: nginx-mod-http-geoip = 1:1.10.2-1.el7 for package: 1:nginx-all-modules-1.10.2-1.el7.noarch ---> Package nginx-filesystem.noarch 1:1.10.2-1.el7 will be installed --> Running transaction check ---> Package libunwind.x86_64 2:1.1-5.el7_2.2 will be installed ---> Package nginx-mod-http-geoip.x86_64 1:1.10.2-1.el7 will be installed --> Processing Dependency: GeoIP for package: 1:nginx-mod-http-geoip-1.10.2-1.el7.x86_64 --> Processing Dependency: libGeoIP.so.1()(64bit) for package: 1:nginx-mod-http-geoip-1.10.2-1.el7.x86_64 ---> Package nginx-mod-http-image-filter.x86_64 1:1.10.2-1.el7 will be installed ---> Package nginx-mod-http-perl.x86_64 1:1.10.2-1.el7 will be installed ---> Package nginx-mod-http-xslt-filter.x86_64 1:1.10.2-1.el7 will be installed ---> Package nginx-mod-mail.x86_64 1:1.10.2-1.el7 will be installed ---> Package nginx-mod-stream.x86_64 1:1.10.2-1.el7 will be installed --> Running transaction check ---> Package GeoIP.x86_64 0:1.5.0-11.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================================== Installing: nginx x86_64 1:1.10.2-1.el7 epel 505 k Installing for dependencies: GeoIP x86_64 1.5.0-11.el7 base 1.1 M gperftools-libs x86_64 2.4-8.el7 base 272 k libunwind x86_64 2:1.1-5.el7_2.2 base 56 k nginx-all-modules noarch 1:1.10.2-1.el7 epel 16 k nginx-filesystem noarch 1:1.10.2-1.el7 epel 17 k nginx-mod-http-geoip x86_64 1:1.10.2-1.el7 epel 23 k nginx-mod-http-image-filter x86_64 1:1.10.2-1.el7 epel 26 k nginx-mod-http-perl x86_64 1:1.10.2-1.el7 epel 35 k nginx-mod-http-xslt-filter x86_64 1:1.10.2-1.el7 epel 25 k nginx-mod-mail x86_64 1:1.10.2-1.el7 epel 53 k nginx-mod-stream x86_64 1:1.10.2-1.el7 epel 46 k Transaction Summary ============================================================================================================================================================================== Install 1 Package (+11 Dependent packages) Total size: 2.1 M Total download size: 745 k Installed size: 6.0 M Downloading packages: (1/9): nginx-all-modules-1.10.2-1.el7.noarch.rpm | 16 kB 00:00:00 (2/9): nginx-1.10.2-1.el7.x86_64.rpm | 505 kB 00:00:00 (3/9): nginx-filesystem-1.10.2-1.el7.noarch.rpm | 17 kB 00:00:00 (4/9): nginx-mod-http-geoip-1.10.2-1.el7.x86_64.rpm | 23 kB 00:00:00 (5/9): nginx-mod-http-perl-1.10.2-1.el7.x86_64.rpm | 35 kB 00:00:00 (6/9): nginx-mod-http-image-filter-1.10.2-1.el7.x86_64.rpm | 26 kB 00:00:00 (7/9): nginx-mod-http-xslt-filter-1.10.2-1.el7.x86_64.rpm | 25 kB 00:00:00 (8/9): nginx-mod-stream-1.10.2-1.el7.x86_64.rpm | 46 kB 00:00:00 (9/9): nginx-mod-mail-1.10.2-1.el7.x86_64.rpm | 53 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 569 kB/s | 745 kB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2:libunwind-1.1-5.el7_2.2.x86_64 1/12 Installing : gperftools-libs-2.4-8.el7.x86_64 2/12 Installing : 1:nginx-filesystem-1.10.2-1.el7.noarch 3/12 Installing : GeoIP-1.5.0-11.el7.x86_64 4/12 Installing : 1:nginx-mod-http-perl-1.10.2-1.el7.x86_64 5/12 Installing : 1:nginx-mod-mail-1.10.2-1.el7.x86_64 6/12 Installing : 1:nginx-mod-http-geoip-1.10.2-1.el7.x86_64 7/12 Installing : 1:nginx-mod-http-image-filter-1.10.2-1.el7.x86_64 8/12 Installing : 1:nginx-mod-stream-1.10.2-1.el7.x86_64 9/12 Installing : 1:nginx-1.10.2-1.el7.x86_64 10/12 Installing : 1:nginx-mod-http-xslt-filter-1.10.2-1.el7.x86_64 11/12 Installing : 1:nginx-all-modules-1.10.2-1.el7.noarch 12/12 Verifying : 1:nginx-mod-http-xslt-filter-1.10.2-1.el7.x86_64 1/12 Verifying : 1:nginx-mod-http-perl-1.10.2-1.el7.x86_64 2/12 Verifying : 1:nginx-mod-mail-1.10.2-1.el7.x86_64 3/12 Verifying : gperftools-libs-2.4-8.el7.x86_64 4/12 Verifying : GeoIP-1.5.0-11.el7.x86_64 5/12 Verifying : 1:nginx-mod-http-geoip-1.10.2-1.el7.x86_64 6/12 Verifying : 1:nginx-mod-http-image-filter-1.10.2-1.el7.x86_64 7/12 Verifying : 1:nginx-mod-stream-1.10.2-1.el7.x86_64 8/12 Verifying : 1:nginx-all-modules-1.10.2-1.el7.noarch 9/12 Verifying : 1:nginx-1.10.2-1.el7.x86_64 10/12 Verifying : 1:nginx-filesystem-1.10.2-1.el7.noarch 11/12 Verifying : 2:libunwind-1.1-5.el7_2.2.x86_64 12/12 Installed: nginx.x86_64 1:1.10.2-1.el7 Dependency Installed: GeoIP.x86_64 0:1.5.0-11.el7 gperftools-libs.x86_64 0:2.4-8.el7 libunwind.x86_64 2:1.1-5.el7_2.2 nginx-all-modules.noarch 1:1.10.2-1.el7 nginx-filesystem.noarch 1:1.10.2-1.el7 nginx-mod-http-geoip.x86_64 1:1.10.2-1.el7 nginx-mod-http-image-filter.x86_64 1:1.10.2-1.el7 nginx-mod-http-perl.x86_64 1:1.10.2-1.el7 nginx-mod-http-xslt-filter.x86_64 1:1.10.2-1.el7 nginx-mod-mail.x86_64 1:1.10.2-1.el7 nginx-mod-stream.x86_64 1:1.10.2-1.el7 Complete! [root@adamhuan-info-center ~]# |
修改Nginx配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
[root@adamhuan-info-center nginx]# pwd /etc/nginx [root@adamhuan-info-center nginx]# [root@adamhuan-info-center nginx]# cat nginx.conf | grep -v "^#" | strings user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 88 default_server; listen [::]:88 default_server; server_name 192.168.92.134; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:2368; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } [root@adamhuan-info-center nginx]# [root@adamhuan-info-center nginx]# |
修改NGINX端口为88,并设置了PROXY_PASS.
启动NGINX:
1 2 3 4 |
[root@adamhuan-info-center nginx]# service nginx start Redirecting to /bin/systemctl start nginx.service [root@adamhuan-info-center nginx]# [root@adamhuan-info-center nginx]# |
这样,就可以通过访问IP的方式访问到GHOST了:
http://192.168.92.134:88/
否则,只能通过【127.0.0.1】访问GHOST。
————————————————————
其他的工具:
安装Ghost-cli:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@adamhuan-info-center ghost_home]# npm i -g ghost-cli (更多信息) │ ├── chownr@1.0.1 │ └── pump@1.0.2 ├─┬ tar-stream@1.5.4 │ ├── bl@1.2.1 │ ├── end-of-stream@1.4.0 │ └── xtend@4.0.1 ├── v8-compile-cache@1.1.0 └─┬ validate-npm-package-license@3.0.1 ├─┬ spdx-correct@1.0.2 │ └── spdx-license-ids@1.2.2 └── spdx-expression-parse@1.0.4 You have new mail in /var/spool/mail/root [root@adamhuan-info-center ghost_home]# |
帮助信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@adamhuan-info-center ghost_home]# ghost help Commands: buster Who ya gonna call? [aliases: b, bu, bus, bust, buste, buster, busters] config [key] [value] Configure a Ghost instance [aliases: c, co, con, conf, confi, config] doctor [category] Check the system for any potential hiccups when installing/updating Ghost [aliases: d, do, doc, doct, docto, doctor] install [version] Install a brand new instance of Ghost [aliases: i, in, ins, inst, insta, instal, install, intsall, insall] log [name] View the logs of a Ghost instance [aliases: lo, log] ls View running ghost processes [aliases: ls, status] restart Restart the Ghost instance [aliases: re, res, rest, resta, restar, restart] run Run a Ghost instance directly (used by process managers and for debugging) [aliases: ru, run] setup [stages..] Setup an installation of Ghost (after it is installed) [aliases: se, set, setu, setup] start Start an instance of Ghost [aliases: sta, star, start] stop [name] Stops an instance of Ghost [aliases: sto, stop] uninstall Remove a Ghost instance and any related configuration files [aliases: un, uni, unin, unins, uninst, uninsta, uninstal, uninstall] update [version] Update a Ghost instance [aliases: up, upd, upda, updat, update, upgrade, udpate] version Prints out Ghost-CLI version (and Ghost version if one exists) [aliases: v, ve, ver, vers, versi, versio, version, --version, -v] Options: -D, --development Run in development mode [boolean] -V, --verbose Enable verbose output [boolean] --prompt [--no-prompt] Allow/Disallow UI prompting [boolean] [default: true] --help Show help [boolean] For more information, see our docs at https://docs.ghost.org/docs/ghost-cli [root@adamhuan-info-center ghost_home]# |
——————————
Done。