Posted: Wed Apr 14, 2021 19:32 Post subject: Installing GMP extension for built-in lighttpd + PHP
1. I'm using dd-wrt's built-in lighttpd. I've installed FreshRSS (https://freshrss.org/) on the the server, but one feature cannot be enabled and it returns this error message: "FAIL 64-bit or GMP extension! Wrong PHP configuration." FreshRSS doc has the explanation for this error
FreshRSS Documentation wrote:
If you get FAIL 64-bit or GMP extension!, then your PHP version does not pass the requirement of being 64-bit and/or have PHP GMP extension.
The easiest is to add the GMP extension. On Debian / Ubuntu: sudo apt install php-gmp
I've tried "opkg install php7-mod-gmp" and modified the module list in lightttpd.conf, but after that I get HTTP error 500, so I revert everything and reinstall entware to recover.
Question: How can I install GMP extension on dd-wrt?
2. After messing and recovering the server, I encounter this warning/error message every time php runs:
Code:
root@RB:~# php -v
Cannot load Zend OPcache - it was already loaded
Warning: Module "openssl" is already loaded in Unknown on line 0
PHP 8.0.3 (cli) (built: Mar 5 2021 23:32:53) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
Question: Is it normal or it's because my php.ini is not correct?
Router/Version: D-Link DIR-868L Rev.A1 DD-WRT v3.0-r46329 std (04/13/21)
File/Kernel: dir868a-webflash.bin/ Linux 4.4.265 #2494 SMP Mon Apr 12 02:49:48 +07 2021 armv7l
Previous/Reset: DD-WRT v3.0-r46316 std (04/09/21)/ no
Mode/Status: Repeater Bridge on 5GHz AC/N-Mixed (wl0 is purposely turned off) + USB Storage + lighttpd / working
today I realize php8 is available in Entware package list, so I go ahead and install php8-mod-gmp and add gmp.so to the list of extension in php.ini, but I encounter this error:
Code:
root@RB:~# php -v
Warning: PHP Startup: Unable to load dynamic library '/opt/lib/php8/gmp.so' (tried: /opt/lib/php8/gmp.so (Error relocating /opt/lib/libgmp.so.10: obstack_vprintf: symbol not found), /etc/php/modules//opt/lib/php8/gmp.so.so (Error loading shared library /etc/php/modules//opt/lib/php8/gmp.so.so: No such file or directory)) in Unknown on line 0
PHP 8.0.6 (cli) (built: May 11 2021 15:56:16) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.6, Copyright (c) Zend Technologies
with Zend OPcache v8.0.6, Copyright (c), by Zend Technologies
I've opened a bug report at entware repo, but they quickly discovered that there's nothing wrong when they fresh-install their php8 packages on their machine, and closed the issue.
So I decide to swap DDWRT's bundled php8 with Entware's php8. After some struggling, everything are good now: no more error, GMP module installed, website functioning normally.
Code:
root@RB:~# php-cli -v
PHP 8.0.9 (cli) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
Below are the steps I did:
Open phpinfo page to see the list of currently loaded modules EDIT: better use type php and php -m
Install Entware php8 + modules
Edit \jffs\etc\lighttpd.conf to point to new Entware php8 ("bin-path"):
Verify if php8 is migrated: php-cli -v, type php-cli, check if all modules are loaded: compare new phpinfo with old one EDIT: use php-cli -m, load website to see if everything are good.
1970-01-01 08:00:23: server.c.1508) server started (lighttpd/1.4.58)
1970-01-01 08:00:23: mod_deflate.c.546) DEPRECATED: compress.filetype replaced with deflate.mimetypes
1970-01-01 08:00:23: mod_deflate.c.559) DEPRECATED: compress.cache-dir replaced with deflate.cache-dir
→ swapping with mod_deflate solve the issues (cache is generated properly in /tmp/lighttpd/cache/compress/ & served to browser)
missing mimetype for SVG/SVGZ: browser asks to download SVG file instead of displaying on website
@kernel-panic69: can you take a look at this issue and decide if it's a valid bug?
lighttpd.conf.zip
Description:
modified lighttpd.conf (contains sections not suitable for generic use)
Joined: 26 Mar 2013 Posts: 1855 Location: Hung Hom, Hong Kong
Posted: Tue Aug 31, 2021 11:19 Post subject:
egc wrote:
I had a quick look, it seems PHP should be compiled with the --with-gmp option set (see my patch)
DDWRT does not have this set, I do not know how much extra KB it takes and if it is worthwhile
I am far from a PHP expert
According to 'opkg list | grep gmp':
Code:
libgmp - 6.2.1-1a - GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers.
php7-mod-gmp - 7.4.20-1 - GMP shared module
It's a separate package in Entware. Not sure whether the package is intended for PHP 8. Even Debian listed it as a separate package.
libgmp - 6.2.1-1a - GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers.
php7-mod-gmp - 7.4.20-1 - GMP shared module
It's a separate package in Entware. Not sure whether the package is intended for PHP 8. Even Debian listed it as a separate package.
the latest Entware package list has php8-mod-gmp (I believe Entware just added php8 a few weeks ago). I think your package list is not updated yet, if you do "opkg update" and rerun list grep then you can see php8-mod-gmp.
mwchang wrote:
You can enable or disable that extension in phpconfig.ini or php.ini, according to some Google results. Take a look at those ini files.
DDWRT comes with php8 and quite a lot of modules for php8, but it seems like there's no GMP, because there's no gmp.so or libgmp.so in /etc/php/modules (there are only openssl.so and opcache.so inside that folder, and php -m doesn't show GMP).
mwchang wrote:
I think Entware is not a part of DD-WRT?? You have to find its administrator for help.
I thought I could just use DDWRT's php8 together with Entware's php8-mod-gmp, but it didn't work. I opened a bug report at Entware repo regarding their php8-mod-gmp, but they found nothing wrong and closed the issue. Details in 2nd post above.
mwchang wrote:
Alternatively, stay with PHP 7????
Maybe PHP 8 is still a work-in-progress. SO be patient?
Joined: 26 Mar 2013 Posts: 1855 Location: Hung Hom, Hong Kong
Posted: Wed Sep 01, 2021 3:28 Post subject:
IONK wrote:
1. I'm using dd-wrt's built-in lighttpd. .... more ...
today I realize php8 is available in Entware package list, so I go ahead and install php8-mod-gmp and add gmp.so to the list of extension in php.ini ... more ...
At the time I started this thread, DDWRT has already incorporated php8 and many php8 modules, but Entware didn't have php8 yet, only php7.... more ...
Instead of trying to use the stock LightTPD mixed with the PHP8 in Entware, it might be easier for you to disable the stock LightTPD and use both PHP and LightTPD from Entware! You should be using /opt/etc to configure them. You are not going to manage it from WEBUI neither.
I suspect the stock LightTPD was never meant to use PHP and other extensions including MySQL.
Quote:
DDWRT comes with php8 and quite a lot of modules for php8, but it seems like there's no GMP, because there's no gmp.so or libgmp.so in /etc/php/modules (there are only openssl.so and opcache.so inside that folder, and php -m doesn't show GMP).
Sorry about this.
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Instead of trying to use the stock LightTPD mixed with the PHP8 in Entware, it might be easier for you to disable the stock LightTPD and use both PHP and LightTPD from Entware! You should be using /opt/etc to configure them. You are not going to manage it from WEBUI neither.
It can be a 5min job for experts, but it can also be a big hurdle for other people, including myself of last week. Not all DDWRT users are comfortable with Linux commands, or are knowledgeable about server/php, or are willing to spend time, or are willing to get their hands dirty, to build/install/configure everything by themselves, just for a hobby project.
You're correct, I should have thought of downgrading to PHP7 at that time, and asked that question and got the answer. Maybe I didn't do so because I had little knowledge of lighttpd/php at that time, and I was scared of making too much changes to the already-working website (there's just one missing feature without GMP). Thanks for finding/sharing the link about installing lighttpd & php on DDWRT, I hope it will benefit others.
Just in case I didn't express it clearly in my 2nd post: I have already solved my original problem by switching to Entware's php8 + Entware's php8-mod-gmp (which are only available recently). During the process, I discovered some issues, so I posted a reply to myself as a kind of documentation, to benefit everyone. I guess downgrading to php7 will also work, but because I had no preference for php7 or php8, I will use php8 for now in case I want to switch back to DDWRT's php8 after the compatibility issue with DDWRT's php8 is fixed.
mwchang wrote:
I suspect the stock LightTPD was never meant to use PHP and other extensions including MySQL.
Joined: 26 Mar 2013 Posts: 1855 Location: Hung Hom, Hong Kong
Posted: Wed Sep 01, 2021 10:37 Post subject:
IONK wrote:
[*]It can be a 5min job for experts, but it can also be a big hurdle for other people, including myself of last week. Not all DDWRT users are comfortable with Linux commands, or are knowledgeable about server/php, or are willing to spend time, or are willing to get their hands dirty, to build/install/configure everything by themselves, just for a hobby project.
.... more ...
Maybe you made some typo or I misunderstood your point, but DDWRT's lighttpd + php8 + various php8 modules are working out-of-the-box, just that the GMP module is not statically built into DDWRT's php8 and somehow DDWRT's php8 is not compatible with Entware's php8-mod-gmp.
Hopefully your ticket would be answered in coming builds. And egc had responded.
I agree that if the stock LightTPD could be recompiled, it's just a 5-minute job to use an extra configure options "--with-gmp". This will affect all routers all models anyway, and might trigger error.
Forgive my wild guesses and oversight. Sorry for wasting your time.
BTW, a PHP expert/programmer does not have to know how PHP and LightTPD are compiled. Division of labor....
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Hopefully your ticket would be answered in coming builds. And egc had responded.
I agree that if the stock LightTPD could be recompiled, it's just a 5-minute job to use an extra configure options "--with-gmp". This will affect all routers all models anyway, and might trigger error.
Forgive my wild guesses and oversight. Sorry for wasting your time.
BTW, a PHP expert/programmer does not have to know how PHP and LightTPD are compiled. Division of labor....
It seems like no ticket? Not that I know of?
Actually it's PHP not lighttpd issue. Not all users need GMP, so it's not necessarily to include GMP in php binary, but to make php compatible with Entware's module, so that users can install additional modules from Entware as they need.
But this seems to deviate from what I was trying to say: I meant that installing only one missing GMP module readily available from Entware would be simpler than throwing away DDWRT's php and reinstalling all php modules from Entware and figuring out which config to change to use Entware's php instead of DDWRT's.
mwchang wrote:
egc wrote:
I had a quick look, it seems PHP should be compiled with the --with-gmp option set (see my patch)
Is it necessary to also patch php.ini as well to disable GMP by default?
From opkg list, php8-mod-gmp is a separate package not installed by default.
the default php.ini doesn't enable GMP (because there's no gmp.so or php_gmp.so to load).
mwchang wrote:
Could we assume that no PHP error would be triggered if no codes made calls to GMP?
that's a very broad question, and someone will probably tell you to run all PHP tests to verify by yourself, and report back here.
Joined: 26 Mar 2013 Posts: 1855 Location: Hung Hom, Hong Kong
Posted: Wed Sep 01, 2021 14:41 Post subject:
egc wrote:
It is for @mwchang if you compile with --with-gmp you have to enable it in the .ini I guess
The default LightTPD that comes with DD-WRT does not have mod-gmp compiled into it. It's safer to make an EXPLICIT declaration in php.ini.
Just a suggestion. Make everything explicit and visible to avoid confusions.
I don't plan to turn on LightTPD nor use PHP in the near future. SO pardon me. I only spoke from my past experiences when I compiled PHP & Apache from source codes for Caldera OpenLinux.
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!