Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP-FPM Insight Guide Enabling PHP Fileinfo extension module

Discussion in 'Centmin Mod Insights' started by eva2000, May 25, 2014.

Tags:
  1. eva2000

    eva2000 Administrator Staff Member

    55,235
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:56 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    By default Centmin Mod will install PHP with Fileinfo disabled if it detects less than 530,000 bytes of memory available. You can lower this threshold in order to compile PHP with Fileinfo enabled.

    If using vps with less than 530,000 bytes of memory and want to enable PHP Fileinfo, change and edit ISLOWMEMPHP variable on line 7 in inc/php_configure.inc to a lower value than your total physical memory available in bytes https://github.com/centminmod/centminmod/blob/master/inc/php_configure.inc#L7 and then run menu option #5 to recompile PHP

    Code:
    #############################################################
    TOTALMEM=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
    ISLOWMEMPHP='530000'
    #############################################################


     
    Last edited: May 25, 2014
  2. eva2000

    eva2000 Administrator Staff Member

    55,235
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:56 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    It seems that php fileinfo extension that is bundled in PHP itself can be compiled/installed standalone rather that at time of PHP compile with persistent config file set PHPFINFO='y' variable with centmin.sh menu option 5 and that standalone install may use less memory to allow lower memory based VPS servers the ability to install php fileinfo extension.

    • The below SSH commands will get the existing PHP_VERSION number from php-config, go into PHP version's ext/fileinfo directory and install php fileinfo extension and setup fileinfo .ini file at /etc/centminmod/php.d/fileinfo.ini and then restart php-fpm and check fileinfo is loaded.
    • If PHP was already installed via centmin.sh menu option 5 with PHPFINFO='y' set, then the fileinfo extension is already loaded and doesn't need this standalone php fileinfo extension install loaded at /etc/centminmod/php.d/fileinfo.ini, so comment it out in /etc/centminmod/php.d/fileinfo.ini so it doesn't load twice and restart php-fpm and recheck fileinfo is loaded.
    Code (Text):
    PHP_VERSION=$(php-config --version)
    cd /svr-setup/php-${PHP_VERSION}/ext/fileinfo
    make clean; phpize; ./configure --with-php-config=/usr/local/bin/php-config; make -j$(nproc); make install
    echo 'extension=fileinfo.so' > /etc/centminmod/php.d/fileinfo.ini
    fpmrestart; php --ri fileinfo
    if [[ "$(php --ri fileinfo 2>&1 | grep 'already loaded')" ]]; then echo ';extension=fileinfo.so' > /etc/centminmod/php.d/fileinfo.ini; fpmrestart; php --ri fileinfo; fi
    
     
    Last edited: Feb 28, 2019
  3. Kintaro

    Kintaro Member

    106
    11
    18
    Dec 2, 2016
    Italy
    Ratings:
    +30
    Local Time:
    5:56 PM
    1.15.x
    MariaDB 10
    is standalone preferred over re-compiling php as it use less ram or do you suggest standalone for low memory server only?
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,235
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:56 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Practically the same end result AFAIK. But may use less memory
     
  5. eva2000

    eva2000 Administrator Staff Member

    55,235
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:56 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+