You can install leveldb from repository
sudo apt-get install libleveldb-dev
sudo apt install php-dev
git clone https://github.com/reeze/php-leveldb.git
cd php-leveldb
./configure --with-leveldb=~/leveldb.*.*
make
make install
After run make install
, your output should be similar as following:
/usr/lib/php/20190902/leveldb.so
By default, laravel is using the php.ini of cli version. Meanwhile, apache2 is using its own php.ini.
php --ini
//output: Loaded Configuration File: /etc/php/7.4/cli/php.ini (cli version)
the php.ini for apache2 can be found at /etc/php/7.4/apache2/php.ini
Open the php.ini with your favorite editor and add the following to it:
extension=leveldb.so
If you are using apache2 instead of php artisan serve, remember to reload your apache2 server with the following command
sudo systemctl restart apache2
You can now use leveldb in your project as the following example:
<?php
$db = new LevelDB('./', $options, $readOptions, $writeOptions);