Open Articus opened 4 years ago
Small update: now there is one more alternative - https://github.com/Articus/unit-php (a bit "hackish" proof-of-concept I made for our project migration to PHP 8.0).
I actually managed to easily compile this for sury php7.4 on bookworm using the instructions here: https://unit.nginx.org/howto/modules/#modules-pkg
This is even easier when done in a temporary docker builder stage.
It would be nice to have those packages to be honest. Thank you for your work!
It would be nice, but I don’t have capacity to do that and maintain yet another framework.
just for posterity, I managed to get this working in docker.
First, start from your favourite distro, install nginx unit from apt/rpm, sury embed package, compile unit-php
in a separate stage and copy .so
file in the end-image.
FROM debian:bullseye-slim AS base
RUN apt-get update \
&& apt-get upgrade \
&& apt-get install \
apt-transport-https \
ca-certificates \
lsb-release \
software-properties-common \
curl \
libcurl4-gnutls-dev \
git \
unzip
# add repository for Ondřej Surý's PHP packages
RUN curl -s https://packages.sury.org/php/apt.gpg > /etc/apt/trusted.gpg.d/php.gpg
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/php.list
RUN apt-get update \
&& apt-get install \
php8.0-cli \
php8.0-curl \
php8.0-zip \
php8.0-bcmath \
php8.0-mbstring \
php8.0-gd \
php8.0-intl \
php8.0-opcache \
php8.0-pdo-mysql \
libphp8.0-embed
# add official nginx unit repo
RUN curl -fsSL https://unit.nginx.org/keys/nginx-keyring.gpg | apt-key add - \
&& add-apt-repository -s "deb https://packages.nginx.org/unit/debian/ $(lsb_release -cs) unit"
RUN apt-get update \
&& apt-get install \
unit \
&& ln -sf /dev/stdout /var/log/unit.log
# COPY ./docker/*.pem /docker-entrypoint.d/
COPY ./docker/*.json /docker-entrypoint.d/
COPY ./docker/*.sh /docker-entrypoint.d/
COPY ./docker/docker.entrypoint /usr/local/bin/docker-entrypoint.sh
WORKDIR /web
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
EXPOSE 80
CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
###########################################################
FROM base as unit-builder
RUN apt-get update && \
apt-get install -y \
curl \
build-essential \
libssl-dev \
libpcre3-dev \
zlib1g-dev \
php8.0-dev
# https://unit.nginx.org/howto/modules/#modules-pkg
RUN unitd --version > /tmp/unit_version_output.txt 2>&1 && \
UNIT_VERSION=$(grep "unit version:" /tmp/unit_version_output.txt | awk '{print $3}') && \
UNIT_CONFIGURE_PARAMS=$(grep "configured as" /tmp/unit_version_output.txt | cut -d' ' -f4- | sed "s/--ld-opt='[^']*'//g" | sed "s/--njs//g" | tr -s ' ') && \
echo "Compiling for Unit [${UNIT_VERSION}] with stripped configure parameters: ${UNIT_CONFIGURE_PARAMS}" && \
mkdir -p /unit-src && \
curl -L -o /unit-src/unit.tar.gz https://sources.nginx.org/unit/unit-${UNIT_VERSION}.tar.gz && \
tar xzf /unit-src/unit.tar.gz -C /unit-src && \
cd /unit-src/unit-${UNIT_VERSION} && \
eval "./configure $UNIT_CONFIGURE_PARAMS" && \
./configure php --module=php8.0 --config=php-config && \
make php8.0 && \
ls -al build/lib/unit/modules/
###########################################################
FROM base AS dev
COPY --from=composer:2.5.5 /usr/bin/composer /usr/bin/composer
COPY --from=unit-builder /unit-src/unit-*/build/lib/unit/modules/php8.0.unit.so /usr/lib/unit/modules/
Is your feature request related to a problem? Please describe.
About two years ago Nginx team introduced Nginx Unit - their own application server that can run PHP applications via
libphp-embed
. We use it in production for more than a year now (nearly year and a half) and it seems to be a perfect alternative for PHP-FPM: feature parity for web applications with only one entry script, better performance, more convenient configuration.Nginx Unit has official repository and its installation is pretty straightforward but there is one "catch" -
unit-php
(package for PHP language module) is build for PHP package from official Debian repository. So for example if you want to run Nginx Unit + PHP 7.4 even on Buster, you have to build PHP language module from source :(Describe the solution you'd like
According discussion at Nginx Unit issue tracker the best place for custom package with PHP language module would be the repository that provides custom PHP package. And for example popular PHP package repository for Centos does that.
I know that is a lot to ask for but would you be interested in providing similar packages? My personal "dream come true" variant would be:
php<version>-unit-php
(likephp7.4-unit-php
) containingphp<version>.unit.so
(likephp7.4.unit.so
) for Nginx Unit module folder (/usr/lib/unit/modules
in package from official repo)Describe alternatives you've considered
There seems to be only two alternatives:
unit-php
package with latest minor revision from packages.sury.org/php for PHP version provided by Debian distribution (our current strategy)php.unit.so
(the only fileunit-php
provides) each time PHP package upgrade from packages.sury.org/php is needed (currently experimenting with that because of PHP 7.4 release)P. S.
Regardless of the answer great thanks for maintaining the best Debian PHP repo!