-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.xml
390 lines (331 loc) · 63.2 KB
/
search.xml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title><![CDATA[使用DigitalOcean搭建ShadowSocks及其优化]]></title>
<url>/2017/12/03/%E4%BD%BF%E7%94%A8DigitalOcean%E6%90%AD%E5%BB%BAShadowSocks%E5%8F%8A%E5%85%B6%E4%BC%98%E5%8C%96/</url>
<content type="html"><![CDATA[<p><strong><em>前言</em></strong></p>
<p>在github的教育资助下买了DigitalOcean的服务器,送了50刀,不错啊,其实用别人的邀请码可以再多10刀的。</p>
<p>一直看朋友自己塔梯子,挺好用的,刚好买了vps,就琢磨着干脆自己来搭个梯子。</p>
<p>本文将包括一下内容:</p>
<ol>
<li>DigitalOcean注册与配置</li>
<li>服务器端ss配置</li>
<li>bbr加速</li>
</ol>
<!--morre-->
<h1 id="一-概念介绍"><a href="#一-概念介绍" class="headerlink" title="一. 概念介绍"></a>一. 概念介绍</h1><p><code>DigitalOcean</code>(以下简称DO)是美国的一家云主机提供商,其目前拥有包括美国(纽约、旧金山)、荷兰阿姆斯特丹、新加坡、英国伦敦、德国法兰克福、加拿大多伦多和印度班加罗尔共8个城市12个可选机房节点。其采用KVM虚拟机,配置高性能的SSD做储存,拥有IPv6可选项,加上服务器配备的是1000M端口,以512M内存为起点,再加上DO较低的价格$5起/月(而且还有其他方式可以获得优惠,下面会讲到),受到很多的追捧。选用这么一个主机不仅可以用来搭建ss,有一定网页制作基础的同学也可以搭建自己的个人网站,甚至可以选择DO提供的高级套餐来进行机器学习等大规模云计算。</p>
<p><code>Shadowsocks</code> 是由大神 clowwindy(传说是妹纸)开发的一款基于SSH的通讯方式,或者理解为SSH的一个变种。简单来说,其原理就是在墙的两边分别建立起ssh-local和ssh-server两个端口,用户PC首先基于Socks5协议与ssh-local进行通讯,其信息由ssh-local进行多种可选方式的加密后通过墙与另一侧的ssh-server通讯,该信息由ssh-server解密后再对真正的目标地址进行请求。因为ssh-local与ssh-server之间的加密理论无法解密且不含特征信息,就是普通的TCP包,因此无法被捕获或拦截。由于该程序实在太过优秀,因此作者本人被请去喝了茶后就把github上的项目删去了,只留下一句:</p>
<pre><code>Removed according to regulations.
</code></pre><p>ps:以上是cope的。</p>
<h1 id="二-DigitalOcean注册与购买"><a href="#二-DigitalOcean注册与购买" class="headerlink" title="二. DigitalOcean注册与购买"></a>二. DigitalOcean注册与购买</h1><p>DigitalOcean的官网目前在中国大陆可以正常访问,欢迎通过我的<a href="https://m.do.co/c/c738abd7e496" target="_blank" rel="external">邀请链接进行注册</a>.即获得10美元的优惠。现在最低价为5美元/月,因此可以说得到了免费两个月的额度。之后如果您付款超过$25美元,我也会得到网站一定的奖励,是个互惠互利的事儿:)</p>
<h2 id="1-首先在主页即可注册:DigitalOcean官网-我的邀请链接可以得到10美金"><a href="#1-首先在主页即可注册:DigitalOcean官网-我的邀请链接可以得到10美金" class="headerlink" title="1.首先在主页即可注册:DigitalOcean官网 我的邀请链接可以得到10美金"></a>1.首先在主页即可注册:<a href="https://www.digitalocean.com/" target="_blank" rel="external">DigitalOcean官网</a> <a href="https://m.do.co/c/c738abd7e496" target="_blank" rel="external">我的邀请链接</a>可以得到10美金</h2><p><img src="/photo/bVWGw1.jpeg" alt=""></p>
<p>注测后添加付款方式:需要绑定“VISA信用卡”或“PayPal账户”用于付款。采用绑定“VISA信用卡”的方式,会先从账户中扣除1刀,10分钟左右返还,确定账户的可以付款,不需要提前付费;采用绑定“PayPal账户”的方式,必须首先至少充值5刀。</p>
<h2 id="2-创建“Droplet”虚拟机"><a href="#2-创建“Droplet”虚拟机" class="headerlink" title="2.创建“Droplet”虚拟机"></a>2.创建“Droplet”虚拟机</h2><ul>
<li>推荐的配置如下:</li>
</ul>
<h3 id="1-镜像和大小的选择"><a href="#1-镜像和大小的选择" class="headerlink" title="1.镜像和大小的选择"></a>1.镜像和大小的选择</h3><p><img src="/photo/镜像.png" alt=""></p>
<p>注:DigitalOcean是Shadowsocks Wiki上推荐的VPS之一,<br>同时Ubuntu是推荐的系统,<br>详情参见 <a href="https://github.com/shadowsocks/shadowsocks/wiki/Shadowsocks-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E" target="_blank" rel="external">Shadowsocks</a> 使用说明中的“服务器搭建”。</p>
<h3 id="2-选择服务器所在地区"><a href="#2-选择服务器所在地区" class="headerlink" title="2.选择服务器所在地区"></a>2.选择服务器所在地区</h3><p>服务器地址可从<a href="http://speedtest-fra1.digitalocean.com/" target="_blank" rel="external">DigitalOcean测速</a>网址进行测速。<br><img src="/photo/bVWGxG.jpeg" alt=""></p>
<h3 id="3-其他"><a href="#3-其他" class="headerlink" title="3.其他"></a>3.其他</h3><p><img src="/photo/bVWGyg.jpeg" alt=""></p>
<p><img src="/photo/bVWGyH.jpeg" alt=""></p>
<ul>
<li>勾选IPv6。IPv6可用于连接教育网的PT站等。</li>
<li>添加SSH公钥,用于SSH远程连接主机。生成密钥的命令为ssh-keygen -t rsa -C “yourmail”。</li>
</ul>
<h3 id="4-最后"><a href="#4-最后" class="headerlink" title="4.最后"></a>4.最后</h3><p>可以取个名字<br><img src="/photo/bVWGyO.jpeg" alt=""></p>
<h2 id="二、服务器端ss配置"><a href="#二、服务器端ss配置" class="headerlink" title="二、服务器端ss配置"></a>二、服务器端ss配置</h2><p>如果没有配置ssh 你会发现自己的邮箱收到如下的一封邮件告诉了你IP地址(IP Address)、用户名(Username)和初始密码(Password)<br>如果配置了ssh,就可以直接登陆。</p>
<pre><code>ssh root@IP
</code></pre><h3 id="1-服务器端安装SS"><a href="#1-服务器端安装SS" class="headerlink" title="1.服务器端安装SS"></a>1.服务器端安装SS</h3><figure class="highlight objc"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">apt-get update <span class="comment">// 更新源中包列表</span></div><div class="line">apt-get install python-pip <span class="comment">// 安装pip</span></div><div class="line">pip install --upgrade pip <span class="comment">// 更新pip</span></div><div class="line">apt-get install git</div><div class="line">pip install git+https:<span class="comment">//github.com/shadowsocks/shadowsocks.git@master // 安装SS</span></div></pre></td></tr></table></figure>
<h3 id="2-安装chacha20加密"><a href="#2-安装chacha20加密" class="headerlink" title="2.安装chacha20加密"></a>2.安装chacha20加密</h3><p>虽然shadowsocks的作者推荐使用<code>aes-256-cfb</code>的加密算法,但是这个算法对手机或者openwrt路由器的压力还是不小的,于是后来Google推出的<code>chacha20</code>算法因为其安全性和惊人的速度被现在更多人使用。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">apt-get install build-essential</div><div class="line">wget https://github.com/jedisct1/libsodium/releases/download/1.0.8/libsodium-1.0.8.tar.gz</div><div class="line">tar xf libsodium-1.0.8.tar.gz && <span class="built_in">cd</span> libsodium-1.0.8</div><div class="line">./configure && make -j2</div><div class="line">make install</div><div class="line">ldconfig</div></pre></td></tr></table></figure></p>
<h3 id="3-服务器端配置"><a href="#3-服务器端配置" class="headerlink" title="3.服务器端配置"></a>3.服务器端配置</h3><ul>
<li>配置shadowsocks文件<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">vim /etc/shadowsocks.json</div></pre></td></tr></table></figure>
</li>
</ul>
<p>这是shadowsocks.json的详情:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">{</div><div class="line"></div><div class="line"> <span class="string">"server"</span>: <span class="string">"服务器的ip"</span>,</div><div class="line"> <span class="string">"server_port"</span>: 8388,</div><div class="line"> <span class="string">"local_address"</span>: <span class="string">"127.0.0.1"</span>,</div><div class="line"> <span class="string">"local_port"</span>: 1080,</div><div class="line"> <span class="string">"password"</span>: <span class="string">"你的密码"</span>,</div><div class="line"> <span class="string">"timeout"</span>: 300,</div><div class="line"> <span class="string">"method"</span>: <span class="string">"chacha20"</span>,</div><div class="line"> <span class="string">"fast_open"</span>: <span class="literal">false</span></div><div class="line">}</div></pre></td></tr></table></figure></p>
<ul>
<li>服务器端启动与停止(一直启动即可)<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">ssserver -c /etc/shadowsocks.json -d start</div><div class="line">ssserver -c /etc/shadowsocks.json -d stop</div></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="三、BBR加速"><a href="#三、BBR加速" class="headerlink" title="三、BBR加速"></a>三、BBR加速</h2><p>TCP-BBR:Linux的内核必须是4.9.0-rc8 内核及以后的版本 才能开启,而锐速并不支持这个最新的内核版本,所以TCP-BBR和锐速是不能共存的。</p>
<h3 id="1-查看系统"><a href="#1-查看系统" class="headerlink" title="1.查看系统"></a>1.查看系统</h3><pre><code>uname -m
</code></pre><p>使用这个命令会返回你的系统位数,如果是 x86_64 那就是64位,如果是 i386 或 386 或 i686 或 686 那就是32位。</p>
<h3 id="2-下载内核文件"><a href="#2-下载内核文件" class="headerlink" title="2.下载内核文件"></a>2.下载内核文件</h3><ul>
<li>64位系统</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">wget -O linux-image-4.10.1-amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb</div></pre></td></tr></table></figure>
<ul>
<li>32位系统</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">wget -O linux-image-4.10.1-i386.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_i386.deb</div></pre></td></tr></table></figure>
<p>下载完是这样的:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># VPS提示(64位)</span></div><div class="line"></div><div class="line"> root@bbr1:~<span class="comment"># wget -O linux-image-4.10.1-amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb</span></div><div class="line"> converted <span class="string">'http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.1/linux-image-4.10.1-041001-generic_4.10.1-041001.201702260735_amd64.deb'</span> (ANSI_X3.4-1968) -> <span class="string">'http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9-rc8/linux-image-4.10.1-040900rc8-generic_4.10.1-040900rc8.201612051443_amd64.deb'</span> (UTF-8)</div><div class="line"> --2016-12-08 15:31:16-- http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-image-4.10.1-040900-generic_4.10.1-040900.201612111631_amd64.deb</div><div class="line"> Resolving kernel.ubuntu.com (kernel.ubuntu.com)... 91.189.94.216</div><div class="line"> Connecting to kernel.ubuntu.com (kernel.ubuntu.com)|91.189.94.216|:80... connected.</div><div class="line"> HTTP request sent, awaiting response... 200 OK</div><div class="line"> Length: 60489324 (58M) [application/x-debian-package]</div><div class="line"> Saving to: <span class="string">'linux-image-4.10.1-amd64.deb'</span></div><div class="line"></div><div class="line"> linux-image-4.10.1-040900 100%[=====================================>] 57.69M 3.02MB/s <span class="keyword">in</span> 14s</div><div class="line"></div><div class="line"> 2016-12-08 15:31:31 (4.05 MB/s) - <span class="string">'linux-image-4.10.1-amd64.deb'</span> saved [60489324/60489324]</div></pre></td></tr></table></figure></p>
<h3 id="3-安装内核"><a href="#3-安装内核" class="headerlink" title="3.安装内核"></a>3.安装内核</h3><ul>
<li><p>64位系统</p>
<p> dpkg -i linux-image-4.10.1-amd64.deb</p>
</li>
<li><p>32位系统</p>
<p> dpkg -i linux-image-4.10.1-i386.deb</p>
</li>
</ul>
<p>安装成功:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># VPS提示</span></div><div class="line"></div><div class="line">root@bbr1:~<span class="comment"># dpkg -i linux-image-4.10.1-amd64.deb</span></div><div class="line">Selecting previously unselected package linux-image-4.10.1-040900rc8-generic.</div><div class="line">(Reading database ... 25141 files and directories currently installed.)</div><div class="line">Preparing to unpack linux-image-4.10.1-040900rc8-generic_4.10.1-040900rc8.201612051443_amd64.deb ...</div><div class="line">Done.</div><div class="line">Unpacking linux-image-4.10.1-040900rc8-generic (4.10.1-040900rc8.201612051443) ...</div><div class="line">Setting up linux-image-4.10.1-040900rc8-generic (4.10.1-040900rc8.201612051443) ...</div><div class="line">Running depmod.</div><div class="line">update-initramfs: deferring update (hook will be called later)</div><div class="line">Examining /etc/kernel/postinst.d.</div><div class="line">run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.10.1-040900rc8-generic /boot/vmlinuz-4.10.1-040900rc8-generic</div><div class="line">run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.10.1-040900rc8-generic /boot/vmlinuz-4.10.1-040900rc8-generic</div><div class="line">update-initramfs: Generating /boot/initrd.img-4.10.1-040900rc8-generic</div><div class="line">run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.10.1-040900rc8-generic /boot/vmlinuz-4.10.1-040900rc8-generic</div><div class="line">Generating grub configuration file ...</div><div class="line">Found linux image: /boot/vmlinuz-4.10.1-040900rc8-generic</div><div class="line">Found initrd image: /boot/initrd.img-4.10.1-040900rc8-generic</div><div class="line">Found linux image: /boot/vmlinuz-3.16.0-4-amd64</div><div class="line">Found initrd image: /boot/initrd.img-3.16.0-4-amd64</div><div class="line"><span class="keyword">done</span></div></pre></td></tr></table></figure></p>
<h3 id="4-列出并删除旧内核"><a href="#4-列出并删除旧内核" class="headerlink" title="4.列出并删除旧内核"></a>4.列出并删除旧内核</h3><p>列出VPS 除了刚才安装的内核以外的 所有内核名称:<br>ps:这个代码是排除了刚才安装的内核,所以不会显示刚才安装的那个内核。删除了多余的内核后,就会什么都不显示!</p>
<pre><code>dpkg -l|grep linux-image | awk '{print $2}' | grep -v 'linux-image-[4-9].[0-9]*.'
</code></pre><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">root@bbr1:~<span class="comment"># dpkg -l|grep linux-image | awk '{print $2}' | grep -v 'linux-image-[4-9].[0-9]*.'</span></div><div class="line">linux-image-3.16.0-4-amd64</div><div class="line">linux-image-amd64</div></pre></td></tr></table></figure>
<p>删除旧内核:</p>
<pre><code>apt-get purge 旧内核名称
</code></pre><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># !!!!示例!!!!</span></div><div class="line"><span class="comment"># 比如我是有这两个内核,所以我把这两个删掉,不要照着我的这个步骤做,自己换成你VPS的内核名称!!!</span></div><div class="line">apt-get purge linux-image-3.16.0-4-amd64</div><div class="line">apt-get purge linux-image-amd64</div><div class="line"><span class="comment"># !!!!示例!!!!</span></div></pre></td></tr></table></figure>
<h3 id="5-更新-grub-系统引导文件并重启VPS"><a href="#5-更新-grub-系统引导文件并重启VPS" class="headerlink" title="5.更新 grub 系统引导文件并重启VPS"></a>5.更新 grub 系统引导文件并重启VPS</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 更新系统引导文件</span></div><div class="line">update-grub</div><div class="line"><span class="comment"># 重启VPS,执行后SSH链接会断开,等十几秒再重新连接继续执行下面的启动命令。</span></div><div class="line">reboot</div></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># VPS提示</span></div><div class="line"></div><div class="line">root@bbr1:~<span class="comment"># update-grub</span></div><div class="line">Generating grub configuration file ...</div><div class="line">Found linux image: /boot/vmlinuz-4.10.1-040900rc8-generic</div><div class="line">Found initrd image: /boot/initrd.img-4.10.1-040900rc8-generic</div><div class="line"><span class="keyword">done</span></div></pre></td></tr></table></figure>
<h3 id="6-开启bbr"><a href="#6-开启bbr" class="headerlink" title="6.开启bbr"></a>6.开启bbr</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">echo</span> <span class="string">"net.core.default_qdisc=fq"</span> >> /etc/sysctl.conf</div><div class="line"><span class="built_in">echo</span> <span class="string">"net.ipv4.tcp_congestion_control=bbr"</span> >> /etc/sysctl.conf</div><div class="line"><span class="comment"># 执行这个保存生效更改。</span></div><div class="line">sysctl -p</div></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># VPS提示</span></div><div class="line"></div><div class="line">root@bbr1:~<span class="comment"># sysctl -p</span></div><div class="line">net.ipv6.conf.all.accept_ra = 2</div><div class="line">net.core.default_qdisc = fq</div><div class="line">net.ipv4.tcp_congestion_control = bbr</div></pre></td></tr></table></figure>
<h3 id="7-关闭bbr"><a href="#7-关闭bbr" class="headerlink" title="7.关闭bbr"></a>7.关闭bbr</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">sed -i <span class="string">'/net\.core\.default_qdisc=fq/d'</span> /etc/sysctl.conf && sed -i <span class="string">'/net\.ipv4\.tcp_congestion_control=bbr/d'</span> /etc/sysctl.conf</div><div class="line">sysctl -p</div><div class="line"></div><div class="line"><span class="comment">#执行完上面的代码,就使用reboot重启VPS后才能关闭bbr,重启后再用下面的查看bbr状态代码,查看是否关闭了。</span></div><div class="line">reboot</div></pre></td></tr></table></figure>
<h3 id="8-查看bbr是否开启"><a href="#8-查看bbr是否开启" class="headerlink" title="8.查看bbr是否开启"></a>8.查看bbr是否开启</h3><ul>
<li><p>执行下面命令,如果结果中有bbr,即证明你的内核已开启bbr。</p>
<p> sysctl net.ipv4.tcp_available_congestion_control</p>
</li>
<li><p>执行下面命令,看到有 tcp_bbr 模块,即说明bbr已启动</p>
<p> lsmod | grep bbr</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># VPS提示</span></div><div class="line">root@bbr1:~<span class="comment"># sysctl net.ipv4.tcp_available_congestion_control</span></div><div class="line">net.ipv4.tcp_available_congestion_control = bbr cubic reno</div><div class="line"></div><div class="line"><span class="comment"># ================================================</span></div><div class="line"></div><div class="line">root@bbr1:~<span class="comment"># lsmod | grep bbr</span></div><div class="line">tcp_bbr 20480 0</div></pre></td></tr></table></figure>
<p>这样就可以快乐的翻墙出去观看世界了 ^_^</p>
]]></content>
</entry>
<entry>
<title><![CDATA[ubuntu强制清除垃圾回收站]]></title>
<url>/2017/11/22/ubuntu%E5%BC%BA%E5%88%B6%E6%B8%85%E9%99%A4%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6%E7%AB%99/</url>
<content type="html"><![CDATA[<h1 id="强制清除垃圾回收站"><a href="#强制清除垃圾回收站" class="headerlink" title="强制清除垃圾回收站"></a>强制清除垃圾回收站</h1><a id="more"></a>
<h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>我遇到了无法在Ubuntu 16.04中清空回收站的问题。我右键回收站图标并选择清空回收站,就像我一直做的那样。我看到进度条显示删除文件中过了一段时间。但是它停止了,垃圾站中有些文件删除了,但有些文件还是没有删除。在看了文件夹后原来没有权限。</p>
<h2 id="方案"><a href="#方案" class="headerlink" title="方案"></a>方案</h2><p>Ubuntu 16.04的回收站路径为</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">:<span class="variable">$HOME</span>/.<span class="built_in">local</span>/share/Trash/</div></pre></td></tr></table></figure>
<p>然后用以下命令即可清空回收站</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo rm -fr <span class="variable">$HOME</span>/.<span class="built_in">local</span>/share/Trash/files/*</div></pre></td></tr></table></figure>
]]></content>
<categories>
<category> linux </category>
</categories>
<tags>
<tag> unbuntu </tag>
<tag> linux,垃圾站 </tag>
</tags>
</entry>
<entry>
<title><![CDATA[ubuntu配置]]></title>
<url>/2017/10/29/ubuntu%E9%85%8D%E7%BD%AE/</url>
<content type="html"><![CDATA[<h1 id="ubuntu16-04安装后配置"><a href="#ubuntu16-04安装后配置" class="headerlink" title="ubuntu16.04安装后配置"></a>ubuntu16.04安装后配置</h1><a id="more"></a>
<h2 id="0-更新源"><a href="#0-更新源" class="headerlink" title="0.更新源"></a>0.更新源</h2><p>更换阿里云的源<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># deb cdrom:[Ubuntu 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801)]/ xenial main restricted</span></div><div class="line"></div><div class="line"><span class="comment"># See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to</span></div><div class="line"><span class="comment"># newer versions of the distribution.</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted</span></div><div class="line"></div><div class="line"><span class="comment">## Major bug fix updates produced after the final release of the</span></div><div class="line"><span class="comment">## distribution.</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted</span></div><div class="line"></div><div class="line"><span class="comment">## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu</span></div><div class="line"><span class="comment">## team. Also, please note that software in universe WILL NOT receive any</span></div><div class="line"><span class="comment">## review or updates from the Ubuntu security team.</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial universe</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe</span></div><div class="line"></div><div class="line"><span class="comment">## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu</span></div><div class="line"><span class="comment">## team, and may not be under a free licence. Please satisfy yourself as to</span></div><div class="line"><span class="comment">## your rights to use the software. Also, please note that software in</span></div><div class="line"><span class="comment">## multiverse WILL NOT receive any review or updates from the Ubuntu</span></div><div class="line"><span class="comment">## security team.</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse</span></div><div class="line"></div><div class="line"><span class="comment">## N.B. software from this repository may not have been tested as</span></div><div class="line"><span class="comment">## extensively as that contained in the main release, although it includes</span></div><div class="line"><span class="comment">## newer versions of some applications which may provide useful features.</span></div><div class="line"><span class="comment">## Also, please note that software in backports WILL NOT receive any review</span></div><div class="line"><span class="comment">## or updates from the Ubuntu security team.</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse</div><div class="line"><span class="comment"># deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse</span></div><div class="line"></div><div class="line"><span class="comment">## Uncomment the following two lines to add software from Canonical's</span></div><div class="line"><span class="comment">## 'partner' repository.</span></div><div class="line"><span class="comment">## This software is not part of Ubuntu, but is offered by Canonical and the</span></div><div class="line"><span class="comment">## respective vendors as a service to Ubuntu users.</span></div><div class="line"><span class="comment"># deb http://archive.canonical.com/ubuntu xenial partner</span></div><div class="line"><span class="comment"># deb-src http://archive.canonical.com/ubuntu xenial partner</span></div><div class="line"></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted</div><div class="line"><span class="comment"># deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe</div><div class="line"><span class="comment"># deb-src http://security.ubuntu.com/ubuntu xenial-security universe</span></div><div class="line">deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse</div><div class="line"><span class="comment"># deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse</span></div></pre></td></tr></table></figure></p>
<p>list文件在<code>/etc/apt/sources.list</code>下</p>
<p>然后更新源和软件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">sudo apt-get update</div><div class="line">sudo apt-get dist-upgrade</div></pre></td></tr></table></figure></p>
<h2 id="1-更换显卡驱动"><a href="#1-更换显卡驱动" class="headerlink" title="1.更换显卡驱动"></a>1.更换显卡驱动</h2><p><img src="/photo/驱动01.png" alt="显卡更换"></p>
<p>ubuntu上有nvidia的驱动</p>
<h2 id="2-同步时间"><a href="#2-同步时间" class="headerlink" title="2.同步时间"></a>2.同步时间</h2><p>使用双系统时间不同,故要使用<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo timedatectl <span class="built_in">set</span>-local-rtc 1</div></pre></td></tr></table></figure></p>
<h2 id="3-安装软件"><a href="#3-安装软件" class="headerlink" title="3.安装软件"></a>3.安装软件</h2><h3 id="3-1-删除亚马逊链接"><a href="#3-1-删除亚马逊链接" class="headerlink" title="3.1 删除亚马逊链接"></a>3.1 删除亚马逊链接</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get remove unity-webapps-common</div></pre></td></tr></table></figure>
<h3 id="3-2-安装vim"><a href="#3-2-安装vim" class="headerlink" title="3.2 安装vim"></a>3.2 安装vim</h3><pre><code>sudo apt-get install vim
</code></pre><h3 id="3-3-安装git和vpnc"><a href="#3-3-安装git和vpnc" class="headerlink" title="3.3 安装git和vpnc"></a>3.3 安装git和vpnc</h3><pre><code>sudo apt-get install vpnc git
</code></pre><h3 id="3-4-安装ExFat文件系统驱动"><a href="#3-4-安装ExFat文件系统驱动" class="headerlink" title="3.4 安装ExFat文件系统驱动"></a>3.4 安装ExFat文件系统驱动</h3><p>Ubuntu默认不支持exFat文件系统的挂载,需要手动安装exfat的支持</p>
<pre><code>sudo apt-get install exfat-fuse
</code></pre><h3 id="3-5-修复分区"><a href="#3-5-修复分区" class="headerlink" title="3.5 修复分区"></a>3.5 修复分区</h3><pre><code>sudo ntfsfix /dev/sda8
</code></pre><h3 id="3-6安装atom"><a href="#3-6安装atom" class="headerlink" title="3.6安装atom"></a>3.6安装atom</h3><p>官网下载最新版本 <a href="https://atom.io/" target="_blank" rel="external">atom</a></p>
<h3 id="3-7-uget-aria2下载工具"><a href="#3-7-uget-aria2下载工具" class="headerlink" title="3.7 uget+aria2下载工具"></a>3.7 uget+aria2下载工具</h3><p>安装uget和aria2<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get install uget aria2</div></pre></td></tr></table></figure></p>
<p>配置</p>
<p> a.打开uget。</p>
<p> b.打开界面的编辑—>设置—>插件,插件匹配顺序:aria2 。</p>
<p> c.打开界面的分类—>默认一般设置。调整最大连接数(建议在5)。设置一下下载文件夹。</p>
<p>在火狐中使用Flashgot扩展就可以。</p>
<h3 id="3-8-安装shadowsocks-qt5"><a href="#3-8-安装shadowsocks-qt5" class="headerlink" title="3.8 安装shadowsocks-qt5"></a>3.8 安装shadowsocks-qt5</h3><ul>
<li>添加源安装</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">sudo add-apt-repository ppa:hzwhuang/ss-qt5</div><div class="line">sudo apt-get update</div><div class="line">sudo apt-get install shadowsocks-qt5</div></pre></td></tr></table></figure>
<h3 id="3-9-安装wine-TIM"><a href="#3-9-安装wine-TIM" class="headerlink" title="3.9 安装wine/TIM"></a>3.9 安装wine/TIM</h3><p>使用 wine staging ( 开发版本的 wine )安装详细教程 <a href="https://wine-staging.com/installation.html" target="_blank" rel="external">https://wine-staging.com/installation.html</a><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">sudo dpkg --add-architecture i386</div><div class="line"><span class="comment">#add the repository:</span></div><div class="line">wget -nc https://dl.winehq.org/wine-builds/Release.key</div><div class="line">sudo apt-key add Release.key</div><div class="line">sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/</div><div class="line"><span class="comment">#install</span></div><div class="line">sudo apt-get update</div><div class="line">sudo apt-get install --install-recommends winehq-staging</div></pre></td></tr></table></figure></p>
<p>去qq官网下载<a href="http://office.qq.com/" target="_blank" rel="external">TIM</a> 我使用的是TIM1.2。</p>
<p>安装wine后 ,命令执行<code>winecfg</code>然后会安装一些插件,选择安装它们。然后拷贝windows字体(不安装字体会使一些字无法查看)。</p>
<p>windows字体在c:\windows\fonts</p>
<p>把这个目录下字体全部复制到wine下的设置目录下:</p>
<p>~/.wine/drive_c/windows/Fonts/</p>
<p>重载所有wine的配置<code>wineboot</code><br>再次打开wine <code>winecfg</code>配置如图</p>
<p><img src="/photo/wine设置.png" alt="wine 设置"></p>
<p>然后重启一下wine <code>wineboot</code> 。安装tim时,使用Wine Windows Program Loader 打开TIM。然后就是windows下安装程序——点点点。</p>
<p>备注:此方法有个bug 当TIM打开讨论组时会是TIM崩溃。</p>
<p>建立桌面快捷方式<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">[Desktop Entry]</div><div class="line">Encoding=UTF-8</div><div class="line">Version=1.2</div><div class="line">Name[en_US]=TIM</div><div class="line">Name[zh_CN]=腾讯TIM</div><div class="line">Exec=env LC_ALL=zh_CN.utf8 wine /home/h/.wine/drive_c/Program\ Files\ \(x86\)/Tencent/TIM/Bin/TIM.exe</div><div class="line">Icon=/home/h/we/electronic-wechat-linux-x64/photo/TIM.ico</div><div class="line">Terminal=<span class="literal">false</span></div><div class="line">NoDisplay=<span class="literal">false</span></div><div class="line">StartupNotify=<span class="literal">true</span></div><div class="line">Type=Application</div><div class="line">Categories=Network;InstantMessaging;</div></pre></td></tr></table></figure></p>
<h3 id="3-10-安装electronic-wechat"><a href="#3-10-安装electronic-wechat" class="headerlink" title="3.10 安装electronic-wechat"></a>3.10 安装electronic-wechat</h3><p>项目在 <a href="https://github.com/geeeeeeeeek/electronic-wechat" target="_blank" rel="external">github</a> 上 。<br>我使用源码安装失败了,npm总是出错,不知为什么。(如果你使用源码安装成功,请求教)最后使用安装版,见此 <a href="https://github.com/geeeeeeeeek/electronic-wechat/releases" target="_blank" rel="external">https://github.com/geeeeeeeeek/electronic-wechat/releases</a></p>
<p>在桌面上建立图标<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[Desktop Entry]</div><div class="line">Encoding=UTF-8</div><div class="line">Name=微信</div><div class="line">Comment=electronic-wechat</div><div class="line">Exec=/home/h/we/electronic-wechat-linux-x64/electronic-wechat</div><div class="line">Icon=/home/h/we/electronic-wechat-linux-x64/photo/icon.png</div><div class="line">Terminal=<span class="literal">false</span></div><div class="line">StartupNotify=<span class="literal">true</span></div><div class="line">Type=Application</div><div class="line">Categories=Application</div></pre></td></tr></table></figure></p>
<h3 id="3-11-安装最新的python3"><a href="#3-11-安装最新的python3" class="headerlink" title="3.11 安装最新的python3"></a>3.11 安装最新的python3</h3><p>首先下载最新的python版本,这个在python官网上下载<a href="https://www.python.org/downloads/" target="_blank" rel="external">python官网</a></p>
<p>解压 进入其目录<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">./configure</div><div class="line">make</div><div class="line">make install</div></pre></td></tr></table></figure></p>
<p>安装完后检查二进制文件的位置<br><figure class="highlight ruby"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">which python3</div><div class="line">python3 -V <span class="comment">#V是大写的</span></div></pre></td></tr></table></figure></p>
<h3 id="3-12安装最新版本的npm-和-nodejs"><a href="#3-12安装最新版本的npm-和-nodejs" class="headerlink" title="3.12安装最新版本的npm 和 nodejs"></a>3.12安装最新版本的npm 和 nodejs</h3><p>首先安装npm和 nodejs<br><figure class="highlight ruby"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">sudo apt-get install nodejs-legacy</div><div class="line">suao apt-get install npm</div></pre></td></tr></table></figure></p>
<p>ubuntu上安装时npm和nodejs都是低版本。</p>
<ul>
<li><p>升级npm</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo npm install npm -g</div></pre></td></tr></table></figure>
</li>
<li><p>升级node.js</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">sudo npm install -g n</div><div class="line">sudo n stable</div></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="4-gnome3的安装和配置"><a href="#4-gnome3的安装和配置" class="headerlink" title="4.gnome3的安装和配置"></a>4.gnome3的安装和配置</h2><ul>
<li><p>安装gnome</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get install gnome</div></pre></td></tr></table></figure>
</li>
<li><p>arc主题<br>在github上的项目 <a href="https://github.com/horst3180/arc-theme" target="_blank" rel="external">horst3180/arc-theme</a></p>
</li>
<li><p>Papirus图标<br>github上项目<a href="https://github.com/PapirusDevelopmentTeam/papirus-icon-theme" target="_blank" rel="external">PapirusDevelopmentTeam/papirus-icon-theme</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">sudo add-apt-repository ppa:papirus/papirus</div><div class="line">sudo apt-get update</div><div class="line">sudo apt-get install papirus-icon-theme</div></pre></td></tr></table></figure>
</li>
</ul>
]]></content>
<categories>
<category> ubuntu 安装 </category>
</categories>
<tags>
<tag> 教程 </tag>
<tag> ubuntu </tag>
</tags>
</entry>
<entry>
<title><![CDATA[github+hexo 搭建博客]]></title>
<url>/2017/10/15/github-hexo-%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2/</url>
<content type="html"><![CDATA[<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="//music.163.com/outchain/player?type=2&id=439915614&auto=0&height=66"></iframe>
<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p> 本文章讲述如何利用 <a href="https://github.com/" target="_blank" rel="external">github pages</a> 和 <a href="https://hexo.io/" target="_blank" rel="external">hexo</a> 建博客</p>
<a id="more"></a>
<h2 id="准备环境"><a href="#准备环境" class="headerlink" title="准备环境"></a>准备环境</h2><ul>
<li>有一个github账号,没有的话去 github <a href="https://github.com/" target="_blank" rel="external">https://github.com/</a> 注册一个;</li>
<li>安装node.js、npm</li>
<li>安装git</li>
<li>安装hexo</li>
</ul>
<p>本文所使用的环境:</p>
<ul>
<li>ubuntu 16.04</li>
<li>node.js 8.6.0</li>
<li>git 2.7.4</li>
<li>hexo 3.3.9</li>
</ul>
<h1 id="搭建github博客"><a href="#搭建github博客" class="headerlink" title="搭建github博客"></a>搭建github博客</h1><h2 id="创建仓库"><a href="#创建仓库" class="headerlink" title="创建仓库"></a>创建仓库</h2><p>在注册完github帐号后,新建一个名为<code>用户名.github.io</code>的仓库,比如说,如果你的github用户名是test,那么你就新建<code>test.github.io</code>的仓库(必须是你的用户名,其它名称无效),将来你的网站访问地址就是 <a href="http://test.github.io" target="_blank" rel="external">http://test.github.io</a> 。</p>
<p><img src="/photo/注册1.png" alt=""></p>
<p>由此可见,每一个github账户最多只能创建一个这样可以直接使用域名访问的仓库。</p>
<p>几个注意的地方:</p>
<ol>
<li>注册的邮箱一定要验证,否则不会成功;</li>
<li>仓库名字必须是:<code>username.github.io</code>,其中<code>username</code>是你的用户名;</li>
</ol>
<p>创建成功后,默认会在你这个仓库里生成一些示例页面,以后你的网站所有代码都是放在这个仓库里啦。</p>
<h2 id="node-js-amp-amp-npm-安装"><a href="#node-js-amp-amp-npm-安装" class="headerlink" title="node.js&&npm 安装"></a>node.js&&npm 安装</h2><ul>
<li>node官网 <v> <a href="https://nodejs.org/en/" target="_blank" rel="external">https://nodejs.org/en/</a></v></li>
<li>npm官网 <v> <a href="https://www.npmjs.com" target="_blank" rel="external">https://www.npmjs.com</a></v></li>
</ul>
<p>ubuntu下安装</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get install nodejs && npm</div></pre></td></tr></table></figure>
<h2 id="git-安装"><a href="#git-安装" class="headerlink" title="git 安装"></a>git 安装</h2><ul>
<li><p>git官网下载 <v> <a href="https://git-scm.com/downloads/" target="_blank" rel="external">https://git-scm.com/downloads/</a></v></p>
<p>Windows: <v> <a href="https://windows.github.com/" target="_blank" rel="external">https://windows.github.com/</a></v></p>
<p>Mac: <v> <a href="https://mac.github.com" target="_blank" rel="external">https://mac.github.com</a></v></p>
</li>
</ul>
<p>其实ubuntu下直接安装就好:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-get install git</div></pre></td></tr></table></figure>
<h1 id="配置SSH-key"><a href="#配置SSH-key" class="headerlink" title="配置SSH key"></a>配置SSH key</h1><p>为什么要配置这个呢?因为你提交代码肯定要拥有你的github权限才可以,但是直接使用用户名和密码太不安全了,所以我们使用ssh key来解决本地和服务器的连接问题。</p>
<p>用git bash执行如下命令:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> ~/. ssh <span class="comment">#检查本机已存在的ssh密钥</span></div></pre></td></tr></table></figure>
<p>如果提示:No such file or directory 说明你是第一次使用git。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ssh-keygen -t rsa -C <span class="string">"邮件地址"</span></div></pre></td></tr></table></figure>
<p>然后连续3次回车,最终会生成一个文件在用户目录下,打开用户目录,找到<code>.ssh\id_rsa.pub</code>文件,记事本打开并复制里面的内容,打开你的github主页,进入个人设置 -> SSH and GPG keys -> New SSH key:</p>
<p><img src="http://image.liuxianan.com/201608/20160818_143914_495_9084.png" alt=""></p>
<p>将刚复制的内容粘贴到key那里,title随便填,保存。</p>
<h2 id="测试是否成功"><a href="#测试是否成功" class="headerlink" title="测试是否成功"></a>测试是否成功</h2><p> $ ssh -T [email protected] # 注意邮箱地址不改</p>
<p>如果提示<code>Are you sure you want to continue connecting (yes/no)?</code>,输入yes,然后会看到:</p>
<blockquote>
<p>Hi liuxianan! You’ve successfully authenticated, but GitHub does not provide shell access.</p>
</blockquote>
<p>看到这个信息说明SSH已配置成功!</p>
<p>此时你还需要配置:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ git config --global user.name <span class="string">"liuxianan"</span>// 你的github用户名,非昵称</div><div class="line">$ git config --global user.email <span class="string">"[email protected]"</span>// 填写你的github注册邮箱</div></pre></td></tr></table></figure>
<p>配置完之后输入:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ git config --list <span class="comment">#查看已设配置</span></div></pre></td></tr></table></figure>
<p>查看username,email是否正确</p>
<h1 id="使用hexo写博客"><a href="#使用hexo写博客" class="headerlink" title="使用hexo写博客"></a>使用hexo写博客</h1><h2 id="hexo简介"><a href="#hexo简介" class="headerlink" title="hexo简介"></a>hexo简介</h2><p>Hexo是一个简单、快速、强大的基于 Github Pages 的博客发布工具,支持Markdown格式,有众多优秀插件和主题。</p>
<p>官网: <a href="http://hexo.io" target="_blank" rel="external">http://hexo.io</a><br>github: <a href="https://github.com/hexojs/hexo" target="_blank" rel="external">https://github.com/hexojs/hexo</a></p>
<h2 id="原理"><a href="#原理" class="headerlink" title="原理"></a>原理</h2><p>由于github pages存放的都是静态文件,博客存放的不只是文章内容,还有文章列表、分类、标签、翻页等动态内容,假如每次写完一篇文章都要手动更新博文目录和相关链接信息,相信谁都会疯掉,所以hexo所做的就是将这些md文件都放在本地,每次写完文章后调用写好的命令来批量完成相关页面的生成,然后再将有改动的页面提交到github。</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install -g hexo</div></pre></td></tr></table></figure>
<h2 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h2><p>在电脑的某个地方新建一个名为hexo的文件夹(名字可以随便取)<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> ~/hexo/</div><div class="line">$ hexo init <span class="comment">#初始化文件夹</span></div><div class="line">$ npm install <span class="comment">#安装包</span></div></pre></td></tr></table></figure></p>
<p>hexo安装成功后,hexo文件夹目录为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">.</div><div class="line">├── _config.yml // 网站的配置信息,你可以在此配置大部分的参数。</div><div class="line">├── package.json</div><div class="line">├── scaffolds // 模板文件夹。当你新建文章时,Hexo会根据scaffold来建立文件。</div><div class="line">├── source // 存放用户资源的地方</div><div class="line">| ├── _drafts</div><div class="line">| └── _posts</div><div class="line">└── themes // 存放网站的主题。Hexo会根据主题来生成静态页面</div></pre></td></tr></table></figure>
<p>具体内容可见<a href="https://hexo.io/zh-cn/docs/setup.html" target="_blank" rel="external">hexo建站</a></p>
<p>然后输入下面:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ hexo g <span class="comment"># 生成public文件夹(浏览器访问资源)</span></div><div class="line">$ hexo s <span class="comment"># 启动服务</span></div></pre></td></tr></table></figure></p>
<p>执行以上命令之后,hexo就会在public文件夹生成相关html文件,这些文件将来都是要提交到github去的</p>
<p><code>hexo s</code>是开启本地预览服务,打开浏览器访问 <a href="http://localhost:4000" target="_blank" rel="external">http://localhost:4000</a> 即可看到内容,很多人会碰到浏览器一直在转圈但是就是加载不出来的问题,一般情况下是因为端口占用的缘故,因为4000这个端口太常见了,解决端口冲突问题请参考这篇文章:</p>
<p><a href="http://blog.liuxianan.com/windows-port-bind.html" target="_blank" rel="external">http://blog.liuxianan.com/windows-port-bind.html</a></p>
<p>第一次初始化的时候hexo已经帮我们写了一篇名为 Hello World 的文章,默认的主题比较丑,打开时就是这个样子:</p>
<p><img src="/photo/2017.10.15.22.1.png" alt=""></p>
<h2 id="配对ssr"><a href="#配对ssr" class="headerlink" title="配对ssr"></a>配对ssr</h2><p>打开<code>~\Hexo</code> 文件夹中的<code>_config.yml</code>文件,填写内容<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># Deployment</span></div><div class="line"><span class="comment">## Docs: https://hexo.io/docs/deployment.html</span></div><div class="line">deploy:</div><div class="line"> <span class="built_in">type</span>: git</div><div class="line"> repository: [email protected]:WarlockFish/WarlockFish.github.io.git <span class="comment">#填入你的github链接,我填的是我的</span></div><div class="line"> branch: master</div></pre></td></tr></table></figure></p>
<h2 id="修改主题"><a href="#修改主题" class="headerlink" title="修改主题"></a>修改主题</h2><p>默认主题很丑,可以来替换一个好看点的主题。这是 <a href="https://hexo.io/themes/" target="_blank" rel="external">官方主题</a> 链接</p>
<p>我使用的是 <a href="https://github.com/iissnan/hexo-theme-next" target="_blank" rel="external">next</a> .<br>喜欢使用可以安装:<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ git <span class="built_in">clone</span> https://github.com/iissnan/hexo-theme-next themes/next</div></pre></td></tr></table></figure></p>
<p>记住要在hexo目录中执行上面指令。</p>
<p>修改<code>hexo</code>目录中的<code>_config.yml</code>中的<code>theme: landscape</code>改为<code>theme: next</code>,保存退出,<br>然后执行<code>hexo g</code>来重新生成文件。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># Extensions</span></div><div class="line"><span class="comment">## Plugins: https://hexo.io/plugins/</span></div><div class="line"><span class="comment">## Themes: https://hexo.io/themes/</span></div><div class="line">theme: next</div></pre></td></tr></table></figure></p>
<h2 id="写博客"><a href="#写博客" class="headerlink" title="写博客"></a>写博客</h2><p>在<code>hexo</code>下</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">hexo n <span class="string">"name of the new post"</span></div></pre></td></tr></table></figure>
<p>在<code>~/hexo/source/_posts</code>下会生成一份博客,Hexo使用MarkDown写作语法。写完后可以使用<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">hexo g</div><div class="line">hexo s</div></pre></td></tr></table></figure></p>
<p>然后可以在本地访问 <a href="http://localhost:4000" target="_blank" rel="external">http://localhost:4000</a> 查看效果,便于更改</p>
<h2 id="更新Github"><a href="#更新Github" class="headerlink" title="更新Github"></a>更新Github</h2><p>进入目录<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> ./hexo</div><div class="line">$ hexo g <span class="comment">#编译本地内容</span></div><div class="line">$ hexo d <span class="comment">#上传到github上</span></div></pre></td></tr></table></figure></p>
<p>这样就发布成功了,可以在网络上访问了。</p>
<p>谢谢阅读!!</p>
]]></content>
<categories>
<category> github + hexo </category>
</categories>
<tags>
<tag> new </tag>
<tag> github pages </tag>
<tag> hexo </tag>
<tag> 教程 </tag>
<tag> 配置 </tag>
</tags>
</entry>
<entry>
<title><![CDATA[my-first-blog]]></title>
<url>/2017/10/07/my-first-blog/</url>
<content type="html"><![CDATA[<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="//music.163.com/outchain/
player?type=2&id=28138493&auto=0&height=66"></iframe>
<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>使用github pages服务搭建博客的好处有:</p>
<ol>
<li><p>全是静态文件,访问速度快;</p>
</li>
<li><p>免费方便,不用花一分钱就可以搭建一个自由的个人博客,不需要服务器不需要后台;</p>
<a id="more"></a>
</li>
<li><p>可以随意绑定自己的域名,不仔细看的话根本看不出来你的网站是基于github的;</p>
</li>
<li><p>数据绝对安全,基于github的版本管理,想恢复到哪个历史版本都行;</p>
</li>
<li><p>博客内容可以轻松打包、转移、发布到其它平台;</p>
</li>
<li><p>等等;</p>
</li>
</ol>
<p><img src="/photo/train.jpg" alt=""></p>
]]></content>
<categories>
<category> github pages </category>
</categories>
<tags>
<tag> new </tag>
<tag> github pages </tag>
<tag> 静态网站 </tag>
</tags>
</entry>
<entry>
<title><![CDATA[Hello World]]></title>
<url>/2017/10/07/hello-world/</url>
<content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="external">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo new <span class="string">"My New Post"</span></div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy</div></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>
]]></content>
<tags>
<tag> hello world </tag>
</tags>
</entry>
</search>