AWS – Install Certbot Nginx on Amazon Linux AMI

amazon ec2amazon-linuxcertbot

i have a really old amazon linux ami in which i need to install certbot for my nginx which is running a php website. Now i need to install ssl on this website. But i cannot install certbot-nginx on my server. whenever i try to install

sudo yum install python2-certbot-nginx.noarch

it shows me some dependency error. Like this at the end

--> Processing Dependency: python-requests >= 2.6.0 for package: python2-requests-2.6.0-0.el7.noarch
---> Package python2-six.noarch 0:1.9.0-0.el7 will be installed
--> Processing Dependency: python-six >= 1.9.0 for package: python2-six-1.9.0-0.el7.noarch
---> Package setools-libs.x86_64 0:3.3.7-34.23.amzn1 will be installed
--> Finished Dependency Resolution
Error: Package: python2-requests-2.6.0-0.el7.noarch (epel)
           Requires: python-requests >= 2.6.0
           Installed: python26-requests-1.2.3-5.10.amzn1.noarch (@amzn-main)
               python-requests = 1.2.3-5.10.amzn1
Error: Package: python2-acme-1.11.0-1.el7.noarch (epel)
           Requires: python2-cryptography
Error: Package: python2-acme-1.11.0-1.el7.noarch (epel)
           Requires: pyOpenSSL >= 0.13.1
           Installing: python26-pyOpenSSL-0.10-2.8.amzn1.x86_64 (amzn-main)
               pyOpenSSL = 0.10-2.8.amzn1
Error: Package: python2-acme-1.11.0-1.el7.noarch (epel)
           Requires: python2-pyasn1
Error: Package: certbot-1.11.0-1.el7.noarch (epel)
           Requires: systemd
Error: Package: python2-six-1.9.0-0.el7.noarch (epel)
           Requires: python-six >= 1.9.0
           Installed: python26-six-1.8.0-1.23.amzn1.noarch (@amzn-main)
               python-six = 1.8.0-1.23.amzn1
Error: Package: python2-josepy-1.3.0-2.el7.noarch (epel)
           Requires: python2-setuptools
Error: Package: python2-josepy-1.3.0-2.el7.noarch (epel)
           Requires: python2-cryptography
Error: Package: python2-certbot-1.11.0-1.el7.noarch (epel)
           Requires: python2-cryptography >= 1.2.3
Error: Package: python2-acme-1.11.0-1.el7.noarch (epel)
           Requires: pyOpenSSL >= 0.13.1
           Available: python26-pyOpenSSL-0.10-2.8.amzn1.x86_64 (amzn-main)
               pyOpenSSL = 0.10-2.8.amzn1
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

i have tried installing yum-utils and package-cleanup --leaves but still the following error shows up. Can anyone tell me how to prevent this issue? thanks.
btw my servers os-release

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

Can anyone help me with this? I think if I could remove all these dependencies issues than I could install the python2-certbot-nginx and i could do ssl. Any help can i get? Thanks in advance.

Best Answer

I also faced similar issue a few months back in Amazon linux. Fixed this by installing certbot via pip. The commands that I used:

pip install virtualenv
virtualenv ~/.certbot
source ~/.certbot/bin/activate
pip install 'setuptools<41'
pip install certbot
pip install 'parsedatetime<2.6'

Now simply generate the certificate by issuing below command

sudo ~/.certbot/bin/certbot certonly --webroot -w /usr/share/nginx/html/example -d example.com