Join the community today
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

    42,015
    9,474
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,580
    Local Time:
    4:29 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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
    • Informative Informative x 1
  2. eva2000

    eva2000 Administrator Staff Member

    42,015
    9,474
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,580
    Local Time:
    4:29 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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