• 安装时报错

    The json extension is missing.
    Install it or recompile php without --disable-json
    
    The phar extension is missing.
    Install it or recompile php without --disable-phar
    
    The iconv OR mbstring extension is required and both are missing.
    Install either of them or recompile php without --disable-iconv

    提示缺少json等拓展

    但我也安装了这个拓展,可是输入 php7.4 -m 却没有加载这个模块,php-fpm7.4 -m 却有加载所有模块

    原来是cli没有加载我安装的模块,ubuntu所有安装的php 模块可以在 /etc/php/7.4/mods-available 目录下找到,而fpm的conf.d目录中链接了所有的模块,cli却没有,什么原因呢我也不知道

    简单粗暴的方法是直接全部复制到cli目录下

    cp -r /etc/php/7.4/fpm/conf.d/* /etc/php/7.4/cli/conf.d

    这样cli就启用了所有模块了

    还有就是可以用 phpenmod 命令去挨个启用模块

    phpenmod json
    phpenmod iconv
    phpenmod phar

    然后安装 composer 就正常了

    curl -sS https://getcomposer.org/installer -o composer-setup.php
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer