本文介绍了Azure应用服务Linux PHP-如何添加"--with-freetype-dir =/usr/lib/x86_64-linux-gnu"到"./configure"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Azure Linux应用服务(PHP 7.3-apache)上安装Magento,并且遇到了

  • 这将重新启动您的应用程序.您可以使用 phpInfo()来确认GD扩展现在具有自由类型.

  • 注意:如果要重置配置,则可以从应用程序设置"中删除 PHP_INI_SCAN_DIR 值,这将使用默认配置重新启动容器.您还可以从您的主站点删除 ext ini 进行清理,但无论如何它们都不会加载.

    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?

    解决方案

    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:

    1. Create two folders in your /home directory to persist the extension and the customized php INI files:

      mkdir /home/site/ext /home/site/ini
      

    2. 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/
      

    3. Copy the generated extension to this folder:

      cp /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so /home/site/ext
      

    4. 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
      

    5. 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).

    6. This will restart your Application. You can use phpInfo() toconfirm 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.

    这篇关于Azure应用服务Linux PHP-如何添加"--with-freetype-dir =/usr/lib/x86_64-linux-gnu"到"./configure"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-05 19:40