GitHub上是这样写的

线上跑的是 Node.js v4.4.0,MongoDB 是 v3.0.5,Redis 是 v3.0.3。

1. 安装 `Node.js/io.js[必须]` `MongoDB[必须]` `Redis[必须]`
2. 启动 MongoDB 和 Redis
3. `$ make install` 安装 Nodeclub 的依赖包
4. `cp config.default.js config.js` 请根据需要修改配置文件
5. `$ make test` 确保各项服务都正常
6. `$ node app.js`
7. visit `http://localhost:3000`
8. done!

前面准备工作已经做完,现在git一份源码吧

[[email protected] ~]# git --version
git version 1.7.1
[[email protected] ~]# git clone https://github.com/cnodejs/nodeclub.git
Initialized empty Git repository in /root/nodeclub/nodeclub/.git/
remote: Counting objects: 10273, done.
remote: Total 10273 (delta 0), reused 0 (delta 0), pack-reused 10273
Receiving objects: 100% (10273/10273), 9.01 MiB | 3.35 MiB/s, done.
Resolving deltas: 100% (6639/6639), done.
[[email protected] ~]# ls
nodeclub
[[email protected] ~]# mv nodeclub /home/wwwroot/
[[email protected] ~# cd /home/wwwroot/
[[email protected] wwwroot]# ls
default  ghost  Ghost-0.7.4-zh-full.zip  ghost1  nodeclub  testweb  wordpress-4.7.2-zh_CN.tar.gz
[[email protected] wwwroot]# cd nodeclub
[[email protected] nodeclub]# cp config.default.js config.js
[[email protected] nodeclub]# vim config.js
[[email protected] nodeclub]# make install
warn不要紧
[[email protected] nodeclub]# node app.js
[2017-02-15 20:37:25.587] [INFO] cheese - NodeClub listening on port 3000
[2017-02-15 20:37:25.588] [INFO] cheese - God bless love....
[2017-02-15 20:37:25.589] [INFO] cheese - You can debug your app with http://localhost:3000
[2017-02-15 20:37:25.589] [INFO] cheese -

成功启动。

配置Nginx

[[email protected] ~]# cd /usr/local/nginx/conf/vhost
[[email protected] vhost]# ls
ghost.kokwind.net.conf  test.kokwind.net.conf
[[email protected] vhost]# cp ghost.kokwind.net.conf club.kokwind.net
[[email protected] vhost]# vim club.kokwind.net
server
 {
 listen 80;
 #listen [::]:80;
 server_name club.kokwind.net;
 index index.html index.htm index.php default.html default.htm default.php;
 root /home/wwwroot/nodeclub;

 include none.conf;
 #error_page 404 /404.html;
 include enable-php.conf;

 location / {
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header Host $http_host;
 proxy_pass http://localhost:3000;
 proxy_set_header REMOTE-HOST $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
 access_log /home/wwwlogs/nodeclub.log;
 }
[[email protected] vhost]# /etc/init.d/nginx reload
Reload service nginx... done
[[email protected] vhost]# cd /home/wwwroot/nodeclub/
[[email protected] nodeclub]#

使用pm2启动,pm2安装使用参考这里

[[email protected] nodeclub]# pm2 start app.js
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /home/wwwroot/nodeclub/app.js in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────┬───────────┬──────────┐
│ App name │ id │ mode │ pid  │ status │ restart │ uptime │ cpu │ mem       │ watching │
├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────┼───────────┼──────────┤
│ app      │ 0  │ fork │ 5431 │ online │ 0       │ 0s     │ 0%  │ 10.5 MB   │ disabled │
└──────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────┴───────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app
[[email protected] nodeclub]#

打开网址

Copyright © OneZos all right reserved,powered by Gitbook本书发布时间: 2021-11-16 19:13:04

results matching ""

    No results matching ""