Let’s be quick and clear. If you’re here, you don’t need a preface for Let’s Encrypt. You probably know how awesome it is. So today I’ll show you guys how to quickly and easily setup let’s encrypt in your cPanel server, and install SSL certificates for your domains with ease. Please note that you need a dedicated server/VPS for this. Shared hosting is not supported. So, let’s get started

### Setting up Let’s Encrypt

#### For Centos 6.x

The thing about CentOs 6.x is it comes with Python 2.6 where as Let’s Encrypt supports Python 2.7+ only. But, installing Python 2.7 in Centos 6.x is pretty simple.

##### Installing Python 2.7 in cPanel ( Centos 6.x )

This step is only for Centos 6.x only

# Install Epel Repository yum install epel-release

# Install IUS Repository

rpm -ivh https://rhel6.iuscommunity.org/ius-release.rpm

# Install Python 2.7 and Git

yum –enablerepo=ius install git python27 python27-devel python27-pip python27-setuptools python27-virtualenv -y


Make sure that the installation was successful.

which python2.7

# The above command should display : /usr/bin/python2.7

So , now we know that Python 2.7 is installed properly.

#### The following steps are common for CentOs 6.x and 7.x

# Install Git
yum -y install git

cd /root

# Clone the letsencrypt Repo

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt

# Run the letsencrypt script
./letsencrypt-auto --verbose

This will take  a few minutes. At the end, you will probably receive a message like _"No installers are available on your OS yet"_

That's it, you're ready to retrieve SSL certificates for your domains. Issue the following command to retrieve an SSL certificate for your domain "example.com"

> Note: I have made a simple php script to automate the installation and retrieval of SSL certificates, feel free to skip to that part

./letsencrypt-auto --text --agree-tos --email [email protected] certonly --renew-by-default --webroot --webroot-path /home/username/public_html/ -d example.com -d www.example.com

It's pretty simple, isn't? Now, you will receive something like the following

> Congratulations! Your certificate and chain have been saved at

> expire on 2016-04-08. To obtain a new version of the certificate in

> the future, simply run Let's Encrypt again.

You can find your certificate and key under /etc/letsencrypt/live/example.com/.

Now you have to install the certificates from the cPanel/WHM interface.

#### Automating SSL certificate installation in cPanel

So I have made a simple PHP script which will do the job for you. Copy the below and save it as "letsencrypt-cpanel.php" Simply run the script in the server itself ( php letsencrypt-cpanel.php ), enter the domain name, email address and username for the domain and it will install the SSL certificate for you. You don't have to manually install the certificates.

Before running the below script, make sure that you have the cPanel access hash. Issue the command

cat /root/.accesshash


It should display a random string. If it does not, login as root in WHM, and search for “Remote Access”, and click on it. Now it should generate the access hash. You can verify it by running the above command. Once you have made sure that the accesshash is generated, you can use the script.

Please note that I have not added any error catching, so if there is any error in the submitted data, you will probably get some weird error. I’ll try to add proper error handling in the future. You can find the latest version of the script Here