reeze / php-leveldb

The PHP Binding for LevelDB
Other
239 stars 44 forks source link

Fatal error: Class 'LevelDB' not found #11

Closed rjonesx closed 10 years ago

rjonesx commented 11 years ago

I am at a loss here...

I followed the installation instructions and encountered no errors. The "make test" was successful, but for some reason I get the following error every time I try to use...

$db = new LevelDB("location");

Fatal error: Class 'LevelDB' not found in /var/www/html/test.php on line 27

Am I missing an include?

rjonesx commented 11 years ago

More information...

  1. The tests have worked perfectly, I have attached the results at the very bottom...
  2. phpinfo() does not indicate that leveldb is installed... (http://198.101.8.230/phpinfo.php)
  3. LevelDB is correctly in the /usr/lib64/php/modules/leveldb.so folder
  4. Other .so in that folder are being dynamically included

Any ideas?

All relevant info I can provide is below:

Running PHP 5.3.3 on x64 architecture Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64

Running CentOS cat /proc/version: Linux version 2.6.32-358.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Fri Feb 22 00:31:26 UTC 2013

Test Results:

PHP : /usr/bin/php PHP_SAPI : cli PHP_VERSION : 5.3.3 ZEND_VERSION: 2.3.0 PHP_OS : Linux - Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 INI actual : /var/www/html/php-leveldb/tmp-php.ini More .INIs : CWD : /var/www/html/php-leveldb Extra dirs :

VALGRIND : Not used

TIME START 2013-11-25 13:55:37

PASS leveldb - basic: get(), set(), put(), delete() [tests/001-basic.phpt] PASS leveldb - db management [tests/002-db-management.phpt] PASS leveldb - open base dir [tests/003-openbasedir.phpt] PASS leveldb - write batch [tests/004-write-batch.phpt] PASS leveldb - iterate thought db [tests/005-iterator.phpt] PASS leveldb - iterate thought db by foreach [tests/006-iterator-foreach.phpt] PASS leveldb - db close [tests/007-db-close.phpt] PASS leveldb - options open options [tests/008-options.phpt] PASS leveldb - custom comparator [tests/009-comparator.phpt] PASS leveldb - compression [tests/010-compression.phpt] PASS leveldb - getApproximateSizes [tests/011-getApproximateSizes.phpt] PASS leveldb - getProperty [tests/012-getProperty.phpt] PASS leveldb - compactRange [tests/013-compactRange.phpt] PASS leveldb - iterator destroy [tests/014-iterator-destroy.phpt] PASS leveldb - Fixed bug segfault when double construct iterator [tests/015-double-iterator.phpt] PASS leveldb - different iterators should not affect each other [tests/016-different-iterators-should-differ.phpt] PASS leveldb - LevelDB::getIterator() [tests/017-db-getIterator.phpt] PASS leveldb - snapshot [tests/018-snapshot.phpt] PASS leveldb - NULL comparator should not throw exception [tests/019-null-comparator.phpt]

PASS leveldb - NULL snapshot should not throw exception [tests/020-null-snapshot.phpt]

TIME END 2013-11-25 13:55:41

TEST RESULT SUMMARY

Exts skipped : 0

Exts tested : 29

Number of tests : 20 20 Tests skipped : 0 ( 0.0%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 0 ( 0.0%) ( 0.0%) Expected fail : 0 ( 0.0%) ( 0.0%)

Tests passed : 20 (100.0%) (100.0%)

Time taken : 4 seconds

rjonesx commented 11 years ago

found something really weird...

phpinfo() run via apache shows no leveldb phpinfo() run via command line does.

2072 commented 11 years ago

This is probably a php.ini issue. Check which PHP ini is loaded in phpinfo()'s output.

rjonesx commented 11 years ago

both say /etc/php.ini

rjonesx commented 11 years ago

totally weird

hwde commented 11 years ago

Dumb question: you have reloaded the webserver (i.e. apachectl graceful) ?

rjonesx commented 11 years ago

Not a dumb question but, yes, multiple times. Rebooted the server, Reinstalled everything about 60 times. totally. weird.

hwde commented 11 years ago

I assume you looked at the error_log of the webserver too (tail -f path_to_error_log, i.e. /var/log/apache2/error_log) while restarting the apache?

2072 commented 11 years ago

Make sure that you have an error_log defined in your php.ini also check your extension_dir setting:

example:

error_log = "/path/php_errors.log"

extension_dir = "/path/php/extensions/no-debug-non-zts-20090626"

rjonesx commented 11 years ago

Thank you for your continued help. Both versions (http://198.101.8.230/phpinfo.php) and command line have the same extension directory set. Ill make sure that php errors are logged too.

rjonesx commented 11 years ago

Now we are getting somewhere!

[26-Nov-2013 06:22:42] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/leveldb.so' - libleveldb.so.1: failed to map segment from shared object: Permission denied in Unknown on line 0

reeze commented 10 years ago

This seems related to apache's startup user, does the user have access right to the liblevdbldb.so.1? or maybe SElinux related: http://www.xcnetwork.com/selinux-prevents-apache-from-starting-mod_jk.jsp

please check out which user apache run as. and try:

$ ldd /usr/lib64/php/modules/leveldb.so
to find out where is your libleveldb.so 
$  ll /path/to/your/libleveld.so
rjonesx commented 10 years ago

Crazy. I am on a completely different server now, also using CentOS 64 bit and have the exact same problem.

I turned off selinux and then changed ownership to apache:apache and that seemed to work. crossing my fingers.

thanks for your excellent work!

reeze commented 10 years ago

Good :)