You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/faq/index.md
+26-11Lines changed: 26 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,13 +16,29 @@ The directory can be changed using the manual build option `--with-config-file-s
16
16
17
17
## Can statically-compiled PHP install extensions?
18
18
19
-
Because the principle of installing extensions in PHP under the traditional architecture is to install new extensions using `.so` type dynamic link libraries,
20
-
and statically linked PHP compiled using this project cannot **directly** install new extensions using dynamic link libraries.
19
+
Because the principle of installing PHP extensions under the normal mode is to use `.so` type dynamic link library to install new extensions,
20
+
and we use the static link PHP compiled by this project. However, static linking has different definitions in different operating systems.
21
21
22
-
For the macOS platform, almost all binary files under macOS cannot be linked purely statically,
23
-
and almost all binary files will link macOS system libraries: `/usr/lib/libresolv.9.dylib` and `/usr/lib/libSystem.B.dylib`.
24
-
So under macOS system, statically compiled php binary files can be used under certain compilation conditions,
25
-
and dynamic link extensions can be used at the same time:
22
+
First of all, for Linux systems, statically linked binaries will not link the system's dynamic link library.
23
+
Purely statically linked binaries (`build with -all-static`) cannot load dynamic libraries, so new extensions cannot be added.
24
+
At the same time, in pure static mode, you cannot use extensions such as `ffi` to load external `.so` modules.
25
+
26
+
You can use the command `ldd buildroot/bin/php` to check whether the binary you built under Linux is purely statically linked.
27
+
28
+
If you [build GNU libc based PHP](../guide/build-with-glibc), you can use the `ffi` extension to load external `.so` modules and load `.so` extensions with the same ABI.
29
+
30
+
For example, you can use the following command to build a static PHP binary dynamically linked with glibc,
31
+
supporting FFI extensions and loading the `xdebug.so` extension of the same PHP version and the same TS type:
For macOS platform, almost all binaries under macOS cannot be truly purely statically linked, and almost all binaries will link macOS system libraries: `/usr/lib/libresolv.9.dylib` and `/usr/lib/libSystem.B.dylib`.
41
+
So on macOS, you can use statically compiled PHP binaries under certain compilation conditions, and dynamically linked extensions:
26
42
27
43
1. Using the `--no-strip` parameter will not strip information such as debugging symbols from the binary file for use with external Zend extensions such as `Xdebug`.
28
44
2. If you want to compile some Zend extensions, use Homebrew, MacPorts, source code compilation, and install a normal version of PHP on your operating system.
@@ -34,15 +50,12 @@ and dynamic link extensions can be used at the same time:
34
50
bin/spc build ffi --build-cli --no-strip
35
51
```
36
52
37
-
For the Linux platform, the current compilation result is a purely statically linked binary file,
38
-
and new extensions cannot be installed using a dynamic link library.
39
-
40
53
## Can it support Oracle database extension?
41
54
42
55
Some extensions that rely on closed source libraries, such as `oci8`, `sourceguardian`, etc.,
43
56
they do not provide purely statically compiled dependent library files (`.a`), only dynamic dependent library files (`.so`).
44
-
These extensions cannot be compiled into static-php-cli from source, so this project may never support them.
45
-
However, in theory, you can access and use such extensions under macOS according to the above questions.
57
+
These extensions cannot be compiled into static-php-cli using source code, so this project may never support these extensions.
58
+
However, in theory you can access and use such extensions under macOS and Linux according to the above questions.
46
59
47
60
If you have a need for such extensions, or most people have needs for these closed-source extensions,
48
61
see the discussion on [standalone-php-cli](https://github.com/crazywhalecc/static-php-cli/discussions/58). Welcome to leave a message.
@@ -75,6 +88,8 @@ such as Swoole Compiler, Source Guardian, etc.
75
88
76
89
## Unable to use ssl
77
90
91
+
**Update: This issue has been fixed in the latest version of static-php-cli, which now reads the system's certificate file by default. If you still have problems, try the solution below.**
92
+
78
93
When using curl, pgsql, etc. to request an HTTPS website or establish an SSL connection, there may be an `error:80000002:system library::No such file or directory` error.
79
94
This error is caused by statically compiled PHP without specifying `openssl.cafile` via `php.ini`.
Copy file name to clipboardExpand all lines: docs/en/guide/extension-notes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,8 +123,8 @@ For details on the solution, see [FAQ - Unable to use ssl](../faq/#unable-to-use
123
123
124
124
## ffi
125
125
126
-
1.Linux not supported yet: Due to limitations of the Linux system, although the ffi extension can be compiled successfully, it cannot be used to load other `so` extensions.
127
-
The prerequisite for Linux to support loading `so` extensions is dynamic compilation, but dynamic compilation conflicts with the purpose of this project.
126
+
1. Due to the limitation of Linux system, you cannot use it to load other `so` extensions in the purely static compiled state (spc defaults to pure static compilation).
127
+
Linux supports loading so extensions only if they are non-statically compiled. If you need to use the ffi extension, see [Compile PHP with GNU libc](./build-with-glibc).
128
128
2. macOS supports the ffi extension, but errors will occur when some kernels do not contain debugging symbols.
0 commit comments