summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html')
-rw-r--r--vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html40
1 files changed, 20 insertions, 20 deletions
diff --git a/vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html b/vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html
index 76bce3d6..fd9bba80 100644
--- a/vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html
+++ b/vhosts/blog/public/posts/2022-10-28/setup-server-for-this-site/index.html
@@ -88,7 +88,7 @@
<p>
ローカルマシンで鍵を生成する。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/teika.key</span></span>
<span class="line"><span>$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/github2teika.key</span></span></code></pre>
</div>
@@ -101,7 +101,7 @@
<p>
<code>.ssh/config</code> に設定しておく。
</p>
- <div class="codeblock" language="ssh_config">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>Host teika</span></span>
<span class="line"><span> HostName **********</span></span>
<span class="line"><span> User **********</span></span>
@@ -124,7 +124,7 @@
<p>
管理者ユーザで作業すると危ないので、メインで使うユーザを作成する。 <code>sudo</code> グループに追加して <code>sudo</code> できるようにし、<code>su</code> で切り替え。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo adduser **********</span></span>
<span class="line"><span>$ sudo adduser ********** sudo</span></span>
<span class="line"><span>$ su **********</span></span>
@@ -133,13 +133,13 @@
</section>
<section id="section--basic-setup--hostname">
<h3><a href="#section--basic-setup--hostname">ホスト名を変える</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo hostname teika</span></span></code></pre>
</div>
</section>
<section id="section--basic-setup--public-key">
<h3><a href="#section--basic-setup--public-key">公開鍵を置く</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ mkdir ~/.ssh</span></span>
<span class="line"><span>$ chmod 700 ~/.ssh</span></span>
<span class="line"><span>$ vi ~/.ssh/authorized_keys</span></span></code></pre>
@@ -153,7 +153,7 @@
<p>
SSH の設定を変更し、少しでも安全にしておく。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak</span></span>
<span class="line"><span>$ sudo vi /etc/ssh/sshd_config</span></span></code></pre>
</div>
@@ -171,7 +171,7 @@
<p>
そして設定を反映。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo systemctl restart sshd</span></span>
<span class="line"><span>$ sudo systemctl status sshd</span></span></code></pre>
</div>
@@ -181,7 +181,7 @@
<p>
今の SSH セッションは閉じずに、ターミナルを別途開いて疎通確認する。 セッションを閉じてしまうと、SSH の設定に不備があった場合に締め出しをくらう。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ ssh teika</span></span></code></pre>
</div>
</section>
@@ -190,7 +190,7 @@
<p>
デフォルトの 22 番を閉じ、設定したポートだけ空ける。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo ufw deny ssh</span></span>
<span class="line"><span>$ sudo ufw allow *******</span></span>
<span class="line"><span>$ sudo ufw enable</span></span>
@@ -206,20 +206,20 @@
<p>
GitHub に置いてある private リポジトリをサーバから clone したいので、SSH 鍵を生成して置いておく。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/github.key</span></span>
<span class="line"><span>$ cat ~/.ssh/github.key.pub</span></span></code></pre>
</div>
<p>
<a href="https://github.com/settings/ssh" rel="noreferrer" target="_blank">GitHub の設定画面</a> から、この公開鍵を追加する。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ vi ~/.ssh/config</span></span></code></pre>
</div>
<p>
設定はこう。
</p>
- <div class="codeblock" language="ssh_config">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>Host github.com</span></span>
<span class="line"><span> HostName github.com</span></span>
<span class="line"><span> User git</span></span>
@@ -230,13 +230,13 @@
<p>
最後に接続できるか確認しておく。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ ssh -T github.com</span></span></code></pre>
</div>
</section>
<section id="section--basic-setup--upgrade-packages">
<h3><a href="#section--basic-setup--upgrade-packages">パッケージの更新</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo apt update</span></span>
<span class="line"><span>$ sudo apt upgrade</span></span>
<span class="line"><span>$ sudo apt update</span></span>
@@ -255,13 +255,13 @@
</section>
<section id="section--site-hosting-setup--install-softwares">
<h3><a href="#section--site-hosting-setup--install-softwares">使うソフトウェアのインストール</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo apt install docker docker-compose git make</span></span></code></pre>
</div>
</section>
<section id="section--site-hosting-setup--docker">
<h3><a href="#section--site-hosting-setup--docker">メインユーザが Docker を使えるように</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo adduser ********** docker</span></span></code></pre>
</div>
</section>
@@ -270,7 +270,7 @@
<p>
80 番と 443 番を空ける。
</p>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ sudo ufw allow 80/tcp</span></span>
<span class="line"><span>$ sudo ufw allow 443/tcp</span></span>
<span class="line"><span>$ sudo ufw reload</span></span>
@@ -279,7 +279,7 @@
</section>
<section id="section--site-hosting-setup--clone-repositories">
<h3><a href="#section--site-hosting-setup--clone-repositories">リポジトリのクローン</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ cd</span></span>
<span class="line"><span>$ git clone git@github.com:nsfisis/nsfisis.dev.git</span></span>
<span class="line"><span>$ cd nsfisis.dev</span></span>
@@ -288,14 +288,14 @@
</section>
<section id="section--site-hosting-setup--certbot">
<h3><a href="#section--site-hosting-setup--certbot">certbot で証明書取得</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ docker-compose up -d acme-challenge</span></span>
<span class="line"><span>$ make setup</span></span></code></pre>
</div>
</section>
<section id="section--site-hosting-setup--run-server">
<h3><a href="#section--site-hosting-setup--run-server">サーバを稼動させる</a></h3>
- <div class="codeblock" language="shell-session">
+ <div class="codeblock">
<pre class="shiki github-light" style="background-color:#f5f5f5;color:#24292e" tabindex="0"><code><span class="line"><span>$ make serve</span></span></code></pre>
</div>
</section>