2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{_ as e,o as i,c as s,a2 as t}from"./chunks/framework.B-QBKwc1.js";const k=JSON.parse('{"title":"常见问题 FAQ","description":"本页收录环境搭建与首次运行阶段的常见问题,按环境、数据库与启动等场景分类,快速入门受阻时优先按症状查阅。","frontmatter":{},"headers":[],"relativePath":"zh/quickstart/faq.md","filePath":"zh/quickstart/faq.md"}'),l={name:"zh/quickstart/faq.md"};function o(n,a,h,r,d,p){return i(),s("div",null,[...a[0]||(a[0]=[t('<h1 id="_2-8-常见问题-FAQ" tabindex="-1">2.8 常见问题 FAQ <a class="header-anchor" href="#_2-8-常见问题-FAQ" aria-label="Permalink to "2.8 常见问题 FAQ""></a></h1><div class="tip custom-block"><p class="custom-block-title">概述</p><p>本页收录环境搭建与首次运行阶段的常见问题,按环境、数据库与启动等场景分类,快速入门受阻时优先按症状查阅。</p></div><h2 id="环境相关" tabindex="-1">环境相关 <a class="header-anchor" href="#环境相关" aria-label="Permalink to "环境相关""></a></h2><h3 id="Q-PHP-版本低于-8-2-能运行吗-" tabindex="-1">Q: PHP 版本低于 8.2 能运行吗? <a class="header-anchor" href="#Q-PHP-版本低于-8-2-能运行吗-" aria-label="Permalink to "Q: PHP 版本低于 8.2 能运行吗?""></a></h3><p>A: 不能。项目使用了 PHP 8.2 的强类型特性(如 <code>readonly</code> 属性、<code>DNF</code> 类型等),必须使用 PHP 8.2+。</p><h3 id="Q-缺少-PHP-扩展怎么办-" tabindex="-1">Q: 缺少 PHP 扩展怎么办? <a class="header-anchor" href="#Q-缺少-PHP-扩展怎么办-" aria-label="Permalink to "Q: 缺少 PHP 扩展怎么办?""></a></h3><p>A: 运行 <code>php -m</code> 检查已安装的扩展。缺少的扩展参考 <a href="/zh/quickstart/environment.html">2.1 节</a> 安装。最常见的是缺少 <code>pdo_mysql</code> 和 <code>gd</code>。</p><h3 id="Q-Composer-安装很慢怎么办-" tabindex="-1">Q: Composer 安装很慢怎么办? <a class="header-anchor" href="#Q-Composer-安装很慢怎么办-" aria-label="Permalink to "Q: Composer 安装很慢怎么办?""></a></h3><p>A: 配置中国镜像:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes dracula-soft vitesse-light vp-code" tabindex="0"><code><span class="line"><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"># 配置阿里云 Composer 镜像(加速依赖下载)</span></span>\n<span class="line"><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"># -g → 修改全局配置(所有项目生效)</span></span>\n<span class="line"><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"># repo.packagist → 设置 Packagist 仓库镜像地址</span></span>\n<span class="line"><span style="--shiki-dark:#62E884;--shiki-light:#59873A;">composer</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> config</span><span style="--shiki-dark:#BF9EEE;--shiki-light:#A65E2B;"> -g</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> repo.packagist</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> composer</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> https://mirrors.aliyun.com/composer/</span></span></code></pre></div><h3 id="Q-Redis-不安装可以吗-" tabindex="-1">Q: Redis 不安装可以吗? <a class="header-anchor" href="#Q-Redis-不安装可以吗-" aria-label="Permalink to "Q: Redis 不安装可以吗?""></a></h3><p>A: 可以。Redis 是可选的缓存驱动,不安装时使用 file 缓存。将 <code>.env</code> 中 <code>CACHE.DRIVER</code> 设为 <code>file</code> 即可。</p><h2 id="启动相关" tabindex="-1">启动相关 <a class="header-anchor" href="#启动相关" aria-label="Permalink to "启动相关""></a></h2><h3 id="Q-php-think-run-报错-Address-already-in-use-" tabindex="-1">Q: <code>php think run</code> 报错 "Address already in use" <a class="header-anchor" href="#Q-php-think-run-报错-Address-already-in-use-" aria-label="Permalink to "Q: `php think run` 报错 "Address already in use"""></a></h3><p>A: 端口被占用,更换端口:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes dracula-soft vitesse-light vp-code" tabindex="0"><code><span class="line"><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"># --port → 指定监听端口(默认 8000)</span></span>\n<span class="line"><span style="--shiki-dark:#62E884;--shiki-light:#59873A;">php</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> think</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> run</span><span style="--shiki-dark:#BF9EEE;--shiki-light:#A65E2B;"> --port</span><span style="--shiki-dark:#BF9EEE;--shiki-light:#2F798A;"> 8080</span></span></code></pre></div><h3 id="Q-数据库连接失败-Connection-refused-" tabindex="-1">Q: 数据库连接失败 "Connection refused" <a class="header-anchor" href="#Q-数据库连接失败-Connection-refused-" aria-label="Permalink to "Q: 数据库连接失败 "Connection refused"""></a></h3><p>A: 检查以下几点:</p><ol><li>MySQL 服务是否启动:<code>systemctl status mysql</code></li><li><code>.env</code> 中的数据库配置是否正确</li><li>数据库用户是否有权限:<code>GRANT ALL ON \\</code>rxthinkcmf.thinkphp8.elevue`.* TO 'root'@'localhost'`</li></ol><h3 id="Q-登录返回-401" tabindex="-1">Q: 登录返回 401 <a class="header-anchor" href="#Q-登录返回-401" aria-label="Permalink to "Q: 登录返回 401""></a></h3><p>A: 可能原因:</p><ol><li>Token 过期 → 重新登录</li><li>请求头格式错误 → 确保是 <code>Authorization: Bearer <token></code></li><li>JWT 密钥不匹配 → 检查 <code>.env</code> 中的 <code>JWT.SECRET</code></li></ol><h2 id="前端相关" tabindex="-1">前端相关 <a class="header-anchor" href="#前端相关" aria-label="Permalink to "前端相关""></a></h2><h3 id="Q-pnpm-install-报错" tabindex="-1">Q: <code>pnpm install</code> 报错 <a class="header-anchor" href="#Q-pnpm-install-报错" aria-label="Permalink to "Q: `pnpm install` 报错""></a></h3><p>A: 清除缓存重新安装:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes dracula-soft vitesse-light vp-code" tabindex="0"><code><span class="line"><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"># 删除依赖目录和锁文件,重新安装</span></span>\n<span class="line"><span style="--shiki-dark:#62E884;--shiki-light:#59873A;">rm</span><span style="--shiki-dark:#BF9EEE;--shiki-light:#A65E2B;"> -rf</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> node_modules</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> pnpm-lock.yaml</span><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"> # 删除旧的依赖和锁文件</span></span>\n<span class="line"><span style="--shiki-dark:#62E884;--shiki-light:#59873A;">pnpm</span><span style="--shiki-dark:#E7EE98;--shiki-light:#B56959;"> install</span><span style="--shiki-dark:#7B7F8B;--shiki-light:#A0ADA0;"> # 重新安装所有依赖</span></span></code></pre></div><h3 id="Q-前端请求后端-404" tabindex="-1">Q: 前端请求后端 404 <a class="header-anchor" href="#Q-前端请求后端-404" aria-label="Permalink to "Q: 前端请求后端 404""></a></h3><p>A: 检查以下几点:</p><ol><li>后端服务是否启动</li><li>Vite 代理配置是否正确(<code>vite.config.ts</code> 中的 <code>target</code>)</li><li>API 路径是否正确(应以 <code>/api</code> 开头)</li></ol><h3 id="Q-页面白屏" tabindex="-1">Q: 页面白屏 <a class="header-anchor" href="#Q-页面白屏" aria-label="Permalink to "Q: 页面白屏""></a></h3><p>A: 打开浏览器控制台(F12)查看错误信息,常见原因:</p><ol><li>JS 加载失败 → 检查网络请求</li><li>路由配置错误 → 检查后端菜单数据</li><li>Token 过期 → 重新登录</li></ol><h2 id="Oracle-相关" tabindex="-1">Oracle 相关 <a class="header-anchor" href="#Oracle-相关" aria-label="Permalink to "Oracle 相关""></a></h2><h3 id="Q-ThinkPHP-连接-Oracle-需要哪个-PHP-扩展-" tabindex="-1">Q: ThinkPHP 连接 Oracle 需要哪个 PHP 扩展? <a class="header-anchor" href="#Q-ThinkPHP-连接-Oracle-需要哪个-PHP-扩展-" aria-label="Permalink to "Q: ThinkPHP 连接 Oracle 需要哪个 PHP 扩展?""></a></h3><p>A: 需要 <code>pdo_oci</code> 扩展。ThinkPHP 的 Oracle 连接器通过 PDO 连接数据库(DSN 前缀 <code>oci:dbname=</code>),XAMPP 8.2 已自带 <code>php_pdo_oci.dll</code>,只需在 php.ini 中启用即可。</p><h3 id="Q-XAMPP-下-pdo-oci-扩展加载失败怎么办-" tabindex="-1">Q: XAMPP 下 pdo_oci 扩展加载失败怎么办? <a class="header-anchor" href="#Q-XAMPP-下-pdo-oci-扩展加载失败怎么办-" aria-label="Permalink to "Q: XAMPP 下 pdo_oci 扩展加载失败怎么办?""></a></h3><p>A: 按以下顺序排查:</p><ol><li>是否安装了 Oracle Instant Client 19c(x64)并解压到固定路径</li><li>该路径是否已添加到<strong>系统变量</strong> PATH 中(不是用户变量)</li><li>是否安装了 VC++ 2015-2022 Redistributable(x64)</li><li><code>php.ini</code> 中 <code>extension=pdo_oci</code> 是否已去掉分号</li><li>XAMPP 是否<strong>完全关闭再启动</strong>(不是只点 Apache 的 Start/Stop)</li></ol><h3 id="Q-命令行-php-m-能看到-pdo-oci-但浏览器-phpinfo-里找不到-" tabindex="-1">Q: 命令行 <code>php -m</code> 能看到 pdo_oci,但浏览器 phpinfo() 里找不到? <a class="header-anchor" href="#Q-命令行-php-m-能看到-pdo-oci-但浏览器-phpinfo-里找不到-" aria-label="Permalink to "Q: 命令行 `php -m` 能看到 pdo_oci,但浏览器 phpinfo() 里找不到?""></a></h3><p>A: Apache 作为 Windows 服务运行时,读取的是服务启动时的系统 PATH。如果在 Apache 启动<strong>之后</strong>才修改了 PATH 环境变量,Apache 不会感知到。解决方法:在 XAMPP 控制面板中完全停止 Apache,再重新启动。</p><h3 id="Q-Oracle-Instant-Client-应该下载哪个版本-" tabindex="-1">Q: Oracle Instant Client 应该下载哪个版本? <a class="header-anchor" href="#Q-Oracle-Instant-Client-应该下载哪个版本-" aria-label="Permalink to "Q: Oracle Instant Client 应该下载哪个版本?""></a></h3><p>A: 推荐下载 <strong>19c</strong> 的 <strong>Basic Package</strong>(x64)。下载地址:<a href="https://www.oracle.com/database/technologies/instant-client/downloads.html" target="_blank" rel="noreferrer">https://www.oracle.com/database/technologies/instant-client/downloads.html</a></p><h3 id="Q-为什么-Instant-Client-必须解压到固定路径-" tabindex="-1">Q: 为什么 Instant Client 必须解压到固定路径? <a class="header-anchor" href="#Q-为什么-Instant-Client-必须解压到固定路径-" aria-label="Permalink to "Q: 为什么 Instant Client 必须解压到固定路径?""></a></h3><p>A: 因为系统 PATH 环境变量写入的是绝对路径。如果解压到桌面或下载文件夹,后续清理、移动或重命名都会导致 PATH 失效,PHP 无法加载 Oracle 客户端库。推荐路径:<code>C:\\oracle\\instantclient_19_20</code>。</p>',44)])])}const u=e(l,[["render",o]]);export{k as __pageData,u as default};
|