gkralik / php7-sapnwrfc

SAP NW RFC SDK extension for PHP 7.3+ & PHP 8
https://gkralik.github.io/php7-sapnwrfc
MIT License
90 stars 35 forks source link

Crash when not running on CLI #68

Closed luckyduck closed 5 years ago

luckyduck commented 5 years ago

Thanks for all the effort you put into this. Really appreciated. I ran into a problem, though. I hope you can help with this.

CLI is working fine

FPM / MOD_PHP causing problems

I am trying to enable this extension for mod_php and/or php-fpm. This leads to an error in the PHP log:

Could not open the ICU common library.
   The following files must be in the path described by
   the environment variable "LD_LIBRARY_PATH":
   libicuuc.so.50, libicudata.so.50, libicui18n.so.50 [/bas/753_REL/src/flat/nlsui0.c 1527] pid = 13751
LD_LIBRARY_PATH is currently set to <not set>  [/bas/753_REL/src/flat/nlsui0.c 1530] pid = 13751
Set the environment variable NLSUI_INIT_TRACE_LEVEL to 'high' to see more details. [/bas/753_REL/src/flat/nlsui0.c 1539] pid = 13751
Check also SAP note 519753. [/bas/753_REL/src/flat/nlsui0.c 1540] pid = 13751

Setup seems to be correct

However, I have added the library path to ld.so.conf.d..:

$ cat /etc/ld.so.conf.d/nwrfcsdk.conf /usr/sap/nwrfcsdk/lib

... and executed ldconfig.

Libraries are loading fine, actually

The libraries even show up in the debug output of ldconfig:

$ ldconfig -p|grep nwrfcsdk libsapucum.so (libc6,x86-64) => /usr/sap/nwrfcsdk/lib/libsapucum.so libsapnwrfc.so (libc6,x86-64) => /usr/sap/nwrfcsdk/lib/libsapnwrfc.so libicuuc.so.50 (libc6,x86-64) => /usr/sap/nwrfcsdk/lib/libicuuc.so.50 libicui18n.so.50 (libc6,x86-64) => /usr/sap/nwrfcsdk/lib/libicui18n.so.50 libicudecnumber.so (libc6,x86-64) => /usr/sap/nwrfcsdk/lib/libicudecnumber.so libicudata.so.50 (libc6,x86-64) => /usr/sap/nwrfcsdk/lib/libicudata.so.50

Extension is linked

$ ldd /usr/lib/php/20151012/sapnwrfc.so linux-vdso.so.1 => (0x00007ffc0c9d2000) libsapucum.so => /usr/sap/nwrfcsdk/lib/libsapucum.so (0x00007f8a6ca1e000) libsapnwrfc.so => /usr/sap/nwrfcsdk/lib/libsapnwrfc.so (0x00007f8a6bed4000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8a6bb0a000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8a6b906000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8a6b6fe000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8a6b37c000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8a6b073000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8a6ae5d000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8a6ac40000) libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f8a6aa3b000) /lib64/ld-linux-x86-64.so.2 (0x00007f8a6cf67000)

Shouldn't this be enough?

My testscript:

<?php

// I changed those details of course
$parameters = [
    'ashost' => 'my.sap.system.local',
    'sysnr'  => '00',
    'client' => '123',
    'user' => 'DEMO',
    'passwd' => 'XXXX',
    // if you need to connect through saprouter, uncomment the following line
    //'saprouter' => '/H/my.saprouter.local/H/',
];

try {
    $connection = new SAPNWRFC\Connection($parameters);

    $remoteFunction = $connection->getFunction('RFC_PING');
    var_dump($remoteFunction->invoke());

    $connection->close();

} catch (Exception $e) {
    echo "didn't went well\n";
}

SetEnv doesn't help

I tried to pass along LD_LIBRARY_PATH to apache in the VHost configuration. That had no effect whatsoever:

SetEnv LD_LIBRARY_PATH /usr/sap/nwrfcsdk/lib

gkralik commented 5 years ago

This sounds interesting. Personally I never had any problems using PHP-FPM, but I have never tried with Apache mod-php... I'll try to investigate.

gkralik commented 5 years ago

What is your PHP version?

gkralik commented 5 years ago

Just a quick thought: are the files in /usr/sap/nwrfcsck readable by the user Apache and/or mod_php or PHP-FPM are running?

gkralik commented 5 years ago

Also, try to use SAP NW RFC SDK 7.20 instead of 7.50. There might be unsolved problems with the new SDK, as I have not tested the extension using the new SDK yet.

luckyduck commented 5 years ago

Awesome. It was about access rights. Didn't thought about it in regard to the libraries. Thank you so much!