PHPのエクステンションを開発する際にPHPをソースからビルドする必要があったので手順メモ。
DBA関数でgdbmやdb4(Berkeley DB 4)を有効にしたかったがdb4はaptでインストールできなかったためソースからビルド。
ちなみに依存するライブラリが足りないと下記のようなエラーが出る。
onfigure: error: DBA: Could not find necessary header file(s)
具体的な手順は下記。
sudo apt install -y valgrind
sudo apt install -y bison re2c pkg-config libxml2-dev libxml++2.6-dev libsqlite3-dev
sudo apt install -y libdb-dev libdb++-dev libdb5.3-dev libgdbm-dev liblmdb-dev tdb-dev libgdbm-compat-dev
# build berkeley db 4.x
wget http://download.oracle.com/berkeley-db/db-4.8.30.zip
unzip db-4.8.30.zip
cd db-4.8.30
cd build_unix/
../dist/configure
make -j4
sudo make install
cd ../../
# build php7.4
git clone https://github.com/php/php-src.git -b php-7.4.11
cd php-src
./buildconf --force
./configure --prefix /usr/local/php74_dev --enable-debug --enable-maintainer-zts --enable-cgi --enable-cli --enable-dba --with-gdbm=/usr --with-db4=/usr --with-lmdb=/usr
make -j4
sudo make install
参考
https://cryptoandcoffee.com/mining-gems/install-berkeley-4-8-db-libs-on-ubuntu-16-04/