forked from nswbmw/N-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,9 +137,7 @@ heroku logs | |
|
||
## 4.15.3 部署到 UCloud | ||
|
||
[UCloud](https://www.ucloud.cn/) 是国内的一家云计算服务商,接下来我们尝试将博客搭在 UCloud 上。 | ||
|
||
#### 创建主机 | ||
### 创建主机 | ||
|
||
1. 注册 UCloud | ||
2. 点击左侧的 `云主机`,然后点击 `创建主机`,统统选择最低配置 | ||
|
@@ -152,7 +150,7 @@ heroku logs | |
|
||
> 注意:下面所有的 ip 都替换为你自己的外网 ip。 | ||
#### 环境搭建与部署 | ||
### 环境搭建与部署 | ||
|
||
修改 config/production.js,将 port 修改为 80 端口: | ||
|
||
|
@@ -203,4 +201,94 @@ pm2 logs | |
|
||
> 小提示:因为我们选择的按时付费套餐,测试完成后,可在主机管理页面选择关闭主机,节约费用。 | ||
## 4.15.4 部署到阿里云 | ||
|
||
### 创建主机 | ||
|
||
1. 注册/登录 | ||
2. 充值 100(因为我们选择『按量付费』,阿里云要求最低账户余额 >= 100) | ||
3. 进入『云服务器 ECS』 | ||
4. 点击『创建实例』 | ||
|
||
进入创建实例页面,按下图选择配置: | ||
|
||
![](./img/4.15.4.png) | ||
|
||
需要注意几点: | ||
|
||
1. 计费方式:按量付费 | ||
2. 公网 ip 地址:分配 | ||
3. 安全组:选中开启 80 端口 | ||
4. 镜像:Ubuntu 16.04 64位 | ||
|
||
点击『开通进入下一页』,选中: | ||
|
||
![](./img/4.15.5.png) | ||
|
||
> 注意:这里我们只是演示,所以自动释放时间只设置了几个小时 | ||
点击『去开通』创建成功,然后点击提示中的『管理控制台』进入 ECS 管理页,刚才创建的机器需要等待几分钟才会初始化成功。成功后如下所示: | ||
|
||
![](./img/4.15.6.png) | ||
|
||
### 环境搭建 | ||
|
||
复制创建的机器的公网 ip 地址,运行: | ||
|
||
```sh | ||
ssh [email protected] | ||
``` | ||
|
||
输入刚才设置的密码登录远程主机。 | ||
|
||
#### 安装 Node.js | ||
|
||
我们下载编译好的 Node.js 压缩包,解压然后使用软连接。 | ||
|
||
```sh | ||
wget https://nodejs.org/dist/v8.9.1/node-v8.9.1-linux-x64.tar.xz | ||
tar -xvf node-v8.9.1-linux-x64.tar.xz | ||
mv node-v8.9.1-linux-x64 nodejs | ||
ln -s ~/nodejs/bin/* /usr/local/bin/ | ||
node -v | ||
npm -v | ||
``` | ||
|
||
#### 安装 MongoDB | ||
|
||
```sh | ||
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.4.10.tgz | ||
tar -xvf mongodb-linux-x86_64-ubuntu1604-3.4.10.tgz | ||
mv mongodb-linux-x86_64-ubuntu1604-3.4.10 mongodb | ||
ln -s ~/mongodb/bin/* /usr/local/bin/ | ||
mongod --version | ||
mongo --version | ||
mkdir mongodb/data | ||
mongod --dbpath=mongodb/data & | ||
``` | ||
|
||
#### 安装 Git | ||
|
||
```sh | ||
apt-get update | ||
apt-get install git | ||
git clone https://github.com/nswbmw/N-blog.git #或者你的 GitHub blog 地址 | ||
cd N-blog | ||
npm i | ||
vim config/default.js #修改端口 3000->80 | ||
node index | ||
``` | ||
|
||
此时,浏览器中访问你的机器的公网 ip 试试吧。 | ||
|
||
#### 使用 PM2 启动 | ||
|
||
```sh | ||
npm i pm2 -g | ||
ln -s ~/nodejs/bin/* /usr/local/bin/ | ||
pm2 start index.js --name="myblog" | ||
``` | ||
|
||
这里我们使用 pm2 启动博客,所以关掉终端后博客仍然在运行。 | ||
|
||
上一节:[4.14 测试](https://github.com/nswbmw/N-blog/blob/master/book/4.14%20%E6%B5%8B%E8%AF%95.md) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.