Hello.

I am developing an Apache module that, upon receiving an HTTP request, reads a 
file in a custom language where a series of request handlers are declared. Once 
the file has been parsed and a handler has been found, the source code it 
contains is obtained, which is in PHP; and it tries to load the PHP Embed 
header, but I'm getting this error message:

> apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error 
> on line 1 of /etc/apache2/mods-enabled/rst.load: Cannot load 
> /usr/lib/apache2/modules/mod_rst.so into server: 
> /usr/lib/apache2/modules/mod_rst.so: undefined symbol: php_embed_shutdown

In principle everything is correct:

ldd /usr/lib/apache2/modules/mod_rest.so
linux-vdso.so.1 (0x00007ffeef78a000)
libphp.so => ​​/home/user/php-embed/libs/libphp.so (0x00007fd10fb2b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd10f93e000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd10f85f000)
libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fd10f6b3000)
libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007fd10f554000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd1110d1000)
libicuuc.so.72 => /lib/x86_64-linux-gnu/libicuuc.so.72 (0x00007fd10f354000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd10f335000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fd10f306000)
libicudata.so.72 => /lib/x86_64-linux-gnu/libicudata.so.72 (0x00007fd10d534000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd10d31a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd10d2fa000)

nm -D /home/user/php-embed/libs/libphp.so | grep php_embed
00000000007ea477 T php_embed_init
000000000157eac0 D php_embed_module
00000000007ea5aa T php_embed_shutdown

I'm working on WSL Debian 12 Bookworm, I've downloaded the php-embed and 
libphp-embed packages, maintained by the Debian PHP and PHP PEAR Maintenance 
teams, and as it still didn't work, I've downloaded and compiled the PHP 8.4.1 
source code with the --enabled-embed flag, but I still get the same error.

I must add that, both with the php-embed and libphp-embed packages, and with 
the source code compiled by myself, I have compiled a basic program with the 
PHP Embed library and I have had no problems, the output is correct, the basic 
example comes from this repository: 
https://github.com/KapitanOczywisty/PHP_embed_docs/blob/main/embed.md.

I have searched a lot, although I probably have not found the correct search 
terms, since the words “Apache, module and PHP” together flood the results, 
surely hiding this specific case. I could conclude that the PHP Embed API works 
correctly, except when I try to use it in an Apache module. I understand that 
you could tell me to go to the PHP channels, you are not wrong, but I thought 
it appropriate to expose my problem here in case someone has had this 
experience.

Thank you very much for reading, greetings.

Reply via email to