2026-07-16 06:25:16 +00:00
|
|
|
|
import{G as e,K as t,at as n,j as r}from"./chunks/framework.DrNIf5Lg.js";var i=JSON.parse(`{"title":"常见问题","description":"","frontmatter":{},"headers":[],"relativePath":"zh/faq/index.md","filePath":"zh/faq/index.md"}`),a={name:`zh/faq/index.md`};function o(r,i,a,o,s,c){return n(),e(`div`,null,[...i[0]||=[t(`<h1 id="常见问题" tabindex="-1">常见问题 <a class="header-anchor" href="#常见问题" aria-label="Permalink to “常见问题”"></a></h1><p>这里将会编写一些你容易遇到的问题。</p><h2 id="php-ini-的路径是什么" tabindex="-1">php.ini 的路径是什么? <a class="header-anchor" href="#php-ini-的路径是什么" aria-label="Permalink to “php.ini 的路径是什么?”"></a></h2><p>在 Linux、macOS 和 FreeBSD 上,<code>php.ini</code> 的路径是 <code>/usr/local/etc/php/php.ini</code>。 在 Windows 中,路径是 <code>C:\\windows\\php.ini</code> 或 <code>php.exe</code> 所在的当前目录。 可以在 *nix 系统中使用构建选项 <code>--with-config-file-path</code> 来更改查找 <code>php.ini</code> 的目录。</p><p>此外,在 Linux、macOS 和 FreeBSD 上,<code>/usr/local/etc/php/conf.d</code> 目录中的 <code>.ini</code> 文件也会被加载。 在 Windows 中,该路径默认为空。 可以使用构建选项 <code>--with-config-file-scan-dir</code> 更改该目录。</p><p>PHP 默认也会从 <a href="https://www.php.net/manual/zh/configuration.file.php" target="_blank" rel="noreferrer">其他标准位置</a> 中搜索 <code>php.ini</code>。</p><h2 id="静态编译的-php-可以安装扩展吗" tabindex="-1">静态编译的 PHP 可以安装扩展吗? <a class="header-anchor" href="#静态编译的-php-可以安装扩展吗" aria-label="Permalink to “静态编译的 PHP 可以安装扩展吗?”"></a></h2><p>因为传统架构下的 PHP 安装扩展的原理是使用 <code>.so</code> 类型的动态链接的库方式安装新扩展,而使用本项目编译的静态链接的 PHP。但是静态链接在不同操作系统有不同的定义。</p><p>首先,对于 Linux 系统,静态链接的二进制文件不会链接系统的动态链接库。纯静态链接的二进制文件(<code>-all-static</code>)无法加载动态库,因此无法添加新扩展。 同时,在纯静态模式下,你也不能使用 <code>ffi</code> 等扩展来加载外部 <code>.so</code> 模块。</p><p>你可以使用命令 <code>ldd buildroot/bin/php</code> 来检查你在 Linux 下构建的二进制文件是否为纯静态链接。</p><p>如果你构建了基于 GNU libc 的 PHP,你可以使用 <code>ffi</code> 扩展来加载外部 <code>.so</code> 模块,并加载具有相同 ABI 的 <code>.so</code> 扩展。</p><p>例如,你可以使用以下命令构建一个与 glibc 动态链接的静态 PHP 二进制文件,支持 FFI 扩展并加载相同 PHP 版本和相同 TS 类型的 <code>xdebug.so</code> 扩展:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SPC_TARGET</span><span style="--shiki-light:#c62739;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">native-native-gnu.2.17</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build:php</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "ffi,xml"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -vvv</span></span>
|