20210413のLinuxに関する記事は4件です。

Uncaught Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): の解決方法

注意 今回の内容はコマンドの実行内容を完全に理解できていないように思います。場当たり的な解決できた参考例である事を前提として、実行の際には自己責任でお願いいたします。 環境 ・AWS Cloud9 (Ubuntu 18.04.5 LTS, Bionic Beaver)1 ・Node.js2 エラー内容 Terminal Uncaught Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): 解決策 以下を実行。 Terminal npm install --save-dev --unsafe-perm node-sass 経緯 検索した結果で最頻の方法を試すも解決しなかった。以下のコマンド。 Terminal npm rebuild node-sass エラー原因・背景など ・原因:EC2のデフォルトのnode-sassが古かった?(導入:2021/2/14時点) https://stackoverflow.com/questions/54354644/error-in-module-build-failed-from-node-modules-sass-loader-lib-loader-js ・コマンド背景参考URL https://qastack.jp/programming/48147896/error-in-cannot-find-module-node-sass 2021/2/14時点 ↩ バージョンは失念しました...すみません ↩
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

CentOS6.xでcertbot-autoが動かなくなったので対応 (apache)

以下の複数の原因からCentOS6.xにインストールしたLetsEncryptのcertbot-autoコマンドが起動できず、SSL証明書の更新が出来なくなりました。新しいOSに引っ越すのが当然ですがとりあえずSSL証明書の更新はしないといけません。 調べてみると同じ条件でないことが多く、完全な解決策を見つけることが出来ませんでした。整理してみると、まず原因は以下の2つかと思います。 2020秋にサポート切れでyumリポジトリが閉鎖され色々ダメになった certbot-autoコマンドがpython3.5以上でないと動かなくなった これを解決するため色々とみなさん試行錯誤されているようです。かくいう私もSSLの期限が迫っている数台のサーバーを何とかせねばならず焦っていました。調査したサーバーの主な環境は、 CentOS 6.10 Apache 2.2 https://certbot.eff.org のCentOS6用の今はない手順書で入れたcerbot-autoコマンド certbot-autoのエラーから察するに、python3.5以上なら動きそうですが、例えcertbot-autoをアップデートしても現時点ではCentOS6で動作を認めていないようで、結局「このOSはサポートされないよ」というエラーとなります。ですので今でも汎用のLinux用にサポートしている pip で certbot をインストールする方法が唯一の対策かと思います。やるべきとこは、 なにはともあれ yum リポジトリを使えるようにする SCL (Software Collections) を使って python3.6 を入れる certbot-auto をやめ新たに certbot を pip でインストール です。途中で色々苦労することが多いのはそのサーバーの環境が違うからなんですが、今回、複数(7台以上)の仮想サーバーで、CentOS 6.4, 6.7, 6.8, 6.9, 6.10 で検証しているのでかなり問題が網羅できていると思っています。 1. 使えなくなったリポジトリの変更 これはよくネットで書かれているようなsedコマンドでファイルを書き換えます。 手で書き換えても構いません。mirrorlist= の行をコメントにし、baseurl= のホスト名を「vault.centos.org」に変更しコメントを外すだけです。 # sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo # sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo 2. Python3.6 入れるため SCLリポジトリ追加 # yum install centos-release-SCL これもOSサポート終了のためそのままでは動かないのでリポジトリURL(baseurl)を変更します。 CentOS-Base.repo と同じホスト名の変更&コメントを外し、mirrorlist= 行のコメントアウト。 /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo [centos-sclo-rh] name=CentOS-6 - SCLo rh baseurl=http://vault.centos.org/centos/6/sclo/$basearch/rh/ #mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=6&repo=sclo-rh ・・・・ /etc/yum.repos.d/CentOS-SCLo-scl.repo が存在するなら CentOS-Base.repo と同じような修正が必要です。(他にも/etc/yum.repos.d/*.repoファイルがあればチェックが必要かも) # yum clean all 3. Python3.6 インストール SCL専用のパッケージ「rh-python36」をインストールしシェルで使えるように有効化します。 # yum install rh-python36 # scl enable rh-python36 bash ここで不運にも エラー: Cannot retrieve metalink for repository: epel. と出てしまった場合、SSLプロトコルの問題の可能性があり、 /etc/yum.repos.d/epel.repo mirrorlist=http://mirrors.fedoraproject.org・・・ epel.repo 内のすべて https を http に変更するとよい。 4. python3 コマンドとしてシンボリックリンク # cd /usr/bin # unlink python3 # ln -s /opt/rh/rh-python36/root/usr/bin/python3 python3 # python3 --version 5. 本題である certbot コマンドをインストール Pythonの仮想実行環境venvを使い、pipでcertbotをインストールします。 httpサーバーにApache2を使っているので同時に apache プラグインもインストールします。 # python3 -m venv /opt/certbot/ # /opt/certbot/bin/pip install --upgrade pip # /opt/certbot/bin/pip install certbot certbot-apache # ln -s /opt/certbot/bin/certbot /usr/bin/certbot # certbot --version 6. 証明書自動更新(cron)の修正 私の場合 cron の設定は /etc/cron.d/letsencrypt に書いていましたのでこれを編集します。certbot-auto をそのまま certbot に置き換えるだけです。(数字 の N は任意ですね) /etc/cron.d/letsencrypt 00 N * * N root certbot renew --post-hook "service httpd restart" これでしばらくは使えそうでは? 証明書のパスなど構造は certbot-auto と同じなのでこのまま継続して使用出来ます。 # certbot certificates もちろんSSL証明書の新規所得も可能です。 # certbot --apache サーバー構築は比較的古めのCentOSを使ってきたツケがここに来てまわってきた感じで、SSLがどんどん期限切れになっていく様は時限爆弾のようです。 一部は新しいサーバーを立て引っ越してしまいましたがそれも気が遠くなるのでこの対策で少し楽になりました。放置した自分が悪いのですが、昔のシステムのメンテはモチベーション上がりませんよね。新しいサーバーに新しいシステム入れるのは楽しいんだけど。 これからはUbuntu20.04を使っていきます。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

サーバ内の不要ユーザ追い出し

きっかけ EC2で通信が遮断された際にSSHのプロセスが残っているのが気になりやってみました。 ですので、ただの備忘録です TODO クライアント % ssh hoge-server サーバ $ w 12:00:00 up 1 days, 1:23, 1 user, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT fuga pts/0 xxxxxxxxxx.a 12:30 4.00s 0.05s 0.00s sshd: fuga [priv] hoge pts/1 xxxxxxxxxx.a 12:50 4.00s 0.05s 0.00s w $ ps ax | grep sshd 3336 ? Ss 0:00 /usr/sbin/sshd -D 22221 ? Ss 0:00 sshd: fuga [priv] 22223 ? S 0:00 sshd: fuga@pts/0 22228 ? Ss 0:00 sshd: hoge [priv] 22229 ? S 0:00 sshd: hoge@pts/1 $ kill -9 22223 解説 w ログインユーザの確認 whoでも確認可能 ps ax | grep sshd sshdのプロセスIDを確認 kill -9 プロセス強制終了コマンド 参考 https://eng-entrance.com/linux-command-kill https://www.atmarkit.co.jp/ait/articles/1807/26/news009.html https://uxmilk.jp/50638
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

dufコマンドが便利そうだった

はじめに サーバー運用をしていると、ディスク容量を確認するケースは多々あるかと思います。 df コマンドや du コマンドを使うケースが多いと思いますが、 良い感じに表示してくれる duf コマンドというものがあるようなので、試して記事にしました。 環境構築 mac 普通に Homebrew で入る。 brew install duf 入らない場合は、下記で formula として追加した後に実行する。 brew tap muesli/tap && brew install duf Linux(CentOS) sudo yum install https://github.com/muesli/duf/releases/download/v0.6.2/duf_0.6.2_linux_amd64.rpm 使ってみる こんな感じで色分けして表示される。 オプション % duf --help Usage of duf: -all include pseudo, duplicate, inaccessible file systems -hide string hide specific devices, separated with commas: local, network, fuse, special, loops, binds -hide-fs string hide specific filesystems, separated with commas -inodes list inode information instead of block usage -json output all devices in JSON format -only string show only specific devices, separated with commas: local, network, fuse, special, loops, binds -only-fs string only specific filesystems, separated with commas -output string output fields: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem -sort string sort output by: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem (default "mountpoint") -style string style: unicode, ascii (default "unicode") -theme string color themes: dark, light (default "dark") -version display version -warnings output all warnings to STDERR -width uint max output width 参考 GitHub dufコマンドでいい感じにディスクの使用量を表示する方法 duf – Disk Usage/Free Utility for Linux, BSD, macOS & Windows
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む