Tag: CentOS

Renewing Let’s Encrypt certificate

Have the following command setup in my crontab to renew the certificate for this blog, and for the main website – thecurlybraces.com

30 3 1 */2 *  /opt/letsencrypt/certbot-auto renew --pre-hook "" --post-hook "service nginx restart"

This causes the command to run, at 03:30 on day-of-month 1 in every 2nd month.

Output

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/thecurlybraces.com.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for thecurlybraces.com
http-01 challenge for blog.thecurlybraces.com
Waiting for verification...
Cleaning up challenges

-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/thecurlybraces.com/fullchain.pem
-------------------------------------------------------------------------------

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/thecurlybraces.com/fullchain.pem (success)
Running post-hook command: service nginx restart

Incase you want to add more domains to an existing certificate, use the following command –

sudo /opt/letsencrypt/certbot-auto --expand -d blog.thecurlybraces.com -d thecurlybraces.com -d bitsnpieces.thecurlybraces.com --pre-hook "" --post-hook "service nginx restart"

This assumes that you have only a single certificate. If you’ve more, you’ll have to use --cert-name. Read more here.

Just putting this here for reference, and with the hope that it might be useful for someone else.

get_results PHP function not working on CentOS

There are instances where the PHP function – get_results will not work on CentOS (this maybe the case with other Linux based operating systems as well). I faced this issue while deploying a project on CentOS which was originally developed on Windows. All my INSERT, UPDATE and DELETE database statements were working properly, but bulk SELECTstatements had issues. Closer inspection narrowed down the problem to the get_results function.

I came across this on the get_results PHP documentation page –

MySQL Native Driver Only
Available only with mysqlnd.

I was able to determine if mysqlnd driver was installed using this post on StackOverflow as reference. As expected, it wasn’t.

Here’s the relevant php code from the StackOverflow post –

<?php
$mysqlnd=function_exists('mysqli_fetch_all');
if($mysqlnd) {
   echo 'mysqlnd enabled!';
}

Now that I new that we needed to install the mysqlnd driver, here are the steps that I followed to get the mysqlnd driver working on CentOS,

// First remove the existing MySQL driver
yum --enablerepo=remi,remi-test remove php-mysql

// Then go ahead and install mysqlnd
yum --enablerepo=remi,remi-test install php-mysqlnd

// Restart httpd
/sbin/service httpd restart

// If you have phpMyAdmin, re-install it so that it uses the new MySQL driver
yum remove phpMyAdmin
yum install phpMyAdmin

After installing the mysqlnd driver the get_results function worked just fine.