从源代码编译安装PHP8
此处以Ubuntu 21.04 为例。
此文仅描述编译安装过程,不含配置等过程。
- 安装必要的依赖
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
- 配置、编译、安装
注意:由于—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
- 编译或配置过程中遇到的依赖解决:
- configure: error: Cannot find sys/sdt.h which is required for DTrace support
sudo apt install systemtap-sdt-dev
- configure: error: Package requirements (krb5-gssapi krb5) were not met
sudo apt install krb5-multidev libkrb5-dev
- configure: error: Package requirements (openssl >= 1.0.1) were not met
sudo apt install libssl-dev
- configure: error: Package requirements (sqlite3 > 3.7.4) were not met
sudo apt install libsqlite3-dev
- configure: error: Please reinstall the BZip2 distribution
sudo apt install libbz2-dev
- configure: error: Package requirements (libcurl >= 7.29.0) were not met
sudo apt install libcurl4-openssl-dev
- configure: error: Package requirements (enchant >= 1.4.2) were not met
sudo apt install libenchant-2-dev
- configure: error: GNU MP Library version 4.2 or greater required
sudo apt install libgmp-dev
- 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
- configure: error: Cannot find ldap.h
sudo apt install libldap2-dev
- configure: error: Package requirements (libsasl2) were not met
sudo apt install libsasl2-dev
- configure: error: Package requirements (oniguruma) were not met
sudo apt install libonig-dev
- configure: error: Package requirements (odbc) were not met
sudo apt install unixodbc-dev
- configure: error: Cannot find pspell
sudo apt install libpspell-dev
- configure: error: Package requirements (libedit) were not met
sudo apt install libedit-dev
- configure: error: cannot find mm library
- 从 ftp://ftp.ossp.org/pkg/lib/mm/mm-1.4.2.tar.gz 下载文件,可通过uget等工具进行下载。或从下方下载。
- 编译安装mm
tar -C ~/builds -zxvf mm-1.4.2.tar.gz cd ~/builds/mm-1.4.2 ./configure make -j$(nproc) sudo make install
- mm-1.4.2.tar.gz附件:
mm-1.4.2.tar.gz
- configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation
sudo apt install libsnmp-dev
- configure: error: Package requirements (libsodium >= 1.0.8) were not met
sudo apt install libsodium-dev
- configure: error: Please ensure the argon2 header and library are installed
sudo apt install libargon2-dev
- configure: error: Cannot find libtidy
sudo apt install libtidy-dev
- configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met
sudo apt install libzip-dev
- configure: error: Package requirements (libwebp) were not met
sudo apt install libwebp-dev
- configure: error: Cannot find sys/sdt.h which is required for DTrace support