Closed W3Max closed 1 day ago
I tried disabling watcher with the flag nowatcher, but I now get this error:
/root/go/pkg/mod/github.com/dunglas/frankenphp@v1.3.0/cgi.go:3:11: fatal error: php_variables.h: No such file or directory 3 | // #include <php_variables.h> | ^~~~~~~~~~~~~~~~~
How can I add the missing files (php_variables.h, wtr/watcher-c.h) to the build process (with xcaddy)?
Thanks!
You need to compile and install PHP and Watcher from sources, as explained in the docs. If you did that, can you check that the headers files are in /usr/lib/include
(the default)?
@dunglas Thank you for your quick answer!
Unfortunately, after installing PHP from source, XCADDY still fails.
To answer your question, there is no /usr/lib/include
directory automatically created after installing PHP from source. I tried to create it manually and copy the required files but it still does not work.
I guess I’m missing something again... any ideas?
Here is what I have done from a fresh Debian 12 install:
Install requirements
apt update && apt-get upgrade -y
apt install build-essential
apt install lsb-release
apt install re2c
apt install git
apt install curl zip unzip tar
apt install pkg-config
apt install libsqlite3-dev
Install GO from Source
GO_VERSION=1.23.3 && \
wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" && \
rm -rf /usr/local/go && tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz" && \
export PATH=$PATH:/usr/local/go/bin && \
source $HOME/.profile && \
go version && \
rm "go${GO_VERSION}.linux-amd64.tar.gz"
Install PHP from source
wget https://www.php.net/distributions/php-8.3.13.tar.gz
tar xf php-8.3.13.tar.gz
cd php-8.3.13
./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers
--without-pdo-sqlite
make -j"$(getconf _NPROCESSORS_ONLN)"
sudo make install
Installing Brotli
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install brotli
Installing watcher-c
curl -L https://github.com/e-dant/watcher/archive/refs/heads/next.tar.gz | tar xz
cd watcher-next/watcher-c
c++ -o libwatcher-c.so ./src/watcher-c.cpp -I ./include -I ../include -std=c++17 -fPIC -shared
Trying to manually copy header files required by dunglas/frankenphp
to /usr/lib/include
mkdir /usr/lib/include
cp /usr/local/include/php/main/php_variables.h /usr/lib/include
cp -r /watcher-next/watcher-c/include/wtr /usr/lib/include
Installing xcaddy
sudo apt install -y curl debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
sudo apt update
sudo apt install xcaddy
Building Caddy with FrankenPHP and other modules
CGO_ENABLED=1 \
XCADDY_GO_BUILD_FLAGS="-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" \
xcaddy build \
--output frankenphp \
--with github.com/dunglas/frankenphp/caddy \
--with github.com/caddy-dns/cloudflare \
--with github.com/hslatman/caddy-crowdsec-bouncer/crowdsec
--with github.com/dunglas/mercure/caddy \
--with github.com/dunglas/vulcain/caddy
Error
watcher.c:5:10: fatal error: wtr/watcher-c.h: No such file or directory
5 | #include "wtr/watcher-c.h"
| ^~~~~~~~~~~~~~~~~
Sorry I meant /usr/local/include
:/
For watcher, you need to use the standard cmake commands to have the headers copied:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
There is a bug in the docs, I'm on it.
Can you try if this fixes your issue? https://github.com/dunglas/frankenphp/pull/1157
@dunglas Almost there!
Installing watcher-c
git clone https://github.com/e-dant/watcher.git
cd watcher
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
The build completes but there is still one error at the end:
./frankenphp version
./frankenphp: error while loading shared libraries: libwatcher-c.so.0: cannot open shared object file: No such file or directory
I found it!
Just had to:
git clone https://github.com/e-dant/watcher.git
cd watcher
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
cd watcher/build/
cp libwatcher-c.so /usr/local/lib/libwatcher-c.so
ldconfig
And now:
frankenphp version
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
Thank you!
What happened?
I tried to install Caddy with dunglas/frankenphp/caddy as shown here https://frankenphp.dev/docs/compile/#using-xcaddy, but I got this error:
# github.com/dunglas/frankenphp/internal/watcher watcher.c:5:10: fatal error: wtr/watcher-c.h: No such file or directory 5 | #include "wtr/watcher-c.h" | ^~~~~~~~~~~~~~~~~
I previously installed Watcher.
I'm on Debian 12.
Any idea what is missing?
Thanks!
Build Type
Standalone binary
Worker Mode
No
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output
No response