-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-search.xml
117 lines (54 loc) · 107 KB
/
local-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
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>week3</title>
<link href="/2022/08/13/week3/"/>
<url>/2022/08/13/week3/</url>
<content type="html"><![CDATA[<h1 id="week3"><a href="#week3" class="headerlink" title="week3"></a>week3</h1><p>1.yum私有仓库的实现及博客输出</p><p>2.阅读《图解TCP/IP》一书,地址:<a href="https://leon-wtf.github.io/doc/%E5%9B%BE%E8%A7%A3TCPIP.pdf">https://leon-wtf.github.io/doc/%E5%9B%BE%E8%A7%A3TCPIP.pdf</a>,有时间的可以写下读书笔记</p><p>3.画图 TCP协议和三次握手及四次挥手,可以参考别人的,但是需要自己画一次</p><p>4.静态配置网卡IP,centos/ubuntu实现</p><p>脚本题</p><p>5.实现免密登陆脚本, expect登陆远程主机,将生成的密钥写入到目标主机, expect测试远程登陆。</p><p>1)通过shift读取脚本参数</p><p>2)通过select来选择功能.例如功能有</p><p>- 安装mysql</p><p>- 安装apache</p><p>- 免密钥登陆主机</p><p>当前我们只实现免密钥登陆主机</p><p>3)通过函数封装每个功能</p><p>4)将免密钥登陆的过程可以重复进行, while 循环实现重复,需要有退出过程。当用户输入exit时,退出免密钥功能。</p><p>5)支持输入一批主机免密钥,使用数组 实现</p><h1 id="1-搭建私有的yum仓库"><a href="#1-搭建私有的yum仓库" class="headerlink" title="1.搭建私有的yum仓库"></a>1.搭建私有的yum仓库</h1><p>环境:server端 10.0.0.129</p><p>client端 10.0.0.130</p><p>server端本地yum源:/etc/yum.repos.d/base.repo</p><figure class="highlight bash"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></div></td><td class="code"><pre><code class="hljs bash">[base]<br>name=base<br>baseurl=https://mirrors.aliyun.com/centos/<span class="hljs-variable">$releasever</span>/os/<span class="hljs-variable">$basearch</span>/<br>gpgcheck=1<br>gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-<span class="hljs-variable">$releasever</span><br><br>[epel]<br>name=epel<br>baseurl=https://mirrors.aliyun.com/epel/<span class="hljs-variable">$releasever</span>/<span class="hljs-variable">$basearch</span>/<br>gpgcheck=1<br>gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-<span class="hljs-variable">$releasever</span><br><br>[extras]<br>name=extras<br>baseurl=https://mirrors.aliyun.com/centos/<span class="hljs-variable">$releasever</span>/extras/<span class="hljs-variable">$basearch</span>/<br>gpgcheck=1<br>gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-<span class="hljs-variable">$releasever</span><br><br>[updates]<br>name=updates<br>baseurl=https://mirrors.aliyun.com/centos/<span class="hljs-variable">$releasever</span>/updates/<span class="hljs-variable">$basearch</span>/<br>gpgcheck=1<br>gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-<span class="hljs-variable">$releasever</span><br></code></pre></td></tr></table></figure><h2 id="安装nginx,添加yum源的web端发布"><a href="#安装nginx,添加yum源的web端发布" class="headerlink" title="安装nginx,添加yum源的web端发布"></a>安装nginx,添加yum源的web端发布</h2><p>添加base,epel,extras,appstream源的发布</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">##安装nginx编译依赖包gcc,支持ssl,zlib压缩等</span><br>yum install -y pcre pcre-devel gcc gcc-c++ openssl openssl-devel zlib zlib-devel gd gd-devel<br>wget -O https://nginx.org/download/nginx-1.20.2.tar.gz /data/nginx<br>tar xf nginx-1.20.2.tar.gz<br><br><span class="hljs-comment">##指定nginx安装目录 --prefix</span><br><span class="hljs-built_in">cd</span> nginx-1.20.2 ; ./configure --perfix=/usr/local/nginx<br>make && make install<br><br>nginx默认目录:/usr/local/nginx/html<br></code></pre></td></tr></table></figure><h3 id="1-配置nginx服务器"><a href="#1-配置nginx服务器" class="headerlink" title="1.配置nginx服务器"></a>1.配置nginx服务器</h3><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs nginx"><span class="hljs-comment">##进入到nginx</span><br><span class="hljs-attribute">vim</span> /usr/local/nginx/conf/nginx.conf<br><br><span class="hljs-comment">##监听端口为8080</span><br>server {<br> <span class="hljs-attribute">listen</span> <span class="hljs-number">8080</span>;<br> <span class="hljs-attribute">server_name</span> localhost;<br><br> <span class="hljs-comment">#charset koi8-r;</span><br><br> <span class="hljs-comment">#access_log logs/host.access.log main;</span><br><br><span class="hljs-comment"># location / {</span><br><span class="hljs-comment"># root /repo ;</span><br><span class="hljs-comment"># index index.html index.htm;</span><br><span class="hljs-comment"># }</span><br> <br> <span class="hljs-comment">#8080的server默认访问路径</span><br> <span class="hljs-attribute">root</span> /usr/local/nginx/html/repo;<br> <span class="hljs-attribute">autoindex</span> <span class="hljs-literal">on</span>;<br><br> <span class="hljs-comment">#error_page 404 /404.html;</span><br><br> <span class="hljs-comment"># redirect server error pages to the static page /50x.html</span><br> <span class="hljs-comment">#</span><br> <span class="hljs-attribute">error_page</span> <span class="hljs-number">500</span> <span class="hljs-number">502</span> <span class="hljs-number">503</span> <span class="hljs-number">504</span> /50x.html;<br> <span class="hljs-section">location</span> = /50x.html {<br> <span class="hljs-attribute">root</span> html;<br> }<br><br><span class="hljs-comment">##重启服务</span><br>./<span class="hljs-attribute">nginx</span> -s reload<br></code></pre></td></tr></table></figure><h3 id="2-访问站点查看是否生效:10-0-0-129-8080"><a href="#2-访问站点查看是否生效:10-0-0-129-8080" class="headerlink" title="2.访问站点查看是否生效:10.0.0.129:8080"></a>2.访问站点查看是否生效:10.0.0.129:8080</h3><p><img src="image-20220813113330186-1660365232968.png" alt="image-20220813113330186"></p><h2 id="在server端搭建yum源"><a href="#在server端搭建yum源" class="headerlink" title="在server端搭建yum源"></a>在server端搭建yum源</h2><h3 id="1-同步本地的yum源packages到repo目录"><a href="#1-同步本地的yum源packages到repo目录" class="headerlink" title="1.同步本地的yum源packages到repo目录"></a>1.同步本地的yum源packages到repo目录</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">##reposync:yum源同步工具,同步到对应的nginx发布中,同步现有的base源内的内容</span><br><span class="hljs-comment">##repo指的是同步本地的yum源到这个发布目录</span><br>reposync -r base -p /usr/local/nginx/html/repo<br></code></pre></td></tr></table></figure><p><img src="image-20220813082226420-1660365232965.png" alt="image-20220813082226420"></p><h3 id="2-创建源数据"><a href="#2-创建源数据" class="headerlink" title="2.创建源数据"></a>2.创建源数据</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">##创建源数据,这个路径以后就放repo文件的</span><br>[10:55:20 root@slave1 repo]<span class="hljs-comment">#createrepo /usr/local/nginx/html/repo/base</span><br>Spawning worker 0 with 10072 pkgs<br>Workers Finished<br>Saving Primary metadata<br>Saving file lists metadata<br>Saving other metadata<br>Generating sqlite DBs<br>Sqlite DBs complete<br></code></pre></td></tr></table></figure><p><img src="image-20220813105749148-1660365232968.png" alt="image-20220813105749148"></p><h3 id="3-制作yum源文件"><a href="#3-制作yum源文件" class="headerlink" title="3.制作yum源文件"></a>3.制作yum源文件</h3><p>这里制作yum源文件的时候,由于只有一个base.repo,所以包括base库,extras库,updates库,epel库都写在一起,用于给其他的client获取,地址写本机的IP地址10.0.0.129</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">##制作repo文件</span><br>vim /usr/local/nginx/html/repo/base.repo<br><br><span class="hljs-comment"># 不需要的仓库可以注释掉</span><br><span class="hljs-comment"># 内网仓库全部关闭gpgcheck校验</span><br><span class="hljs-comment"># 实现base仓库</span><br><span class="hljs-comment"># base仓库</span><br>[base]<br>name=Local CentOS-7 Base<br>baseurl=http://10.0.0.129/base<br>enabled=1<br>gpgcheck=0<br><br><span class="hljs-comment"># extras仓库</span><br>[extras]<br>name=Local CentOS-7 Extras<br>baseurl=http://10.0.0.129/base<br>enabled=1<br>gpgcheck=0<br><br><span class="hljs-comment"># updates仓库</span><br>[updates]<br>name=Local CentOS-7 Updates<br>baseurl=http://10.0.0.129/base<br>enabled=1<br>gpgcheck=0<br><br><span class="hljs-comment"># epel仓库</span><br>[epel]<br>name=Local Extra Packages <span class="hljs-keyword">for</span> Enterprise Linux 7<br>baseurl=http://10.0.0.129/base<br>enabled=1<br>gpgcheck=0<br><br></code></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">#查看本地的yum仓库情况</span><br>yum repolist<br></code></pre></td></tr></table></figure><h2 id="client测试yum仓库"><a href="#client测试yum仓库" class="headerlink" title="client测试yum仓库"></a>client测试yum仓库</h2><p>yum源文件必须放在/etc/yum.repos.d才生效,记得加上10.0.0.129:8080端口</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">##备份yum源</span><br><span class="hljs-built_in">mkdir</span> /etc/yum.repos.d/backup<br><span class="hljs-built_in">mv</span> /etc/yum.repos.d/* backup<br><br><span class="hljs-comment">##从server端获取yum源,curl -o指定目标路径</span><br>curl -o /etc/yum.repos.d/base.repo http://10.0.0.129:8080/base.repo<br><br><span class="hljs-comment">##构建缓存,查看yum仓库</span><br>yum clean all ; yum makecache ; yum repolist<br></code></pre></td></tr></table></figure><p><img src="image-20220813114310972-1660365232968.png" alt="image-20220813114310972"></p><p>查看bind-utils有无,测试,证明yum源搭建成功</p><p><img src="image-20220813114432789-1660365232968.png" alt="image-20220813114432789"></p><h1 id="2-阅读《图解TCP-IP》一书"><a href="#2-阅读《图解TCP-IP》一书" class="headerlink" title="2.阅读《图解TCP/IP》一书"></a>2.阅读《图解TCP/IP》一书</h1><p>地址:<a href="https://leon-wtf.github.io/doc/%E5%9B%BE%E8%A7%A3TCPIP.pdf">https://leon-wtf.github.io/doc/%E5%9B%BE%E8%A7%A3TCPIP.pdf</a>,有时间的可以写下读书笔记</p><h1 id="3-TCP三次挥手-四次挥手"><a href="#3-TCP三次挥手-四次挥手" class="headerlink" title="3.TCP三次挥手/四次挥手"></a>3.TCP三次挥手/四次挥手</h1><p><img src="TCP%E5%9B%9B%E6%AC%A1%E6%8C%A5%E6%89%8B-1660365232968.jpg" alt="TCP四次挥手"></p><p><img src="TCP%E4%B8%89%E6%AC%A1%E6%8C%A5%E6%89%8B-1660365232969.jpg" alt="TCP三次挥手"></p><h1 id="4-静态配置网卡IP,centos-ubuntu实现"><a href="#4-静态配置网卡IP,centos-ubuntu实现" class="headerlink" title="4.静态配置网卡IP,centos/ubuntu实现"></a>4.静态配置网卡IP,centos/ubuntu实现</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">##centos7,8</span><br>vim /etc/sysconfig/network-scripts/ifcfg-ens33<br>BOOTPROTO=<span class="hljs-string">"static"</span><br>IPADDR=10.0.0.128<br>PREFIX=24<br>GATEWAY=10.0.0.2<br>DNS1=114.114.114.114<br>DNS2=8.8.8.8<br>centos7:systemctl restart network<br>centos8:nmcli connection down ens160 && nmcli connection up ens160<br><br><span class="hljs-comment">##ubuntu</span><br><span class="hljs-comment">##已提前改过名字</span><br>vim /etc/netplan/ifcfg-ens33.yaml<br><span class="hljs-comment"># This is the network config written by 'subiquity'</span><br>network:<br> ethernets:<br> ens33:<br> addresses: [10.0.0.131/24]<br> gateway4: 10.0.0.2<br> nameservers:<br> addresses: [114.114.114.114,8.8.8.8]<br> dhcp4: no<br> version: 2<br></code></pre></td></tr></table></figure><h1 id="5-实现脚本功能"><a href="#5-实现脚本功能" class="headerlink" title="5.实现脚本功能"></a>5.实现脚本功能</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-meta">#!/bin/bash</span><br><span class="hljs-comment">########################################</span><br><span class="hljs-comment">#Author:Catyer</span><br><span class="hljs-comment">#time:2022-08-07_14:53:44</span><br><span class="hljs-comment">#filename:scp.sh</span><br><span class="hljs-comment">#Script description:</span><br><span class="hljs-comment">#实现免密登陆脚本, expect登陆远程主机,将生成的密钥写入到目标主机, expect测试远程登陆。</span><br><span class="hljs-comment">#1)通过shift读取脚本参数</span><br><span class="hljs-comment">#2)通过select来选择功能.例如功能有</span><br><span class="hljs-comment">#- 安装mysql</span><br><span class="hljs-comment">#- 安装apache</span><br><span class="hljs-comment">#- 免密钥登陆主机</span><br><span class="hljs-comment">#当前我们只实现免密钥登陆主机</span><br><span class="hljs-comment">#3)通过函数封装每个功能</span><br><span class="hljs-comment">#4)将免密钥登陆的过程可以重复进行, while 循环实现重复,需要有退出过程。当用户输入exit时,退出免密钥功能。</span><br><span class="hljs-comment">#5)支持输入一批主机免密钥,使用数组 实现</span><br><span class="hljs-comment">########################################</span><br><br><span class="hljs-comment">##引用function功能</span><br>. /etc/init.d/functions<br> <br><br><span class="hljs-function"><span class="hljs-title">MYSQL</span></span>(){<br><span class="hljs-comment">##二进制安装mysql</span><br><span class="hljs-built_in">echo</span> <span class="hljs-string">"MYSQL"</span><br>}<br><br><br><span class="hljs-function"><span class="hljs-title">APACHE</span></span>(){<br><br>OS=`awk -F= <span class="hljs-string">'/ID/{print $2}'</span> /etc/os-release | <span class="hljs-built_in">head</span> -n 1 | sed <span class="hljs-string">'s/\"//g'</span>`<br><span class="hljs-comment">##yum安装Apache</span><br><span class="hljs-keyword">if</span> [ <span class="hljs-variable">$OS</span> == <span class="hljs-string">"centos"</span> ] ;<span class="hljs-keyword">then</span><br> rpm -q httpd && <span class="hljs-built_in">echo</span> <span class="hljs-string">"apache install"</span> || yum -y install httpd;systemctl <span class="hljs-built_in">enable</span> --now httpd<br> <span class="hljs-keyword">elif</span> [ <span class="hljs-variable">$OS</span> == <span class="hljs-string">"ubuntu"</span> ] ;<span class="hljs-keyword">then</span><br> <span class="hljs-comment">##ubuntu自动启动服务</span><br> apt list --installed | grep httpd && <span class="hljs-built_in">echo</span> <span class="hljs-string">"ubuntu httpd is installed"</span> || apt update; apt -y install httpd <br> <span class="hljs-keyword">else</span><br> <span class="hljs-built_in">echo</span> <span class="hljs-string">"invalid <span class="hljs-variable">$OS</span>"</span> <br> <span class="hljs-keyword">fi</span><br> <span class="hljs-built_in">echo</span> <span class="hljs-string">"httpd test"</span> > /var/www/html/index.html<br> curl 127.0.0.1:80<br>}<br><br><span class="hljs-comment">##使用SSHPASS功能</span><br><span class="hljs-comment">#SSHPASS(){</span><br><span class="hljs-comment">#</span><br><span class="hljs-comment">#pass1=123</span><br><span class="hljs-comment">#IP=(10.0.0.129</span><br><span class="hljs-comment">#10.0.0.130</span><br><span class="hljs-comment">#10.0.0.131</span><br><span class="hljs-comment">#10.0.0.132)</span><br><span class="hljs-comment">#</span><br><span class="hljs-comment">#echo "目标主机:${IP[*]}"</span><br><span class="hljs-comment">#</span><br><span class="hljs-comment">#cd /root && rm -rf .ssh</span><br><span class="hljs-comment">###生成自己的密钥,-p ""空密码,-f路径</span><br><span class="hljs-comment">#ssh-keygen -P "" -f /root/.ssh/id_rsa &>/dev/null</span><br><span class="hljs-comment">###判断sshpass是否安装</span><br><span class="hljs-comment">#rpm -q sshpass && echo "sshpass already install" || yum update;yum -y install sshpass</span><br><span class="hljs-comment">#for i in ${IP[*]};do</span><br><span class="hljs-comment"># sshpass -p $pass1 ssh-copy-id -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa.pub $i</span><br><span class="hljs-comment">#ssh $i "echo `hostname -I`" && echo "$i ssh-keygen执行成功" || echo "failed"</span><br><span class="hljs-comment">#done</span><br><span class="hljs-comment">#</span><br><span class="hljs-comment">#}</span><br><br><span class="hljs-function"><span class="hljs-title">EXPECT</span></span>(){<br><br>host=(<br>10.0.0.129<br>10.0.0.130<br>10.0.0.131<br>10.0.0.132<br>)<br><br>pass1=123<br><br><span class="hljs-comment">##本机删除掉SSH秘钥</span><br><span class="hljs-built_in">cd</span> /root ; <span class="hljs-built_in">rm</span> -rf .ssh<br>ssh-keygen -P <span class="hljs-string">""</span> -f /root/.ssh/id_rsa &>/dev/null<br><br><span class="hljs-comment">##定义x的值</span><br>x=0<br><br><span class="hljs-comment">##x值小于等于数组长度,执行循环,包括数组最大长度</span><br><span class="hljs-keyword">while</span> [ <span class="hljs-variable">$x</span> -le <span class="hljs-variable">${#host[*]}</span> ] ; <span class="hljs-keyword">do</span><br>i=<span class="hljs-variable">${host[$x]}</span> <span class="hljs-comment">##数组对应下标元素(IP)赋值给i变量</span><br><br><span class="hljs-built_in">cat</span> << <span class="hljs-string">EOF</span><br><span class="hljs-string">EXPECT选项</span><br><span class="hljs-string">1.expect:执行免秘钥</span><br><span class="hljs-string">2.exit:退出</span><br><span class="hljs-string">EOF</span><br><br><span class="hljs-built_in">read</span> -p <span class="hljs-string">"please input your choice:"</span> choice<br><span class="hljs-keyword">case</span> <span class="hljs-variable">$choice</span> <span class="hljs-keyword">in</span><br>1|<span class="hljs-string">"expect"</span>)<br><br><span class="hljs-comment">##再次判断一次x的值,如果小于数组长度,则退出;不包括数组最大长度,当x达到数组最大长度,则不执行以下循环,退出</span><br><span class="hljs-keyword">if</span> [ <span class="hljs-variable">$x</span> -lt <span class="hljs-variable">${#host[*]}</span> ];<span class="hljs-keyword">then</span><br><span class="hljs-built_in">let</span> x++ <br>expect <<<span class="hljs-string">EOF</span><br><span class="hljs-string">spawn ssh-copy-id root@$i</span><br><span class="hljs-string">expect {</span><br><span class="hljs-string">"yes/no" {send "yes\n";exp_continue}</span><br><span class="hljs-string">"password" {send "$pass1\n"}</span><br><span class="hljs-string">}</span><br><span class="hljs-string">expect eof</span><br><span class="hljs-string">EOF</span><br><span class="hljs-comment">##调用action</span><br>action <span class="hljs-string">"主机<span class="hljs-variable">$i</span> SSH成功"</span> <span class="hljs-literal">true</span><br><br><span class="hljs-keyword">else</span><br><span class="hljs-built_in">echo</span> <span class="hljs-string">"已经达到数组最大长度,退出"</span><br><span class="hljs-built_in">break</span><br><span class="hljs-keyword">fi</span><br><br><span class="hljs-comment">#let x++</span><br>;;<br><br>2|<span class="hljs-string">"exit"</span>) <span class="hljs-built_in">break</span> ;; <span class="hljs-comment">##退出函数,可以在两次expect之间退出</span><br><br><span class="hljs-keyword">esac</span><br><span class="hljs-keyword">done</span><br><br>}<br><br><br><span class="hljs-keyword">while</span> :<br><span class="hljs-keyword">do</span><br><span class="hljs-built_in">echo</span> <span class="hljs-string">"输入想要实现的功能:"</span><br>select order <span class="hljs-keyword">in</span> 安装MySQL 安装apache EXPECT测试 EXIT退出;<span class="hljs-keyword">do</span><br><span class="hljs-keyword">case</span> <span class="hljs-variable">$REPLY</span> <span class="hljs-keyword">in</span><br> 1) MYSQL ;;<br> 2) APACHE ;;<br> 3) EXPECT ;;<br> 4) <span class="hljs-built_in">exit</span> 2 ;; <span class="hljs-comment">##退出两层循环</span><br> <span class="hljs-keyword">esac</span><br><span class="hljs-keyword">done</span><br><span class="hljs-keyword">done</span><br><br><br></code></pre></td></tr></table></figure><h2 id="实现效果"><a href="#实现效果" class="headerlink" title="实现效果"></a>实现效果</h2><h2 id="主界面"><a href="#主界面" class="headerlink" title="主界面"></a>主界面</h2><p><img src="image-20220813122734744.png" alt="image-20220813122734744"></p><h2 id="执行安装Apache-已安装"><a href="#执行安装Apache-已安装" class="headerlink" title="执行安装Apache(已安装)"></a>执行安装Apache(已安装)</h2><p><img src="image-20220813122822678.png" alt="image-20220813122822678"></p><h2 id="执行安装-Apache-未安装"><a href="#执行安装-Apache-未安装" class="headerlink" title="执行安装 Apache(未安装)"></a>执行安装 Apache(未安装)</h2><p><img src="image-20220813122942630.png" alt="image-20220813122942630"></p><p><img src="image-20220813122954319.png" alt="image-20220813122954319"></p><h2 id="执行第一次expect"><a href="#执行第一次expect" class="headerlink" title="执行第一次expect"></a>执行第一次expect</h2><p><img src="image-20220813123029478.png" alt="image-20220813123029478"></p><p>测试scp文件是否能够免秘钥传输到10.0.0.129</p><p><img src="image-20220813123138302.png" alt="image-20220813123138302"></p><h2 id="执行第二次expect"><a href="#执行第二次expect" class="headerlink" title="执行第二次expect"></a>执行第二次expect</h2><p><img src="image-20220813123213314.png" alt="image-20220813123213314"></p><h2 id="达到数据长度上限,退出脚本"><a href="#达到数据长度上限,退出脚本" class="headerlink" title="达到数据长度上限,退出脚本"></a>达到数据长度上限,退出脚本</h2><p><img src="image-20220813123305069.png" alt="image-20220813123305069"></p>]]></content>
</entry>
<entry>
<title>Hello World</title>
<link href="/2022/08/13/hello-world/"/>
<url>/2022/08/13/hello-world/</url>
<content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">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">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">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"><div class="code-wrapper"><pre><span class="line">1</span><br></pre></div></td><td class="code"><pre><code class="hljs bash">$ hexo new <span class="hljs-string">"My New Post"</span><br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/writing.html">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><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo server<br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/server.html">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><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo generate<br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/generating.html">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><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo deploy<br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a><br>1111</p>]]></content>
</entry>
<entry>
<title>week_2</title>
<link href="/2022/08/07/week-2/"/>
<url>/2022/08/07/week-2/</url>
<content type="html"><![CDATA[<h1 id="week2"><a href="#week2" class="headerlink" title="week2"></a>week2</h1><ol><li>运行脚本可以显示出本机的ip地址</li><li>如果ip地址中有3这个数字,那么就打印出当前的系统时间</li><li>如果ip地址中不含3这个数字,就批量建立用户magedu_00, magedu_01, … magedu_100并且所有用户同属于magedu组</li><li>打印出/etc/passwd这个文件中可以登陆的用户(非/usr/sbin/nologin)</li><li>yum安装nginx服务,并且启动该服务</li><li>一个脚本完成</li></ol><figure class="highlight bash"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></div></td><td class="code"><pre><code class="hljs bash"><span class="hljs-meta">#!/bin/bash</span><br><span class="hljs-comment">########################################</span><br><span class="hljs-comment">#Author:Catyer</span><br><span class="hljs-comment">#time:2022-08-02_20:56:32</span><br><span class="hljs-comment">#filename:1.sh</span><br><span class="hljs-comment">#Script description:</span><br><span class="hljs-comment">########################################</span><br><br><span class="hljs-comment">##适应不同的机器网卡名</span><br>DATE=`<span class="hljs-built_in">date</span>`<br>IP=`hostname -I | awk <span class="hljs-string">'{print $1}'</span>`<br>OS=`awk -F= <span class="hljs-string">'/ID/{print $2}'</span> /etc/os-release | <span class="hljs-built_in">head</span> -n 1 | sed <span class="hljs-string">'s/\"//g'</span>` <br><span class="hljs-comment">#pass=`cat /dev/urandom | tr -dc [:alnum:] | head -c 8`</span><br><br><span class="hljs-function"><span class="hljs-title">IP</span></span>(){<br><span class="hljs-comment">#local IP=`ifconfig eth0 | awk /netmask/'{print $2}'`</span><br><span class="hljs-built_in">echo</span> <span class="hljs-string">"本机IP:<span class="hljs-variable">$IP</span>"</span><br>}<br><br><span class="hljs-function"><span class="hljs-title">IPCHECK</span></span>(){<br><span class="hljs-comment">#DATE=`date`</span><br><span class="hljs-built_in">echo</span> <span class="hljs-variable">$IP</span><br><br><span class="hljs-comment">#IPcheck=`ifconfig eth0 | awk /netmask/'{print $2}' | grep 3`</span><br>hostname -I | awk <span class="hljs-string">'{print $1}'</span> | grep 3 &> /dev/null<br><span class="hljs-keyword">if</span> [ $? -eq 0 ] ;<span class="hljs-keyword">then</span><br><span class="hljs-built_in">echo</span> <span class="hljs-string">"<span class="hljs-variable">$DATE</span>"</span><br><span class="hljs-keyword">else</span><br>[ <span class="hljs-string">"grep magedu /etc/group"</span> ] && <span class="hljs-built_in">echo</span> <span class="hljs-string">"group exist"</span> || groupadd madedu<br><span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> {1..20};<span class="hljs-keyword">do</span><br><span class="hljs-built_in">local</span> pass=`<span class="hljs-built_in">cat</span> /dev/urandom | <span class="hljs-built_in">tr</span> -dc [:alnum:] | <span class="hljs-built_in">head</span> -c 8`<br><span class="hljs-keyword">if</span> [ <span class="hljs-variable">$i</span> -lt 10 ];<span class="hljs-keyword">then</span><br>useradd magedu_0<span class="hljs-variable">$i</span> -g magedu<br><span class="hljs-built_in">echo</span> <span class="hljs-variable">$pass</span> | passwd --stdin magedu_0<span class="hljs-variable">$i</span> &> /dev/null ;<span class="hljs-built_in">echo</span> <span class="hljs-string">"magedu_0<span class="hljs-variable">$i</span> create"</span> <br><span class="hljs-built_in">echo</span> <span class="hljs-string">"username:magedu_0<span class="hljs-variable">$i</span> passwd:<span class="hljs-variable">$pass</span>"</span> >> /script/homework/pass.txt<br><span class="hljs-keyword">else</span><br>useradd magedu_<span class="hljs-variable">$i</span> -g magedu<br><span class="hljs-built_in">echo</span> <span class="hljs-variable">$pass</span> | passwd --stdin magedu_<span class="hljs-variable">$i</span> &> /dev/null ;<span class="hljs-built_in">echo</span> <span class="hljs-string">"magedu_<span class="hljs-variable">$i</span> create"</span> <br><span class="hljs-built_in">echo</span> <span class="hljs-string">"username:magedu_<span class="hljs-variable">$i</span> passwd:<span class="hljs-variable">$pass</span>"</span> >> /script/homework/pass.txt<br><span class="hljs-keyword">fi</span><br><span class="hljs-keyword">done</span><br><span class="hljs-keyword">fi</span><br><span class="hljs-built_in">cat</span> /script/homework/pass.txt<br>}<br><br><span class="hljs-function"><span class="hljs-title">USER</span></span>(){<br>grep -v <span class="hljs-string">"/sbin/nologin"</span> /etc/passwd | awk -F: <span class="hljs-string">'{print $1}'</span><br>}<br><br><span class="hljs-function"><span class="hljs-title">NGINX</span></span>(){<br><span class="hljs-keyword">if</span> [ <span class="hljs-variable">$OS</span> == <span class="hljs-string">"centos"</span> ] ;<span class="hljs-keyword">then</span><br>rpm -q nginx && <span class="hljs-built_in">echo</span> <span class="hljs-string">"nginx install"</span> || yum -y install nginx;systemctl <span class="hljs-built_in">enable</span> --now nginx<br><span class="hljs-keyword">elif</span> [ <span class="hljs-variable">$OS</span> == <span class="hljs-string">"ubuntu"</span> ] ;<span class="hljs-keyword">then</span><br><span class="hljs-comment">##ubuntu自动启动服务</span><br>apt list --installed | grep nginx && <span class="hljs-built_in">echo</span> <span class="hljs-string">"ubuntu nginx is installed"</span> || apt update; apt -y install nginx <br> <span class="hljs-keyword">else</span><br> <span class="hljs-built_in">echo</span> <span class="hljs-string">"invalid <span class="hljs-variable">$OS</span>"</span> <br><span class="hljs-keyword">fi</span><br> <span class="hljs-built_in">echo</span> <span class="hljs-string">"nginx test"</span> > /usr/share/nginx/html/index.html<br>systemctl <span class="hljs-built_in">enable</span> --now nginx<br>curl <span class="hljs-variable">$IP</span><br>}<br><br><br><span class="hljs-keyword">while</span> :<br><span class="hljs-keyword">do</span><br><span class="hljs-built_in">cat</span> <<<span class="hljs-string">EOF</span><br><span class="hljs-string">========================我是分隔符========================</span><br><span class="hljs-string"> week 2 homework</span><br><span class="hljs-string">1.输出本机IP地址</span><br><span class="hljs-string">2.判断IP地址是否含有3(打印系统时间/创建用户)</span><br><span class="hljs-string">3.打印出/etc/passwd可以登陆的用户(非/usr/sbin/nologin)</span><br><span class="hljs-string">4.安装nginx服务,并且启动该服务(centos/ubuntu)</span><br><span class="hljs-string">5.exit</span><br><span class="hljs-string">========================我是分隔符========================</span><br><span class="hljs-string"></span><br><span class="hljs-string">EOF</span><br><span class="hljs-built_in">read</span> -p <span class="hljs-string">"please input your num: "</span> num <span class="hljs-comment">##这里注意不要写成$num变量</span><br><span class="hljs-keyword">case</span> <span class="hljs-variable">$num</span> <span class="hljs-keyword">in</span><br>1) IP;;<br>2) IPCHECK;;<br>3) USER;;<br>4) NGINX;;<br>5|e|E|<span class="hljs-built_in">exit</span>|Exit) <span class="hljs-built_in">break</span> ;;<br>*) <span class="hljs-built_in">echo</span> <span class="hljs-string">"error input"</span><br><span class="hljs-keyword">esac</span><br><span class="hljs-keyword">done</span><br><br><br></code></pre></td></tr></table></figure><h1 id="实现效果"><a href="#实现效果" class="headerlink" title="实现效果"></a>实现效果</h1><h2 id="1-运行界面"><a href="#1-运行界面" class="headerlink" title="1.运行界面"></a>1.运行界面</h2><p><img src="image-20220807144527883.png" alt="image-20220807144527883"></p><h2 id="2-输出IP地址"><a href="#2-输出IP地址" class="headerlink" title="2.输出IP地址"></a>2.输出IP地址</h2><p><img src="image-20220807144550302.png" alt="image-20220807144550302"></p><h2 id="3-判断是否有3,否则创建用户"><a href="#3-判断是否有3,否则创建用户" class="headerlink" title="3.判断是否有3,否则创建用户"></a>3.判断是否有3,否则创建用户</h2><p><img src="image-20220807144846107.png" alt="image-20220807144846107"></p><h2 id="创建随机密码"><a href="#创建随机密码" class="headerlink" title="创建随机密码"></a>创建随机密码</h2><p><img src="image-20220807144905901.png" alt="image-20220807144905901"></p><h2 id="4-输出nologin用户"><a href="#4-输出nologin用户" class="headerlink" title="4.输出nologin用户"></a>4.输出nologin用户</h2><p><img src="image-20220807144923382.png" alt="image-20220807144923382"></p><h2 id="5-安装nginx"><a href="#5-安装nginx" class="headerlink" title="5.安装nginx"></a>5.安装nginx</h2><p><img src="image-20220807145254152.png" alt="image-20220807145254152"></p><p>nginx测试页:nginx test</p>]]></content>
</entry>
<entry>
<title>week 1</title>
<link href="/2022/07/31/week_1/"/>
<url>/2022/07/31/week_1/</url>
<content type="html"><![CDATA[<h1 id="week-1"><a href="#week-1" class="headerlink" title="week 1"></a>week 1</h1><figure class="highlight markdown"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></div></td><td class="code"><pre><code class="hljs markdown"><span class="hljs-bullet">1.</span> 图文并茂解释开源许可证 GPL、BSD、MIT、Mozilla、Apache和LGPL的区别?<br><span class="hljs-bullet">2.</span> 安装各发行版系统的安装(centos, rockylinux, ubuntu, 等)<br><span class="hljs-bullet">3.</span> Linux中总结,1)如何通过一个简短的关键字,例如process 获取相关的命令。2)通过命令的描述,选择一个命令,获取命令的man文档。3)解读man文档,man分几个部分?man每个部分的解释,特别是语法部分。<>, [] ...等各代表什么含义。4)根据语法部分 简要的写几个操作。<br><span class="hljs-bullet">4.</span> 切换到/etc/目录,列出fstab文件的详细信息,详细解决fstab一行,每个或每几个字符的详细含义。<br><span class="hljs-bullet">5.</span> 简要说明FHS结构。<br><span class="hljs-bullet">6.</span> 用自己的理解总结 文件管理,用户管理,组用户,权限管理相关的命令。<br></code></pre></td></tr></table></figure><h2 id="1-图文并茂解释开源许可证-GPL、BSD、MIT、Mozilla、Apache和LGPL的区别?"><a href="#1-图文并茂解释开源许可证-GPL、BSD、MIT、Mozilla、Apache和LGPL的区别?" class="headerlink" title="1.图文并茂解释开源许可证 GPL、BSD、MIT、Mozilla、Apache和LGPL的区别?"></a>1.图文并茂解释开源许可证 GPL、BSD、MIT、Mozilla、Apache和LGPL的区别?</h2><p><img src="C:\Users\11194\AppData\Roaming\Typora\typora-user-images\image-20220731203307888.png" alt="image-20220731203307888"></p><p>较流行的两种许可证:MIT和apache</p><p>GPL:GPL软件的使用者有权力得到软件的代码,只要使用了GPL,在发布(redistribution)时,整个项目也必须是GPL的,即主程序和静态链接的库(linux的.a和Windows的.lib)必须是GPL的,动态链接库(Linux的.so,Windows的.dll)必须是GPL兼容的。</p><p>BSD、apache 2.0:相对GPL/LGPL的开放源代码,BSD,Apache 2.0就宽松许多——商业软件可以任意的使用BSD,Apache 2.0发布的软件代码,而不需要开放源代码,只需要提及代码的原出处就可以了。BSD和Apache 2.0提及的方式稍有不同,具体可以参考协议的详细内容。它们是GPL兼容的</p><p>LGPL:LGPL定义为,在以LGPL发布的库的基础上开发新的库的时候,新的库必须以LGPL发布,但是如果仅仅是动态链接,那么则不受任何限制。这样商业软件就可以随意的使用LGPL的库了。因此,LGPL也具有传染性,但限制在其基础上开发的库上,而并不限制使用它的程序本身——它的传染性远小于GPL。</p><p>MIT:特此免费授予任何获得本软件副本和相关文档文件(下称“软件”)的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、转授许可和/或出售该软件副本,以及再授权被配发了本软件的人如上的权利</p><p>Mozilla:Mozilla公共许可证(英语:Mozilla Public License,简称MPL)是个自由、开源、详细的软件许可证,由Mozilla基金会开发并维护。该协议融合了BSD许可证和GNU通用公共许可协议的特性,追求平衡专有软件和开源软件开发者之间的顾虑。</p><p>Apache许可证:Apache 2.0许可证是ASF(Apache Software Foundation,Apache软件基金会)在2004年发布的,以帮助ASF实现其目标:“通过开源软件开发协作,提供可靠且长久不衰的软件产品”。ASF出品的软件一般都采用Apache 2.0许可证。当然,非ASF的项目也可以使用,Apache许可证设计出来是供所有人使用的。</p><h2 id="2-安装各发行版系统的安装-centos-rockylinux-ubuntu-等"><a href="#2-安装各发行版系统的安装-centos-rockylinux-ubuntu-等" class="headerlink" title="2.安装各发行版系统的安装(centos, rockylinux, ubuntu, 等)"></a>2.安装各发行版系统的安装(centos, rockylinux, ubuntu, 等)</h2><p>Cent OS 7:是一个企业级别的Linux发行版,生产中最为常见的版本,发布于2014年。</p><p>内核版本:Linux master 3.10.0-957.el7.x86_64,发行版本:CentOS Linux release 7.6.1810 (Core)</p><p>rockylinux:Rocky Linux是CentOS的一个分支,它位于Red Hat Enterprise Linux或RHEL的下游。与CentOS一样,它提供了一个稳定的Linux版本,非常适合服务器。已经可以成为Cent OS 8版本及以上的替代品</p><p>内核版本:Linux rocky 4.18.0-372.9.1.el8.x86_64,发行版本:Rocky Linux release 8.6 (Green Obsidian)</p><p>ubuntu:基于Debian的发行版,已经成为常见的Linux服务器版本。Ubuntu 是各种公有云上最受欢迎的操作系统,这是因为 Ubuntu 与各⼤云运营商密切合作,针对云服务商的基础架构优化内核和系统,加快安全更新速度,并最⼤限度降低⽤⼾默认需要的⽹络或存储成本。</p><p>内核版本:Linux ubuntu 5.4.0-113-generic,发行版本:Ubuntu 20.04.4 LTS</p><h2 id="3-Linux中总结"><a href="#3-Linux中总结" class="headerlink" title="3.Linux中总结"></a>3.Linux中总结</h2><p>1)如何通过一个简短的关键字,例如process 获取相关的命令。</p><figure class="highlight livecodeserver"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs livecodeserver">man <span class="hljs-built_in">process</span><br><span class="hljs-built_in">process</span> <span class="hljs-comment">--help</span><br><span class="hljs-built_in">process</span> -h(内部命令)<br></code></pre></td></tr></table></figure><p>2)通过命令的描述,选择一个命令,获取命令的man文档。</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">man</span> <span class="hljs-built_in">ls</span><br></code></pre></td></tr></table></figure><p>3)解读man文档,man分几个部分?man每个部分的解释,特别是语法部分。<>, [] …等各代表什么含义。</p><figure class="highlight gherkin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs gherkin">NAME 命令的名称<br>SYNOPSIS 命令的格式<br>[] 可选内容<br><span class="hljs-variable"><></span> 必选内容<br>a|<span class="hljs-string">b 二选一</span><br><span class="hljs-string">... 同一内容可出现多次</span><br><span class="hljs-string">DESCRIOTION 命令的描述</span><br><span class="hljs-string">OPTIONS 命令的参数</span><br><span class="hljs-string">EXAMPLES 命令举例</span><br><span class="hljs-string">AUTHOR 命令作者</span><br><span class="hljs-string">REPORTING BUGS 命令的BUG修改情况</span><br><span class="hljs-string">SEE ALSO </span><br></code></pre></td></tr></table></figure><p>4)根据语法部分 简要的写几个操作。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">ls</span> -a:列出当前目录下所有文件<br><span class="hljs-built_in">ls</span> -l:显示更加完全的信息,格式<br></code></pre></td></tr></table></figure><h2 id="4-切换到-etc-目录,列出fstab文件的详细信息,详细解决fstab一行,每个或每几个字符的详细含义。"><a href="#4-切换到-etc-目录,列出fstab文件的详细信息,详细解决fstab一行,每个或每几个字符的详细含义。" class="headerlink" title="4.切换到/etc/目录,列出fstab文件的详细信息,详细解决fstab一行,每个或每几个字符的详细含义。"></a>4.切换到/etc/目录,列出fstab文件的详细信息,详细解决fstab一行,每个或每几个字符的详细含义。</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">#</span><br><span class="hljs-comment"># /etc/fstab</span><br><span class="hljs-comment"># Created by anaconda on Fri Feb 18 20:42:44 2022</span><br><span class="hljs-comment">#</span><br><span class="hljs-comment"># Accessible filesystems, by reference, are maintained under '/dev/disk'</span><br><span class="hljs-comment"># See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info</span><br><span class="hljs-comment">#</span><br>UUID=69faa10e-7a46-47af-88f2-55b65be6d82d / xfs defaults 0 0<br>UUID=9ade9f73-8ffb-41b8-8a49-eef1512e07a7 /boot xfs defaults 0 0<br><span class="hljs-comment">#UUID=862b50f1-d9ca-45e9-8540-5bbe6c2b4f04 swap swap defaults 0 0</span><br>UUID=7b96d0e5-dae5-4538-a9ab-aebe08a26cec /root/mount ext4 defaults 0 2<br><br><span class="hljs-comment">######################</span><br>UUID:磁盘分区唯一识别码<br>/:分区挂载点<br>xfs:分区文件系统类型,可通过<span class="hljs-built_in">df</span> -Th查看<br>default:默认的挂载参数<br>dump:是否做备份,一般为0<br>pass:fsck需要检查分区的顺序,一般来说根目录为0,优先级为最高,其他分区(数据盘)一般设置为2<br></code></pre></td></tr></table></figure><h2 id="5-简要说明FHS结构。"><a href="#5-简要说明FHS结构。" class="headerlink" title="5.简要说明FHS结构。"></a>5.简要说明FHS结构。</h2><p>FHS :文件系统层级结构,Linux常见的目录</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><code class="hljs bash">/:根目录,所有的目录、文件、设备都在/之下,根分区挂载在根目录下<br>/bin 可执行文件,其实/bin是/usr/bin的软链接,一般的可执行文件都放在/usr/bin中<br>/boot 系统启动相关的文件,内核文件等<br>/dev 设备文件目录,外部设备<br>/etc 配置文件,系统配置文件例如/etc/profile,网卡配置文件等,包括很多yum安装的服务例如httpd,nginx的主目录也在/etc下<br>/home 家目录,创建用户所在的目录<br>/lib library,库文件和内核模块文件,这个目录是用来存放系统动态连接共享库的。<br>/mnt 挂载点目录,通常挂载其他文件系统,挂载其他分区<br>/root root用户的家目录,在生产环境中不允许用root用户登录<br>/run 进程相关的数据<br>/sbin 系统管理员命令<br>/srv 系统服务相关数据 系统启动服务时候可以访问的数据库目录<br>/tmp temp,临时文件目录<br>/usr 系统核心所在目录,系统资源所在,结构和/目录类似<br>/var 可以理解为vary的缩写,/var下有/var/log 这是用来存放系统日志的目录。<br>/proc 用于存放进程相关数据,一个进程号pid就是一个目录<br></code></pre></td></tr></table></figure><h2 id="6-用自己的理解总结-文件管理,用户管理,组用户,权限管理相关的命令"><a href="#6-用自己的理解总结-文件管理,用户管理,组用户,权限管理相关的命令" class="headerlink" title="6.用自己的理解总结 文件管理,用户管理,组用户,权限管理相关的命令"></a>6.用自己的理解总结 文件管理,用户管理,组用户,权限管理相关的命令</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs bash">Linux本身就由文件组成,一切皆文件<br><br><span class="hljs-comment">##文件管理</span><br>添加文件、编辑文件、删除文件、移动修改文件<br><br><span class="hljs-comment">##用户管理</span><br>用户分为:系统用户(uid:1-999),服务用户(1000+)<br>useradd:添加用户<br>userdel:删除用户<br><span class="hljs-built_in">id</span> user:查看用户信息,所属组信息<br><span class="hljs-built_in">whoami</span>:查看用户信息<br>passwd user:修改密码<br>su root/su user:切换用户,需要输入密码<br><br><span class="hljs-comment">##组用户</span><br>一组有相同权限的用户<br>groupadd:创建组<br>groupdel:删除组<br><br><span class="hljs-comment">##权限管理相关,查看文件的属性,各个属主,属组,others对文件的权限</span><br>[root@master ~]<span class="hljs-comment">#ll 1.sh</span><br>-rwxr-xr-x 1 root root 75 Jun 6 21:27 1.sh<br><br><span class="hljs-built_in">chmod</span>:修改文件的所属主、属组、其他人权限<br>rwx:读写执行权限,对应421<br><span class="hljs-built_in">chmod</span> u+x 1.sh:修改1.sh文件属主有x可执行权限,变为可执行文件<br><br><span class="hljs-built_in">chown</span>:修改文件属主<br><span class="hljs-comment">##修改文件的属主</span><br>useradd nginx<br><span class="hljs-built_in">chown</span> nginx 1.sh<br>[root@master ~]<span class="hljs-comment">#ll</span><br>total 7168<br>-rwxr-xr-x 1 nginx root 75 Jun 6 21:27 1.sh<br><br><span class="hljs-built_in">chgrp</span>:修改文件属组<br><span class="hljs-comment">##修改dns配置的所属组</span><br><span class="hljs-built_in">chgrp</span> named /var/named/catyer.cn.zone<br>[root@master ~]<span class="hljs-comment">#ll /var/named/catyer.cn.zone </span><br>-rw-r----- 1 root named 435 Jul 23 08:54 /var/named/catyer.cn.zone<br></code></pre></td></tr></table></figure>]]></content>
</entry>
<entry>
<title>作业</title>
<link href="/2022/07/27/%E4%BD%9C%E4%B8%9A/"/>
<url>/2022/07/27/%E4%BD%9C%E4%B8%9A/</url>
<content type="html"><![CDATA[<h1 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h1><p>第一周作业</p><p>编辑编辑编辑了哈哈哈哈哈</p><p>2022-0727</p><p>编辑了编辑了</p><span id="more"></span>]]></content>
</entry>
<entry>
<title>test</title>
<link href="/2022/07/26/test/"/>
<url>/2022/07/26/test/</url>
<content type="html"><![CDATA[<h1 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h1><p>test.html</p><span id="more"></span>]]></content>
</entry>
<entry>
<title>与安全</title>
<link href="/2022/07/26/%E4%B8%8E%E5%AE%89%E5%85%A8/"/>
<url>/2022/07/26/%E4%B8%8E%E5%AE%89%E5%85%A8/</url>
<content type="html"><![CDATA[<h1 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h1><span id="more"></span>]]></content>
</entry>
<entry>
<title>免费搞网站-gitpages</title>
<link href="/2022/05/12/%E5%85%8D%E8%B4%B9%E6%90%9E%E7%BD%91%E7%AB%99-gitpages/"/>
<url>/2022/05/12/%E5%85%8D%E8%B4%B9%E6%90%9E%E7%BD%91%E7%AB%99-gitpages/</url>
<content type="html"><![CDATA[<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>完全免费的git网站搭建, 参考 <a href="https://blog.csdn.net/yaorongke/article/details/119089190">https://blog.csdn.net/yaorongke/article/details/119089190</a></p><p>实现的目标: 本地写markdown, 推送github即可以看 github.io 域名查看网页。</p><p>实现的工具</p><ul><li><code>nodejs</code> hexo生成网站</li><li><code>codeup.aliyun.com</code> 保存自己的博客代码</li><li><code>github.com</code> 静态页面展示 </li><li><code>vscode</code> 开发工具</li></ul><span id="more"></span><h1 id="生成静态页面"><a href="#生成静态页面" class="headerlink" title="生成静态页面"></a>生成静态页面</h1><p>参考 <a href="https://blog.csdn.net/yaorongke/article/details/119089190">https://blog.csdn.net/yaorongke/article/details/119089190</a> 确保访问OK</p><p>slcnx.github.io 仓库名</p><p>准备index.html</p><figure class="highlight xml"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></div></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta"><!DOCTYPE <span class="hljs-keyword">html</span>></span><br><span class="hljs-tag"><<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>></span><br><span class="hljs-tag"><<span class="hljs-name">head</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">"X-UA-Compatible"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"IE=edge"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">title</span>></span>主页<span class="hljs-tag"></<span class="hljs-name">title</span>></span><br><span class="hljs-tag"></<span class="hljs-name">head</span>></span><br><span class="hljs-tag"><<span class="hljs-name">body</span>></span><br> hello world<br><span class="hljs-tag"></<span class="hljs-name">body</span>></span><br><span class="hljs-tag"></<span class="hljs-name">html</span>></span><br></code></pre></td></tr></table></figure><p><img src="20220512214701-16524035403072.png" alt="image-20220512214700115"></p><p><img src="20220512214623.png" alt="image-20220512214617755"></p><h1 id="docker推送github"><a href="#docker推送github" class="headerlink" title="docker推送github"></a>docker推送github</h1><p>新建临时目录,vscode打开, 准备以下文件</p><p>id_rsa_2048 <strong>需要linux生成或xshell生成,不可以自己生成</strong></p><p>id_rsa_2048的公钥加入到以上仓库中</p><p><img src="20220512225649.png" alt="image-20220512225647448"></p><p>Dockerfile</p><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs routeros"><span class="hljs-keyword">FROM</span> node:latest<br><br><br>WORKDIR /data/git <br><br><span class="hljs-built_in">ADD</span> id_rsa_2048 /root/.ssh/<br><span class="hljs-built_in">RUN</span> chmod 600 /root/.ssh/id_rsa_2048 <br><br><span class="hljs-built_in">ADD</span> . ./<br><br><span class="hljs-comment"># 生成网页</span><br><span class="hljs-comment">#RUN npm run build </span><br><br><br><span class="hljs-comment"># 上传到GIT</span><br><br><span class="hljs-built_in">RUN</span> install -dv /data/page/ && cp -a index.html /data/page/<br><br><br>WORKDIR /data/page/<br>ENV <span class="hljs-attribute">GIT_SSH_COMMAND</span>=<span class="hljs-string">'ssh -i /root/.ssh/id_rsa_2048 -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'</span><br><span class="hljs-built_in">RUN</span> git<span class="hljs-built_in"> config </span>--global init.defaultBranch main && git<span class="hljs-built_in"> config </span>--global user.email <span class="hljs-string">'[email protected]'</span> && git<span class="hljs-built_in"> config </span>--global user.name <span class="hljs-string">'songliangcheng'</span> && \<br> git<span class="hljs-built_in"> config </span>--global pull.rebase <span class="hljs-literal">true</span> && \<br> git init && \<br> git remote <span class="hljs-built_in">add</span> origin [email protected]:slcnx/slcnx.github.io.git && git <span class="hljs-built_in">add</span> -A && git commit -m init && git push --force origin main <br></code></pre></td></tr></table></figure><p>index.html</p><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta"><!DOCTYPE <span class="hljs-keyword">html</span>></span><br><span class="hljs-tag"><<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>></span><br><br><span class="hljs-tag"><<span class="hljs-name">head</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">"X-UA-Compatible"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"IE=edge"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">title</span>></span>主页<span class="hljs-tag"></<span class="hljs-name">title</span>></span><br><span class="hljs-tag"></<span class="hljs-name">head</span>></span><br><br><span class="hljs-tag"><<span class="hljs-name">body</span>></span><br> cat<br><span class="hljs-tag"></<span class="hljs-name">body</span>></span><br><br><span class="hljs-tag"></<span class="hljs-name">html</span>></span><br></code></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">D:\vscode_projects\myblog>docker build -t <span class="hljs-built_in">test</span> .<br></code></pre></td></tr></table></figure><p><img src="20220512223352.png" alt="image-20220512223351323"></p><h1 id="本地生成hexo仓库"><a href="#本地生成hexo仓库" class="headerlink" title="本地生成hexo仓库"></a>本地生成hexo仓库</h1><h2 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install hexo-cli -g<br><br><span class="hljs-comment"># 当前目录为项目根</span><br>hexo init test1blog<br><span class="hljs-built_in">cd</span> test1blog<br><br><span class="hljs-comment"># 内容</span><br>$ <span class="hljs-built_in">ls</span><br>_config.landscape.yml node_modules/ package-lock.json <span class="hljs-built_in">source</span>/<br>_config.yml package.json scaffolds/ themes/<br></code></pre></td></tr></table></figure><h2 id="启动"><a href="#启动" class="headerlink" title="启动"></a>启动</h2><figure class="highlight axapta"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs axapta">hexo <span class="hljs-keyword">server</span><br></code></pre></td></tr></table></figure><p><img src="20220512224452.png" alt="image-20220512224451207"></p><h2 id="发布到github"><a href="#发布到github" class="headerlink" title="发布到github"></a>发布到github</h2><p>在以上目录 <code>test1blog</code> 中生成以下文件</p><ol><li><p><code>.dockerignore</code></p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs">node_modules/<br></code></pre></td></tr></table></figure></li><li><p><code>Dockerfile</code></p><figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs dockerfile"><span class="hljs-keyword">FROM</span> node:latest<br><br><br><span class="hljs-keyword">WORKDIR</span><span class="language-bash"> /data/git </span><br><br><span class="hljs-keyword">ADD</span><span class="language-bash"> id_rsa_2048 /root/.ssh/</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> <span class="hljs-built_in">chmod</span> 600 /root/.ssh/id_rsa_2048 </span><br><br><span class="hljs-keyword">ADD</span><span class="language-bash"> . ./</span><br><br><span class="hljs-comment"># 生成网页</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> npm install && npm run build </span><br><br><span class="hljs-comment"># 上传到GIT</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> install -dv /data/page/ && <span class="hljs-built_in">cp</span> -a public /data/page/</span><br><br><span class="hljs-keyword">ARG</span> GITHUB<br><span class="hljs-keyword">ARG</span> GUSER <br><span class="hljs-keyword">ARG</span> EMAIL <br><span class="hljs-keyword">WORKDIR</span><span class="language-bash"> /data/page/public/</span><br><span class="hljs-keyword">ENV</span> GIT_SSH_COMMAND=<span class="hljs-string">'ssh -i /root/.ssh/id_rsa_2048 -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> git config --global init.defaultBranch main && git config --global user.email <span class="hljs-variable">$EMAIL</span> && git config --global user.name <span class="hljs-variable">$GUSER</span> && \</span><br><span class="language-bash"> git config --global pull.rebase <span class="hljs-literal">true</span> && \</span><br><span class="language-bash"> git init && \</span><br><span class="language-bash"> git remote add origin <span class="hljs-variable">$GITHUB</span> && git add -A && git commit -m init && git push --force origin main </span><br></code></pre></td></tr></table></figure></li><li><p><code>id_rsa_2048</code> 以上与github互通的密钥</p></li><li><p>发布</p><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs stylus">docker build <span class="hljs-attr">--build-arg</span> GITHUB=git@github<span class="hljs-selector-class">.com</span>:slcnx/slcnx<span class="hljs-selector-class">.github</span><span class="hljs-selector-class">.io</span><span class="hljs-selector-class">.git</span> <span class="hljs-attr">--build-arg</span> EMAIL=<span class="hljs-string">'[email protected]'</span> <span class="hljs-attr">--build-arg</span> GUSER=<span class="hljs-string">'songliangcheng'</span> ./<br></code></pre></td></tr></table></figure></li></ol><p><img src="20220512225143.png" alt="image-20220512225141348"></p><h1 id="codeup一键发布"><a href="#codeup一键发布" class="headerlink" title="codeup一键发布"></a>codeup一键发布</h1><h2 id="添加codeup仓库"><a href="#添加codeup仓库" class="headerlink" title="添加codeup仓库"></a>添加codeup仓库</h2><p>将当前仓库加入到自己的codeup中</p><p><img src="20220512230442.png" alt="image-20220512230441057"></p><p>复制https地址 <a href="https://codeup.aliyun.com/5f73e5a3728df4b180fab5ca/myblog-2022-05-12.git">https://codeup.aliyun.com/5f73e5a3728df4b180fab5ca/myblog-2022-05-12.git</a></p><h2 id="初始化代码"><a href="#初始化代码" class="headerlink" title="初始化代码"></a>初始化代码</h2><p>将上面test1blog中,初始化,添加代码</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash">git config --global init.defaultBranch main<br>git init<br>git remote add origin https://codeup.aliyun.com/5f73e5a3728df4b180fab5ca/myblog-2022-05-12.git<br></code></pre></td></tr></table></figure><p>添加文件 <code>.gitignore</code></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># Logs</span><br>logs<br>*.<span class="hljs-built_in">log</span><br>npm-debug.log*<br>yarn-debug.log*<br>yarn-error.log*<br>lerna-debug.log*<br>.pnpm-debug.log*<br><br><span class="hljs-comment"># Diagnostic reports (https://nodejs.org/api/report.html)</span><br>report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json<br><br><span class="hljs-comment"># Runtime data</span><br>pids<br>*.pid<br>*.seed<br>*.pid.lock<br><br><span class="hljs-comment"># Directory for instrumented libs generated by jscoverage/JSCover</span><br>lib-cov<br><br><span class="hljs-comment"># Coverage directory used by tools like istanbul</span><br>coverage<br>*.lcov<br><br><span class="hljs-comment"># nyc test coverage</span><br>.nyc_output<br><br><span class="hljs-comment"># Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)</span><br>.grunt<br><br><span class="hljs-comment"># Bower dependency directory (https://bower.io/)</span><br>bower_components<br><br><span class="hljs-comment"># node-waf configuration</span><br>.lock-wscript<br><br><span class="hljs-comment"># Compiled binary addons (https://nodejs.org/api/addons.html)</span><br>build/Release<br><br><span class="hljs-comment"># Dependency directories</span><br>node_modules/<br>jspm_packages/<br><br><span class="hljs-comment"># Snowpack dependency directory (https://snowpack.dev/)</span><br>web_modules/<br><br><span class="hljs-comment"># TypeScript cache</span><br>*.tsbuildinfo<br><br><span class="hljs-comment"># Optional npm cache directory</span><br>.npm<br><br><span class="hljs-comment"># Optional eslint cache</span><br>.eslintcache<br><br><span class="hljs-comment"># Optional stylelint cache</span><br>.stylelintcache<br><br><span class="hljs-comment"># Microbundle cache</span><br>.rpt2_cache/<br>.rts2_cache_cjs/<br>.rts2_cache_es/<br>.rts2_cache_umd/<br><br><span class="hljs-comment"># Optional REPL history</span><br>.node_repl_history<br><br><span class="hljs-comment"># Output of 'npm pack'</span><br>*.tgz<br><br><span class="hljs-comment"># Yarn Integrity file</span><br>.yarn-integrity<br><br><span class="hljs-comment"># dotenv environment variable files</span><br>.<span class="hljs-built_in">env</span><br>.env.development.local<br>.env.test.local<br>.env.production.local<br>.env.local<br><br><span class="hljs-comment"># parcel-bundler cache (https://parceljs.org/)</span><br>.cache<br>.parcel-cache<br><br><span class="hljs-comment"># Next.js build output</span><br>.next<br>out<br><br><span class="hljs-comment"># Nuxt.js build / generate output</span><br>.nuxt<br>dist<br><br><span class="hljs-comment"># Gatsby files</span><br>.cache/<br><span class="hljs-comment"># Comment in the public line in if your project uses Gatsby and not Next.js</span><br><span class="hljs-comment"># https://nextjs.org/blog/next-9-1#public-directory-support</span><br><span class="hljs-comment"># public</span><br><br><span class="hljs-comment"># vuepress build output</span><br>.vuepress/dist<br><br><span class="hljs-comment"># vuepress v2.x temp and cache directory</span><br>.temp<br>.cache<br><br><span class="hljs-comment"># Docusaurus cache and generated files</span><br>.docusaurus<br><br><span class="hljs-comment"># Serverless directories</span><br>.serverless/<br><br><span class="hljs-comment"># FuseBox cache</span><br>.fusebox/<br><br><span class="hljs-comment"># DynamoDB Local files</span><br>.dynamodb/<br><br><span class="hljs-comment"># TernJS port file</span><br>.tern-port<br><br><span class="hljs-comment"># Stores VSCode versions used for testing VSCode extensions</span><br>.vscode-test<br><br><span class="hljs-comment"># yarn v2</span><br>.yarn/cache<br>.yarn/unplugged<br>.yarn/build-state.yml<br>.yarn/install-state.gz<br>.pnp.*<br><br><br><span class="hljs-comment"># 静态文件</span><br>public <br></code></pre></td></tr></table></figure><h2 id="推送aliyun"><a href="#推送aliyun" class="headerlink" title="推送aliyun"></a>推送aliyun</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 状态</span><br>$ git status<br>hint: core.useBuiltinFSMonitor will be deprecated soon; use core.fsmonitor instead<br>hint: Disable this message with <span class="hljs-string">"git config advice.useCoreFSMonitorConfig false"</span><br>On branch main<br><br>No commits yet<br><br>Untracked files:<br> (use <span class="hljs-string">"git add <file>..."</span> to include <span class="hljs-keyword">in</span> what will be committed)<br> .dockerignore<br> .github/<br> .gitignore<br> .npmignore<br> Dockerfile<br> _config.landscape.yml<br> _config.yml<br> db.json<br> id_rsa_2048<br> package-lock.json<br> package.json<br> scaffolds/<br> <span class="hljs-built_in">source</span>/<br> themes/<br> <br><span class="hljs-comment"># 生成标志</span><br>$ <span class="hljs-built_in">echo</span> <span class="hljs-string">'1111'</span> >> <span class="hljs-built_in">source</span>/_posts/hello-world.md<br><br><span class="hljs-comment"># 推送</span><br>git add . <br>git commit -m init<br><br>$ git push origin main<br>Enumerating objects: 122, <span class="hljs-keyword">done</span>.<br>Counting objects: 100% (122/122), <span class="hljs-keyword">done</span>.<br>Delta compression using up to 8 threads<br>Compressing objects: 100% (110/110), <span class="hljs-keyword">done</span>.<br>Writing objects: 100% (122/122), 580.00 KiB | 7.34 MiB/s, <span class="hljs-keyword">done</span>.<br>Total 122 (delta 0), reused 0 (delta 0), pack-reused 0<br>To https://codeup.aliyun.com/5f73e5a3728df4b180fab5ca/myblog-2022-05-12.git<br> * [new branch] main -> main<br><br></code></pre></td></tr></table></figure><h2 id="aliyun验证"><a href="#aliyun验证" class="headerlink" title="aliyun验证"></a>aliyun验证</h2><p><img src="20220512231059.png" alt="image-20220512231058218"></p><h2 id="添加流水线"><a href="#添加流水线" class="headerlink" title="添加流水线"></a>添加流水线</h2><p><img src="20220512231120.png" alt="image-20220512231118465"></p><p><img src="20220512231146.png" alt="image-20220512231145367"></p><p><img src="20220513000840.png" alt="image-20220513000838863"></p><p><img src="20220512231255.png" alt="image-20220512231253578"></p><p><img src="20220512231628.png" alt="image-20220512231626849"></p><p>删除kubernetes发布</p><p>保存并运行</p><p><img src="20220512231324.png" alt="image-20220512231322519"></p><h2 id="查看运行日志"><a href="#查看运行日志" class="headerlink" title="查看运行日志"></a>查看运行日志</h2><p><img src="20220512232021.png" alt="image-20220512232019242"></p><h2 id="查看github进度"><a href="#查看github进度" class="headerlink" title="查看github进度"></a>查看github进度</h2><p><img src="20220512232122.png" alt="image-20220512232121239"></p><h2 id="查看页面"><a href="#查看页面" class="headerlink" title="查看页面"></a>查看页面</h2><p>当进度为</p><p><img src="20220512232141.png" alt="image-20220512232140087"></p><p><img src="20220512232151.png" alt="image-20220512232150142"></p><h1 id="开发方式"><a href="#开发方式" class="headerlink" title="开发方式"></a>开发方式</h1><h2 id="准备vscode"><a href="#准备vscode" class="headerlink" title="准备vscode"></a>准备vscode</h2><p>在vscode中加载 codeup的仓库</p><p>安装插件 typora <strong>安装后需要重启vscode</strong></p><p><img src="20220512231737.png" alt="image-20220512231735959"></p><h2 id="本地开发"><a href="#本地开发" class="headerlink" title="本地开发"></a>本地开发</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># clone 代码</span><br><br><span class="hljs-comment"># 安装依赖</span><br>npm install<br><br><span class="hljs-comment"># 运行服务</span><br>npx hexo server<br></code></pre></td></tr></table></figure><blockquote><p><code>npx command</code> 相当于加载了<code>$(npm bin)</code> 目录到环境变量, 后面的命令可以执行</p></blockquote><p>通过本地调试出合理的界面, 推送aliyun, 就可以一键发布</p><h2 id="本地添加文章"><a href="#本地添加文章" class="headerlink" title="本地添加文章"></a>本地添加文章</h2><p>脚本 <code>addarticle.sh</code></p><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs awk">echo -ne <span class="hljs-string">"Enter a \033[1;31mtitle\033[0m for your blog: "</span>; read title<br>[ $? -ne <span class="hljs-number">0</span> ] && echo <span class="hljs-string">'exit'</span> && sleep <span class="hljs-number">3</span> && <span class="hljs-keyword">exit</span> <span class="hljs-number">1</span><br>[ -z <span class="hljs-string">"$title"</span> ] && echo title must be exists. && sleep <span class="hljs-number">3</span> && <span class="hljs-keyword">exit</span> <span class="hljs-number">1</span><br>npx hexo new <span class="hljs-string">"$title"</span><br><br>start $(readlink -f .)<span class="hljs-regexp">/source/</span>_posts<br></code></pre></td></tr></table></figure><p>生成文章, 运行脚本</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-meta">---</span><br><span class="hljs-attr">title:</span> <span class="hljs-string">第1个文章</span><br><span class="hljs-attr">date:</span> <span class="hljs-number">2022-05-12 23:27:58</span><br><span class="hljs-meta">---</span><br></code></pre></td></tr></table></figure><h2 id="个性化页面展示"><a href="#个性化页面展示" class="headerlink" title="个性化页面展示"></a>个性化页面展示</h2><p><a href="https://blog.csdn.net/yaorongke/article/details/119089190">https://blog.csdn.net/yaorongke/article/details/119089190</a></p><ul><li><code>hexo站点配置</code></li><li><code>fluid</code>主题配置</li><li><code>阅读量</code></li><li><code>评论功能</code></li></ul><p>例如修改标题 <code>_config.yml</code></p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">title:</span> <span class="hljs-string">"5-12 23:30"</span><br><span class="hljs-comment"># ...</span><br><br><span class="hljs-attr">post_asset_folder:</span> <span class="hljs-literal">true</span><br></code></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 处理typora相对路径</span><br>npm install hexo-typora-asset --registry https://registry.npmjs.org --save<br></code></pre></td></tr></table></figure><p>typora中的配置</p><p><img src="image-20220513092438970.png" alt="image-20220513092438970"></p><p>重启 <code>npx hexo server</code></p><p><img src="20220512233119.png" alt="image-20220512233117729"></p><h2 id="文章默认页面-可选"><a href="#文章默认页面-可选" class="headerlink" title="文章默认页面(可选)"></a>文章默认页面(可选)</h2><p><a href="https://hexo.io/docs/writing#Scaffolds">https://hexo.io/docs/writing#Scaffolds</a></p><p>当我们写大量的文章,发现主页不应该显示所有内容,需要readmore, readmore之前有1小段简介</p><p>如下, 上面的nginx文章会<code>显示标题,简介,readmore</code>, 而下面的hello world就显示所有, 这两者区别在于</p><p>后者,默认</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-meta">---</span><br><span class="hljs-attr">title:</span> <span class="hljs-string">第1个文章</span><br><span class="hljs-attr">date:</span> <span class="hljs-number">2022-05-12 23:27:58</span><br><span class="hljs-meta">---</span><br></code></pre></td></tr></table></figure><p>前者</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-meta">---</span><br><span class="hljs-attr">title:</span> <span class="hljs-string">第1个文章</span><br><span class="hljs-attr">date:</span> <span class="hljs-number">2022-05-12 23:27:58</span><br><span class="hljs-attr">tags:</span><br><span class="hljs-bullet">-</span> <span class="hljs-string">hello</span><br><span class="hljs-attr">categories:</span><br><span class="hljs-bullet">-</span> <span class="hljs-string">nginx</span><br><span class="hljs-meta">---</span><br><span class="hljs-meta"></span><br><span class="hljs-meta"></span><br><span class="hljs-meta"></span><br><span class="hljs-comment"># 背景</span><br><br><span class="hljs-string">这篇讲解如何编译安装nginx,</span> <span class="hljs-string">优化nginx</span><br><br><span class="hljs-string"><!--more--></span><br></code></pre></td></tr></table></figure><p><img src="20220512234116.png" alt="image-20220512234114962"></p><p>要实现每个文章创建均生成nginx这样的模板, 编辑 <code>scaffolds/post.md</code></p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-meta">---</span><br><span class="hljs-attr">title:</span> {{ <span class="hljs-string">title</span> }}<br><span class="hljs-attr">date:</span> {{ <span class="hljs-string">date</span> }}<br><span class="hljs-attr">tags:</span><br><span class="hljs-bullet">-</span> <br><span class="hljs-attr">categories:</span><br><span class="hljs-bullet">-</span> <br><span class="hljs-meta">---</span><br><span class="hljs-meta"></span><br><span class="hljs-comment"># 背景</span><br><br><span class="hljs-string"><!--more--></span><br></code></pre></td></tr></table></figure><p>现在运行脚本 <code>addarticle.sh</code> 添加<strong>第2个文章</strong></p><p>网页已经达到效果</p><p><img src="20220512234553.png" alt="image-20220512234551537"></p><h2 id="准备一个主题-fluid"><a href="#准备一个主题-fluid" class="headerlink" title="准备一个主题 fluid"></a>准备一个主题 fluid</h2><blockquote><p>使用此主题后, 不需要前面的文章默认页面, 每个页面不需要加<code><!--more--></code> 主题会自动抽取前多少个字符,作为描述的.</p></blockquote><p>Fluid主题 <a href="https://blog.csdn.net/yaorongke/article/details/119089190">https://blog.csdn.net/yaorongke/article/details/119089190</a></p><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs awk">$ git submodule add https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/fluid-dev/</span>hexo-theme-fluid.git themes/fluid<br></code></pre></td></tr></table></figure><p>编辑 <code>_config.yml</code></p><figure class="highlight clean"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs clean"># Extensions<br>## Plugins: https:<span class="hljs-comment">//hexo.io/plugins/</span><br>## Themes: https:<span class="hljs-comment">//hexo.io/themes/</span><br>theme: fluid<br></code></pre></td></tr></table></figure><p>重启 <code>npx hexo server</code></p><p><img src="20220512235039.png" alt="image-20220512235038001"></p><p>配置主题 <code>fluid</code> 需要准备一个文件 <code>_config.主题名.yml</code></p><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs awk">cp themes<span class="hljs-regexp">/fluid/</span>_config.yml _config.fluid.yml<br></code></pre></td></tr></table></figure><p>测试配置是否生效,修改 <code>_config.fluid.yml</code></p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-comment"># 首页副标题的独立设置</span><br><span class="hljs-comment"># Independent config of home page subtitle</span><br><span class="hljs-attr">slogan:</span><br> <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br><br> <span class="hljs-comment"># 为空则按 hexo config.subtitle 显示</span><br> <span class="hljs-comment"># If empty, text based on `subtitle` in hexo config</span><br> <span class="hljs-attr">text:</span> <span class="hljs-string">"Hello 05-12 .... "</span><br></code></pre></td></tr></table></figure><p>重启 <code>npx hexo server</code></p><p><img src="20220512235647.png" alt="image-20220512235645718"></p><h2 id="发布"><a href="#发布" class="headerlink" title="发布"></a>发布</h2><p>准备脚本 <code>push.sh</code></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-meta">#!/bin/bash</span><br>git config --<span class="hljs-built_in">local</span> pull.rebase <span class="hljs-literal">true</span><br>git add .<br>git commit -m <span class="hljs-string">"笔记本-`date +%F_%T`"</span><br><br><br>git push origin main<br><br>git pull origin main<br>[ $? -ne 0 ] && <span class="hljs-built_in">exit</span> -1<br><br>git push origin main<br><br><span class="hljs-comment"># test</span><br>start $(<span class="hljs-built_in">readlink</span> -f .)/source/_posts<br></code></pre></td></tr></table></figure><p><a href="https://slcnx.github.io/">https://slcnx.github.io/</a></p>]]></content>
<tags>
<tag>git</tag>
</tags>
</entry>
</search>