从源代码编译安装PHP8

如此文无法正常查看,可查看博客园

此处以Ubuntu 21.04 为例。
此文仅描述编译安装过程,不含配置等过程。

  1. 安装必要的依赖
    sudo apt install libsystemd-dev libacl1-dev libapparmor-dev valgrind libdmalloc-dev systemtap-sdt-dev krb5-multidev libkrb5-dev libssl-dev libsqlite3-dev libbz2-dev libcurl4-openssl-dev libenchant-2-dev libgmp-dev libc-client2007e-dev libldap2-dev libsasl2-dev libonig-dev unixodbc-dev libpspell-dev libedit-dev libsnmp-dev libsodium-dev libargon2-dev libtidy-dev libzip-dev libwebp-dev
    
  2. 配置、编译、安装

    注意:由于—enable-mm和—enable-zts冲突,两者无法同时使用。下方为启用zts但为启用mm的配置方法。关于mm的安装可以参照3.16。

    ./configure --prefix=/usr/local/php/$(basename $(pwd)) --enable-re2c-cgoto --enable-fpm --with-fpm-systemd --with-fpm-acl --with-fpm-apparmor --enable-fuzzer-msan --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-phpdbg-readline --with-valgrind --enable-gcov --enable-debug --enable-debug-assertions --enable-zts --enable-rtld-now --enable-sigchild --enable-libgcc --enable-dtrace --enable-fd-setsize=1024 --with-openssl --with-kerberos --with-system-ciphers --with-external-pcre --with-pcre-jit --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-dba --with-enchant --enable-exif --with-ffi --enable-ftp --enable-gd --with-external-gd --with-webp --with-jpeg --with-xpm --with-freetype --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --with-imap --with-kerberos --with-imap-ssl --enable-intl --with-ldap --with-ldap-sasl --enable-mbstring --with-mysqli --with-mysql-sock --with-unixODBC --enable-pcntl --with-pdo-mysql --with-zlib-dir --with-pspell --with-libedit --with-readline --enable-shmop --with-snmp --enable-soap --enable-sockets --with-sodium --with-password-argon2 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --with-expat -with-xsl --enable-zend-test --with-zip --enable-mysqlnd --with-pear --with-gnu-ld
    make -j$(nproc)
    sudo make install
    
  3. 编译或配置过程中遇到的依赖解决:
    1. configure: error: Cannot find sys/sdt.h which is required for DTrace support
      sudo apt install systemtap-sdt-dev
      
    2. configure: error: Package requirements (krb5-gssapi krb5) were not met
      sudo apt install krb5-multidev libkrb5-dev 
      
    3. configure: error: Package requirements (openssl >= 1.0.1) were not met
      sudo apt install libssl-dev
      
    4. configure: error: Package requirements (sqlite3 > 3.7.4) were not met
      sudo apt install libsqlite3-dev
      
    5. configure: error: Please reinstall the BZip2 distribution
      sudo apt install libbz2-dev
      
    6. configure: error: Package requirements (libcurl >= 7.29.0) were not met
      sudo apt install libcurl4-openssl-dev
      
    7. configure: error: Package requirements (enchant >= 1.4.2) were not met
      sudo apt install libenchant-2-dev
      
    8. configure: error: GNU MP Library version 4.2 or greater required
      sudo apt install libgmp-dev
      
    9. configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information
      sudo apt install libc-client2007e-dev
      
    10. configure: error: Cannot find ldap.h
      sudo apt install libldap2-dev
      
    11. configure: error: Package requirements (libsasl2) were not met
      sudo apt install libsasl2-dev
      
    12. configure: error: Package requirements (oniguruma) were not met
      sudo apt install libonig-dev
      
    13. configure: error: Package requirements (odbc) were not met
      sudo apt install unixodbc-dev
      
    14. configure: error: Cannot find pspell
      sudo apt install libpspell-dev
      
    15. configure: error: Package requirements (libedit) were not met
      sudo apt install libedit-dev
      
    16. configure: error: cannot find mm library
      1. 从 ftp://ftp.ossp.org/pkg/lib/mm/mm-1.4.2.tar.gz 下载文件,可通过uget等工具进行下载。或从下方下载。
      2. 编译安装mm
        tar -C ~/builds -zxvf mm-1.4.2.tar.gz
        cd ~/builds/mm-1.4.2
        ./configure
        make -j$(nproc)
        sudo make install
        
      3. mm-1.4.2.tar.gz附件:
        mm-1.4.2.tar.gz
    17. configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation
      sudo apt install libsnmp-dev
      
    18. configure: error: Package requirements (libsodium >= 1.0.8) were not met
      sudo apt install libsodium-dev
      
    19. configure: error: Please ensure the argon2 header and library are installed
      sudo apt install libargon2-dev
      
    20. configure: error: Cannot find libtidy
      sudo apt install libtidy-dev
      
    21. configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met
      sudo apt install libzip-dev
      
    22. configure: error: Package requirements (libwebp) were not met
      sudo apt install libwebp-dev
      
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值