LoginSignup
1
2

More than 5 years have passed since last update.

【let's encrypt】./letsencrypt-auto実行時に発生するpipのエラー回避

Posted at

./letsencrypt-auto実行時に発生したエラーにかなり躓いたのでその回避方法を記述します.
また, letsencryptクライアントを使用していますがcertbotクライアントでも発生する模様です.

環境

  • OS:CentOS release 6.8
  • python 2.6.6 ,python 2.7.5(SCL)
  • pip 8.1.2

エラー内容

--略--
Failed building wheel for cffi
Command "/root/.local/share/letsencrypt/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-33ozQM/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-9u4Uv6-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.local/share/letsencrypt/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-33ozQM/cffi
You are using pip version 8.0.3, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

原因

エラーに表示されないので非常にわかりにくいですが, どうやらpipモジュールのインストール時にメモリが不足していることが起因しているらしいです.
また, 今回はcffiモジュールで発生していますが, cryptography等でも発生するようです.

解決方法

今回はスワップ領域を作成してメモリが使える領域を広げます.
最初にfreeコマンドでメモリを確認します.
メモリ1Gをほぼ使い切っている状態かつスワップ領域が0だとこのようになります.

$ free -m
             total       used       free     shared    buffers     cached
Mem:           992        975         16          0         12         55
-/+ buffers/cache:        908         84 
Swap:            0          0          0 

次にスワップファイルを作成し,有効にします.
今回はサーバのメモリが1Gなので2Gのスワップ領域を作成します.

$ dd if=/dev/zero of=/swapfile bs=1M count=2048
$ mkswap /swapfile
$ swapon /swapfile

この状態で確認すると下記のようにswap領域が作成されていることがわかります.

$ free -m
             total       used       free     shared    buffers     cached
Mem:           992        975         16          0         13         58
-/+ buffers/cache:        904         87 
Swap:         2047        135       1912 

さらにswap領域が自動でマウントできるように/etc/fstabに下記を追記します

/swapfile               swap                   swap    defaults        0 0

この状態で./letsencrypt-autoもしくは./certbot-autoを実行すればメモリによるエラーは回避できます.

参考

CentOS python-tools conflict #2921
InsecurePlatformWarning & Failed building wheel for cryptography | cffi
CentOSサーバ構築術 文具堂 スワップファイル(swap)を作成して有効にする

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2