Linux – Installing GnuPG extension for PHP

apache-2.2debianlinuxPHP

System: Amazon EC2 instance running Debian 5.0.1 with Apache 2 and PHP 5.2.6

I need to send encrypted files using a PHP script. I had been intending to do this with command line instructions from the script(e.g. exec()), but have discovered that there is a PHP extension for GnuPG. I installed it using the steps provided in this walkthrough, although I've used the newest versions of the packages mentioned (libgpg-error-1.10, gpgme-1.3.1 and gnupg-1.3.2). When I get to the 'make' step of the gnupg-1.3.2 installation I am told to run 'make test'. When I do, I get the following errors / warnings:

PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/curl.so' - modules/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/curl.so' - modules/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/mcrypt.so' - modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mcrypt.so' - modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/mysql.so' - modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mysql.so' - modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/mysqli.so' - modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mysqli.so' - modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/gnupg.so' - libgpgme.so.11: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/gnupg.so' - libgpgme.so.11: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/curl.so' - modules/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/curl.so' - modules/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/mcrypt.so' - modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mcrypt.so' - modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/mysql.so' - modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mysql.so' - modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/mysqli.so' - modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mysqli.so' - modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo.so' - modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_mysql.so' - modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/gnupg.so' - libgpgme.so.11: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/gnupg.so' - libgpgme.so.11: cannot open shared object file: No such file or directory in Unknown on line 0

=====================================================================
PHP         : /usr/bin/php
PHP_SAPI    : cli
PHP_VERSION : 5.2.6-1+lenny13
ZEND_VERSION: 2.2.0
PHP_OS      : Linux - Linux ip-10-235-58-131 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64
INI actual  : /etc/php5/cli/php.ini
More .INIs  : /etc/php5/cli/conf.d/curl.ini,/etc/php5/cli/conf.d/gd.ini,/etc/php5/cli/conf.d/gnupg.ini,/etc/php5/cli/conf.d/mcrypt.ini,/etc/php5/cli/conf.d/mysql.ini,/etc/php5/cli/conf.d/mysqli.ini,/etc/php5/cli/conf.d/pdo.ini,/etc/php5/cli/conf.d/pdo_mysql.ini
CWD         : /var/apache2/sites/gnupg-1.3.2
Extra dirs  :
=====================================================================
Running selected tests.
SKIP import a new key into the keyring [tests/gnupg_oo_0001_import.phpt]
SKIP encrypt and decrypt a text [tests/gnupg_oo_encrypt.phpt]
SKIP encryptsign and decryptverify a text [tests/gnupg_oo_encryptsign.phpt]
SKIP export a key [tests/gnupg_oo_export.phpt]
SKIP get keyinfo [tests/gnupg_oo_keyinfo.phpt]
SKIP list signatures [tests/gnupg_oo_listsignatures.phpt]
SKIP sign a text with sigmode SIG_MODE_CLEAR [tests/gnupg_oo_sign_clear.phpt]
SKIP sign a text with mode SIG_MODE_DETACH [tests/gnupg_oo_sign_detach.phpt]
SKIP sign a text with mode SIG_MODE_DETACH and without armored output [tests/gnupg_oo_sign_detach_nonarmor.phpt]
SKIP sign a text with mode SIG_MODE_NORMAL [tests/gnupg_oo_sign_normal.phpt]
SKIP sign a text with mode SIG_MODE_NORMAL and without armored output [tests/gnupg_oo_sign_normal_noarmor.phpt]
SKIP delete a key from the keyring [tests/gnupg_oo_zzz_deletekey.phpt]
FAIL import a new key into the keyring [tests/gnupg_res_0001_import.phpt]
FAIL encrypt and decrypt a text [tests/gnupg_res_encrypt.phpt]
FAIL encryptsign and decryptverify a text [tests/gnupg_res_encryptsign.phpt]
FAIL export a key [tests/gnupg_res_export.phpt]
FAIL get keyinfo [tests/gnupg_res_keyinfo.phpt]
FAIL list signatures [tests/gnupg_res_listsignatures.phpt]
FAIL sign a text with sigmode SIG_MODE_CLEAR [tests/gnupg_res_sign_clear.phpt]
FAIL sign a text with mode SIG_MODE_DETACH [tests/gnupg_res_sign_detach.phpt]
FAIL sign a text with mode SIG_MODE_DETACH and without armored output [tests/gnupg_res_sign_detach_nonarmor.phpt]
FAIL sign a text with mode SIG_MODE_NORMAL [tests/gnupg_res_sign_normal.phpt]
FAIL sign a text with mode SIG_MODE_NORMAL and without armored output [tests/gnupg_res_sign_normal_noarmor.phpt]
FAIL delete a key from the keyring [tests/gnupg_res_zzz_deletekey.phpt]
=====================================================================
Number of tests :   24                12
Tests skipped   :   12 ( 50.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   12 ( 50.0%) (100.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    1 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
import a new key into the keyring [tests/gnupg_res_0001_import.phpt]
encrypt and decrypt a text [tests/gnupg_res_encrypt.phpt]
encryptsign and decryptverify a text [tests/gnupg_res_encryptsign.phpt]
export a key [tests/gnupg_res_export.phpt]
get keyinfo [tests/gnupg_res_keyinfo.phpt]
list signatures [tests/gnupg_res_listsignatures.phpt]
sign a text with sigmode SIG_MODE_CLEAR [tests/gnupg_res_sign_clear.phpt]
sign a text with mode SIG_MODE_DETACH [tests/gnupg_res_sign_detach.phpt]
sign a text with mode SIG_MODE_DETACH and without armored output [tests/gnupg_res_sign_detach_nonarmor.phpt]
sign a text with mode SIG_MODE_NORMAL [tests/gnupg_res_sign_normal.phpt]
sign a text with mode SIG_MODE_NORMAL and without armored output [tests/gnupg_res_sign_normal_noarmor.phpt]
delete a key from the keyring [tests/gnupg_res_zzz_deletekey.phpt]

The list of libraries it says it can't load other than gnupg (curl, gd, mcrypt, mysql, mysqli, pdo & pdo_mysql) are all present in the extensions directory beside the gnupg.so file and they all show up in php_info(), but the gnupg extension doesn't show on that. Also, as you can see from the errors, all the gnupg functions which were tested failed. Does anyone have any suggestions?

Best Answer

Solved it. The walkthrough I linked to worked OK for an Ubuntu 10.04 system, but obviously not for the Debian server it was needed on. I needed to install some other packages in order for this to work:

  • libgpg-error0_1.6-1
  • libpth20_2.0.7-16
  • libpth-dev_2.0.7-16
  • libgpg-error-dev_1.6-1
  • libgpgme11_1.2.0-1.2
  • libgpgme11-dev_1.2.0-1

All of which are available from packages on the debian site