Monday, June 29, 2020

Upgrading PHP7 in AWS EC2 Instance

We followed following steps to upgrade our PHP version from 5.6 to 7.3

Step 1   

First need to search which PHP 7 version is available as part of AWS package by using following command

sudo yum search  php7

 

This will list all available PHP7 packages. Choose one and Install

 

Step 2

 To Install PHP use following command. The following command will install PHP7.3

sudo yum install php73

      Step 3

 Install necessary extensions as follows

sudo yum install php73-opcache php73-mysqlnd php73-gd php73-bcmath php73-mbstring php73-pdo php73-soap

 

Step 4

If you are installing fresh PHP no need to do this step, if are using already previous version of PHP and trying to install, then this step is required.  Run the following command to select Proper php version

    alternatives --config php

Saturday, June 27, 2020

Changing AWS instance type from M4 to M5 (Ena)

We cannot directly convert our instance from M4 to M5 as new instances are provided with enhanced networking capabilities through ENA (Elastic network Adapter).

If we have to convert, first we need to enable ENA support in M4 and then it will allow us to change M5 instance type.

To enable ENA we need to follow steps.

 

1.       Needs to stop the existing M4 instance.

Note: If instance is under Auto scaling group (ASG) and if we try to stop the instance automatically will get terminated. To Avoid, take the AMI of the instance and launch the instance using AMI outside ASG and follow the following step. Once ENA is enabled take another AMI and create launch configuration using M5 instance type and update the ASG with launch configuration

 

2.       Get the Instance Id of stopped instance.

 

3.       Run the following command to enable ENA. 

Note: To run this command you can use another active instance and also you should have proper role access to do.

 

aws ec2 modify-instance-attribute --instance-id <<instance Id>> --ena-support --region <<Region>>

 

4.       To Check you can use following command

aws ec2 describe-instances --instance-ids << instance Id>> --query "Reservations[].Instances[].EnaSupport" --region <<Region>>

 

5.       Change the instance type from Action->Instance Settings option

 

6.       Start the instance

You can refer following document for more details

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-resize.html

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking-ena.html


Wkhtmltopdf Letter spacing issue (Bad Kerning)

When we are using smaller font in the document and trying convert to PDF the letter spacing is completely broken.

It will too visible when we use Arial font. We tried lot of way, finally we found a solution by

By creating a 10-wkhtmltopdf.conf inside /etc/fonts/conf.d/ with following content

<?xml version='1.0'?>

<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>

<fontconfig>

 <match target="font">

  <edit mode="assign" name="rgba">

   <const>rgb</const>

  </edit>

 </match>

 <match target="font">

  <edit mode="assign" name="hinting">

   <bool>true</bool>

  </edit>

 </match>

 <match target="font">

  <edit mode="assign" name="hintstyle">

   <const>hintslight</const>

  </edit>

 </match>

 <match target="font">

  <edit mode="assign" name="antialias">

   <bool>true</bool>

  </edit>

 </match>

  <match target="font">

    <edit mode="assign" name="lcdfilter">

      <const>lcddefault</const>

    </edit>

  </match>

</fontconfig>

Following link helped us to resolve this issue

https://html.developreference.com/article/17386238/letter-spacing+is+too+large+with+wkhtmltopdf

https://github.com/kisenka/docker-kotlin-website/blob/master/scripts/10-wkhtmltopdf.conf