Last active
October 8, 2018 14:17
-
-
Save 798886844/7feafadf6b19d423f285a03f93f8c121 to your computer and use it in GitHub Desktop.
发现并修正问题。
This file contains hidden or 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
本文来自[如有乐享](https://51.ruyo.net/9976.html),但是本人在Linux上测试后发现其在`nodejs`、`npm`和`now`安装的描述中存在着一些问题。所以部分转载并做了一些补充。 | |
测试环境:Docker镜像:`rastasheep/ubuntu-sshd` | |
1. 首先是更新系统环境: | |
```Ubuntu | |
apt-get upgrade | |
apt-get update | |
apt-get install -y git | |
``` | |
如果有其他软件需求请自行安装。 | |
2. 安装`nodejs`和`npm` | |
```Ubuntu | |
apt install nodejs | |
apt install npm | |
``` | |
3. 升级`npm`为最新版本 | |
```Ubuntu | |
npm install npm@latest -g | |
``` | |
4. 安装用于安装`nodejs`的模块`n` | |
```Ubuntu | |
npm install -g n | |
``` | |
5. 然后通过`n`模块安装稳定版本的`nodejs` | |
```Ubuntu | |
n stable | |
``` | |
6. 安装`now.sh`客户端 | |
```Ubuntu | |
npm install -g now | |
``` | |
7. 登陆`now`账号 | |
```Ubuntu | |
now login | |
``` | |
8. 拉取最新的`oneindex`代码并部署 | |
```Ubuntu | |
git clone https://github.com/malaohu/oneindex.git -b now-sh | |
cd oneindex | |
now | |
``` | |
在部署过程中会出现你的URL,类似于`https://oneindex-code.now.sh`,其中`code`是一段随机码,比较难记,有两种方法可以缩短网址。 | |
也可以到now.sh管理面板中查看,地址:`https://zeit.co/dashboard` | |
9. 缩短网址的第一种方法,now.sh转发 | |
这是now.sh官网提供的一种方法。由用户指定一个`subdomain`,即一个短语,然后生成新的网址为`https://subdomain.now.sh`,具体操作如下: | |
```Ubuntu | |
now alias oneindex-code.now.sh subdomain | |
``` | |
10. 缩短网址的第二种方法,绑定自己的域名 | |
该操作对域名有要求,必须拥有对顶级域名的操作权。需要在顶级域名下添加TXT记录。具体操作如下: | |
```Ubuntu | |
now alias oneindex-code.now.sh yourdomain.com | |
``` | |
这样,在SSH中就会出现now的验证,第一次验证会失败,需要你在顶级域名下添加TXT记录以验证域名所有权,然后再次验证,域名所有权验证通过,但是域名没有指定到网页上,因此,会再次出现错误,这时需要你把自己的域名`CNAME`到`alias.zeit.co`上。第三次验证,成功,可以通过自己的域名访问了。 | |
11. 部署完成后,容器默认会隔一段时间重启,为了不让容器重启,执行下面的命令 | |
```Ubuntu | |
now scale oneindex-code.now.sh 1 | |
``` | |
至此,该部分教程结束。说一下我个人的感受。首先就是省心,now这个平台和github合作的,想来应该很稳定了,其次就是自己的域名一绑定上就有https,还是值得一玩的。 | |
当然,也有缺点,第一,不支持伪静态,第二,不能设置crontab定时任务。不过这两点没有刚需其实也是无所谓的。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment