nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

Unit building PHP modules. Version confusion. #1007

Closed skillslasher closed 8 months ago

skillslasher commented 10 months ago

When trying to build modules for PHP of different versions, at the moment of configuring the build, the latest PHP package is picked up, not the one specified in the configuration parameters.

For example. The system has php7.4, php8.1, php8.2 installed. ./configure php --module=php7.4 --config=php-config --lib-path=/usr/lib/php/7.4/sapi

configuring PHP module checking for PHP ... found

With these ./configure settings, it will still pick up the most recent package on the system, which is php8.2 Naturally, such a module does not work properly afterwards. Forcing the default PHP interpreter to be changed to php7.4 did nothing.

Can you please tell me how to fix the problem? System: Ubuntu 22.04.3. Unit version 1.31.1 PHP 7.4.33 PHP 8.1.25 PHP 8.2.12

thresheek commented 10 months ago

Hi @skillslasher, you'd also need to specify a proper path to php7.4-config, via --config option.

skillslasher commented 10 months ago

Hi @thresheek I've had the same idea before, but it raises an error. ./configure: error: no PHP found.

thresheek commented 10 months ago

Please check the build/autoconf.err file for the issues encountered then, it should have the information on why it wasnt found.

skillslasher commented 10 months ago

All I found in this file is this:

checking for PHP zend_signal_startup() configuring PHP module ... checking for PHP ... /bin/sh: 1: php7.4-config: not found configuring PHP module ... checking for PHP ... 8.2.12

I tried to find this file on the system, but it doesn't exist. I don't know where he's supposed to be either. The Unit's documentation states simply --config=php-config.

It worked like this with past versions of Unit

thresheek commented 10 months ago

Well, you need to specify a proper path to php-config (or similarly named executable) that corresponds to PHP 7.4 - typically found in packages named like "php7.4-dev". Probably prior you had the default set to it.

Looking at Ubuntu packages, though, I don't see 7.4 in 22.04, only in 20.04: https://packages.ubuntu.com/search?keywords=php7.4-dev so I'm not sure where it can be found on your system - probably a self-installed PHP from somewhere else?

skillslasher commented 10 months ago

@thresheek Thank you so much, for your help and advice. Yeah, I found it. This file. It was called php-config7.4 And similar for the rest of the packages.

tippexs commented 10 months ago

@skillslasher sorry for comming back to this a little late but before closing it - would you say there are some missing steps in our documentation about building PHP modules? Is there anything we can improve that would helped you doing it right in the first place?