見出し画像

conoha vpsのosを入れ替えるなど

rsyncで一応全部コピーしておいた、収容する別ホストが無い場合は今日日これS3を使ってもいいかもしれない。遅そうだけど…

rsync -aHAXzv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / [dest]

サーバー再構築

ログインとapt 

apt update; apt dist-upgrade
# apt update
Hit:1 http://security.debian.org/debian-security bookworm-security InRelease
Hit:2 http://deb.debian.org/debian bookworm InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
N: Repository 'Debian bookworm' changed its 'firmware component' value from 'non-free' to 'non-free-firmware'
N: More information about this can be found online in the Release notes at: https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.html#non-free-split

こんなの言われる

やったこと

  • vim入れる

  • /etc/hostname を書き換える

  • localeを調整する

  • 一般ユーザー作る

    • グループに投入

  • パッケージ入れる

    • git

    • docker-compose

    • etckeeper

個人的にはetckeeperに結構依存してる気がしないでもない


ここではwebサーバーのstaging環境として起動するため、letsencryptを入れる。まあその実態としてはcertbotパッケージが入るが…あとpython3-certbot-apacheも入れた

webfront

単純にapache2をつかう、単純に楽なので。これはdockerにして個別に起動すると若干面倒くさいから、apache2パッケージを入れる

# apt install apache2
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4 liblua5.3-0 ssl-cert
提案パッケージ:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser
以下のパッケージが新たにインストールされます:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4 liblua5.3-0 ssl-cert
アップグレード: 0 個、新規インストール: 11 個、削除: 0 個、保留: 0 個。
2,690 kB のアーカイブを取得する必要があります。
この操作後に追加で 9,148 kB のディスク容量が消費されます。
続行しますか? [Y/n]

cert

# certbot --apache -d <ドメイン>
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 
Deploying certificate
Successfully deployed certificate 

とかいわれれば成功している。

# git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   apache2/sites-available/000-default.conf

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        apache2/mods-enabled/rewrite.load
        apache2/mods-enabled/socache_shmcb.load
        apache2/mods-enabled/ssl.conf
        apache2/mods-enabled/ssl.load
        apache2/sites-available/000-default-le-ssl.conf
        apache2/sites-enabled/000-default-le-ssl.conf
        letsencrypt/.updated-options-ssl-apache-conf-digest.txt
        letsencrypt/accounts/
        letsencrypt/archive/
        letsencrypt/csr/
        letsencrypt/keys/
        letsencrypt/live/
        letsencrypt/options-ssl-apache.conf
        letsencrypt/renewal/

とまあこんな感じで修正がかかったり、新規ファイルが出来たりする。でも実際これだとちょっとやり辛いので個人的には初回の変更だけ適用して実際にはvirtualhostは個別で作っちゃったりしてるかもしれない

proxy

dockerにはproxyを使って入れるので

a2enmod proxy proxy_http

など

dockerのビルド

# docker-compose build

本来rootでやらん方がええな…





この記事が気に入ったらサポートをしてみませんか?