问题
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?
回答1:
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:mkdir /home/site/ext /home/site/ini
Run the docker command to reconfigure GD extension using freetype (takes some time):
docker-php-ext-configure gd --with-freetype-dir=/usr/lib/x86_64-linux-gnu && docker-php-ext-install -j$(nproc) gd
It will return the place where your ext was generated, something like this:
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/
Copy the generated extension to this folder:
cp /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so /home/site/ext
Move all the INI files to your new INI folder. Remove the old GD reference and add a new one:
cp /usr/local/etc/php/conf.d/* /home/site/ini rm -rf docker-php-ext-gd.ini echo “extension=/home/site/ext/gd.so” » extensions.ini
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 delete ext
and ini
from your home site to clean up but they won't be loaded anyway.
回答2:
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:
cd / apt-get install freetype* apt-get install libwebp-dev
Create two folders in your /home directory to persist the extension and the customized php INI files:
mkdir /home/site/ext /home/site/ini /home/site/freetype
Move installed freetype to /home/site/freetype from /usr/lib/x86_64-linux-gnu, because outside home files are not persistent:
cp -r /usr/lib/x86_64-linux-gnu/* /home/site/freetype
Run the docker command to reconfigure GD extension using freetype with the new directory and including JPEG Support and WebP Support.
docker-php-ext-configure gd --with-freetype-dir=/home/site/freetype/libfreetype.so --with-jpeg-dir=/home/site/freetype/libjpeg.so --with-webp-dir=/home/site/freetype/libwebp.so && docker-php-ext-install -j$(nproc) gd
Copy the generated extension to this folder:
cp /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so /home/site/ext
Move all the INI files to your new INI folder. Remove the old GD reference and add a new one:
cp /usr/local/etc/php/conf.d/* /home/site/ini rm -rf /home/site/ini/docker-php-ext-gd.ini rm -rf /home/site/ini/extensions.ini echo "extension=/home/site/ext/gd.so" >> /home/site/ini/extensions.ini
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:
来源:https://stackoverflow.com/questions/60918752/azure-app-service-linux-php-how-to-add-with-freetype-dir-usr-lib-x86-64-li