swoole / phpy

Connecting the Python and PHP ecosystems together
Apache License 2.0
543 stars 44 forks source link

看了说是可以支持 Linux Alpine 平台,那么有docker的Alpine,python镜像教程或者容器镜像吗? #48

Closed hgc357341051 closed 6 months ago

hgc357341051 commented 7 months ago

看了说是可以支持 Linux Alpine 平台,那么有docker的Alpine,python镜像教程或者容器镜像吗?

matyhtf commented 6 months ago

参考 https://github.com/swoole/phpy/blob/main/Dockerfile ,自己写

hgc357341051 commented 6 months ago

参考 https://github.com/swoole/phpy/blob/main/Dockerfile ,自己写

image 执行php -m查看未安装成功 `/www/phpy # docker-php-source extract && \

phpize && \
./configure --with-python-config=/usr/bin/python3-config && \
make && make install && \
docker-php-ext-enable phpy && \
docker-php-source delete

Configuring for: PHP Api Version: 20220829 Zend Module Api No: 20220829 Zend Extension Api No: 420220829 checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether cc accepts -g... yes checking for cc option to enable C11 features... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking for system library directory... lib checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-pc-linux-musl checking host system type... x86_64-pc-linux-musl checking target system type... x86_64-pc-linux-musl checking for PHP prefix... /usr/local checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20220829 checking for PHP installed headers prefix... /usr/local/include/php checking if debug is enabled... no checking if zts is enabled... no checking for gawk... no checking for nawk... no checking for awk... awk checking if awk is broken... no checking dir of python... no checking version of python... no checking path of python_config... /usr/bin/python3-config checking whether to enable phpy support... yes, shared checking for g++... g++ checking whether the compiler supports GNU C++... yes checking whether g++ accepts -g... yes checking for g++ option to enable C++11 features... none needed checking how to run the C++ preprocessor... g++ -E checking for a sed that does not truncate output... /bin/sed checking for ld used by cc... /usr/x86_64-alpine-linux-musl/bin/ld checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld) is GNU ld... yes checking for /usr/x86_64-alpine-linux-musl/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes checking how to recognize dependent libraries... pass_all ./configure: line 6372: /usr/bin/file: not found checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking how to run the C++ preprocessor... g++ -E checking the maximum length of command line arguments... 98304 checking command to parse /usr/bin/nm -B output from cc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if cc supports -fno-rtti -fno-exceptions... no checking for cc option to produce PIC... -fPIC checking if cc PIC flag -fPIC works... yes checking if cc static flag -static works... no checking if cc supports -c -o file.o... yes checking whether the cc linker (/usr/x86_64-alpine-linux-musl/bin/ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no

creating libtool appending configuration tag "CXX" to libtool checking for ld used by g++... /usr/x86_64-alpine-linux-musl/bin/ld checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld) is GNU ld... yes checking whether the g++ linker (/usr/x86_64-alpine-linux-musl/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC checking if g++ PIC flag -fPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking whether the g++ linker (/usr/x86_64-alpine-linux-musl/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so (cached) (cached) checking how to hardcode library paths into programs... immediate configure: patching config.h.in configure: creating ./config.status config.status: creating config.h config.status: config.h is unchanged

Build complete. Don't forget to run 'make test'.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20220829/ fetch https://mirrors.ustc.edu.cn/alpine/v3.19/main/x86_64/APKINDEX.tar.gz fetch https://mirrors.ustc.edu.cn/alpine/v3.19/community/x86_64/APKINDEX.tar.gz (1/1) Installing .docker-php-ext-enable-deps (20240528.085413) OK: 409 MiB in 119 packages (1/1) Purging .docker-php-ext-enable-deps (20240528.085413) OK: 409 MiB in 118 packages`

hgc357341051 commented 6 months ago

`/www/phpy # make test /bin/sh /www/phpy/libtool --mode=install cp ./phpy.la /www/phpy/modules cp ./.libs/phpy.so /www/phpy/modules/phpy.so cp ./.libs/phpy.lai /www/phpy/modules/phpy.la PATH="$PATH:/sbin" ldconfig -n /www/phpy/modules

Libraries have been installed in: /www/phpy/modules

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:

See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages.

Build complete. Don't forget to run 'make test'.

===================================================================== PHP : /usr/local/bin/php Warning: PHP Startup: Unable to load dynamic library 'phpy.so' (tried: /www/phpy/modules/phpy.so (Error relocating /www/phpy/modules/phpy.so: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv: symbol not found), /www/phpy/modules/phpy.so.so (Error loading shared library /www/phpy/modules/phpy.so.so: No such file or directory)) in Unknown on line 0

PHP_SAPI : cli PHP_VERSION : 8.2.15 ZEND_VERSION: 4.2.15 PHP_OS : Linux - Linux 883e4afeb547 5.4.265-1.el7.elrepo.x86_64 #1 SMP Wed Dec 20 13:57:20 EST 2023 x86_64 INI actual : /www/phpy/tmp-php.ini More .INIs :
CWD : /www/phpy Extra dirs : VALGRIND : Not used

TIME START 2024-05-28 16:57:27

No tests were run.`

hgc357341051 commented 6 months ago

不知道是不是Linux的Alpine容器环境下,会出现这个情况,因为Alpine容器的安装方式都不一样,采用的是apk add,您这个是apt install