I’m trying to install Magento on Azure Linux App Service (PHP 7.3-apache) and I ran into this error:
Image CAPTCHA requires FT fonts support
Apparently the libfreetype6-dev
despite being installed in the underlying container (at /usr/lib/x86_64-linux-gnu
) are not loaded by PHP.
Basically, the solution proposed by the other StackOverflow answer is to reconfigure and recompile PHP. To reconfigure you must run the ./configure
command with the flag --with-freetype-dir=/usr/lib/x86_64-linux-gnu
.
According to the info.php
most likely the right commands I will need to run will be:
./configure
--build=x86_64-linux-gnu
--with-config-file-path=/usr/local/etc/php
--with-config-file-scan-dir=/usr/local/etc/php/conf.d
--enable-option-checking=fatal
--with-mhash
--enable-ftp
--enable-mbstring
--enable-mysqlnd
--with-password-argon2
--with-sodium=shared
--with-pdo-sqlite=/usr
--with-sqlite3=/usr
--with-curl
--with-libedit
--with-openssl
--with-config-file-scan-dir=/usr/local/etc/php/conf.d
--with-zlib
--with-libdir=lib/x86_64-linux-gnu
--with-apxs2
--with-freetype-dir=/usr/lib/x86_64-linux-gnu
--disable-cgi build_alias=x86_64-linux-gnu
make && make install
service apache2 reload
Unfortunately, I am not sure on how to do this within the container. I found a blog that suggests that I should use the docker tools to do so. But all I can see is how to update gd extension which doesn’t seem to work for my case:
docker-php-ext-configure gd –with-freetype-dir=/usr/lib/x86_64-linux-gnu”
Also the container has the following commands that probably could help:
docker-php-entrypoint docker-php-ext-enable docker-php-source
docker-php-ext-configure docker-php-ext-install
Any clues on how to accomplish this?
2
Answers
I've figured it out thanks to Toan Nguyen post.
You don't need to recompile php.
It's sufficient to add the
libfreetype
to your GD configuration. What wasn't obvious was the fact that because the container only persists/home
you need to create an app setting in the portal to override all the previous PHP INI configuration.Here are the steps needed to be run in the SSH web interface Azure portal has:
Create two folders in your
/home
directory to persist the extension and the customized php INI files:Run the docker command to reconfigure GD extension using freetype (takes some time):
It will return the place where your ext was generated, something like this:
Copy the generated extension to this folder:
Move all the INI files to your new INI folder. Remove the old GD reference and add a new one:
Finally, update the app setting in Azure Portal to include your new INI folder. Add an app seting with Name:
PHP_INI_SCAN_DIR
and value/home/site/ini
(This will override all the previous INI files).This will restart your Application. You can use
phpInfo()
to confirm that the GD extension now has freetype.Note: If you want to reset the configuration you can just delete the
PHP_INI_SCAN_DIR
value from App Settings and that will restart the container with the default configuration. You can in addition deleteext
andini
from your home site to clean up but they won't be loaded anyway.I have to put it here, because I get too much trouble with this. I followed Bruno Medina instructions, but if you see the GD info, he don’t have JPEG Support. Here is what I did to solve that problem:
Install Freetype:
Create two folders in your /home directory to persist the extension and the customized php INI files:
Move installed freetype to /home/site/freetype from /usr/lib/x86_64-linux-gnu, because outside home files are not persistent:
Run the docker command to reconfigure GD extension using freetype with the new directory and including JPEG Support and WebP Support.
Copy the generated extension to this folder:
Move all the INI files to your new INI folder. Remove the old GD reference and add a new one:
Finally, update the app setting in Azure Portal to include your new INI folder. Add an app setting with Name: PHP_INI_SCAN_DIR and value /home/site/ini:
This is the final Result, with JPEG Support enabled: