|
== 本页列出站点常用维护脚本 ==及适用场景。执行前请先备份数据库。
这些脚本涉及到数据库优化、文件清理、索引重建、权限更新等操作,通常是为了确保 MediaWiki 实例能够稳定运行,并且提升性能和响应速度。
== 数据库优化与更新 ==
== 常用脚本 ==
<syntaxhighlight lang="bash">
# 更新数据库架结构(快速模式,不做过多检查)
php maintenance/run.php update.php --quick
# 重建数据库中的“最近更改”记录
php maintenance/run.php rebuildrecentchanges.php
# 重建所有内容(页面、修订、文件等)
php maintenance/run.php rebuildallrefreshLinks.php
# 重建全文本索引(用于全文搜索)
php maintenance/run.php rebuildtextindex.php
# 执行队列任务
php maintenance/run.php refreshLinksrunJobs.php
# 清理无效的页面标题(干运行模式,仅模拟,不做实际修改)
php maintenance/run.php cleanupTitles.php --dry-run
</syntaxhighlight>
== 运行提示使用建议 ==
* 维护窗口执行,避免业务高峰。
* 先在测试环境验证脚本副作用。
* 使用服务器上的 PHP CLI 执行维护脚本,通常用 <code>php maintenance/run.php 脚本名</code>,避免通过 Web 访问。
* 记录执行时间、参数和结果,便于追踪。
* 如果站点部署了多个 PHP 版本,可先运行 <code>php -v</code> 或指定完整路径(如 <code>/usr/bin/php8.2</code>)以确保使用与 Wiki 一致的运行时。
* 对于耗时的脚本(如 rebuildtextindex.php、rebuildrecentchanges.php),建议在流量低峰期执行,并记录输出、检查 <code>maintenance/logs</code>。
* 不确定命令合适时,可先添加 <code>--help</code> 或 <code>--dry-run</code> 选项查看安全性,例如:<code>php maintenance/run.php deleteOldRevisions.php --dry-run</code>。
== 分类和页面维护 ==
<syntaxhighlight lang="bash">
# 删除过期的修订记录,减少数据库体积(干运行模式,仅模拟,不做实际删除)
php maintenance/run.php deleteOldRevisions.php --dry-run
</syntaxhighlight>
== 作业与后台处理 ==
<syntaxhighlight lang="bash">
# 手动执行所有后台作业,确保没有待处理的作业(如图片处理、邮件发送等)
php maintenance/run.php runJobs.php
</syntaxhighlight>
{{Template:站点帮助文档}}
[[Category:帮助文档]]
|