File tree Expand file tree Collapse file tree 4 files changed +67
-0
lines changed
Expand file tree Collapse file tree 4 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ nodejs作为服务端的drpy实现。全面升级异步写法
2020* [ 本地配置接口-动态外网/局域网] ( /config/1?healthy=1&pwd=$pwd )
2121* [ 其他配置接口-订阅过滤] ( /docs/sub.md )
2222* [ python环境] ( /docs/pyenv.md ) | [ DS项目环境变量说明] ( /docs/envdoc.md )
23+ * php环境(详见 spider/php/readme.md) 不在这里赘述
2324* [ 猫源调试教程] ( /docs/catDebug.md )
2425* [ 接口压测教程] ( /docs/httpTest.md )
2526* [ AI编程工具 trae] ( https://www.trae.ai/account-setting#subscription ) | 邮编ZIP输入: 518000
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ <h3 id="常用超链接">常用超链接</h3>
2323< li > < a href ="/config/1?healthy=1&pwd=dzyyds "> 本地配置接口-动态外网/局域网</ a > </ li >
2424< li > < a href ="/docs/sub.md "> 其他配置接口-订阅过滤</ a > </ li >
2525< li > < a href ="/docs/pyenv.md "> python环境</ a > | < a href ="/docs/envdoc.md "> DS项目环境变量说明</ a > </ li >
26+ < li > php环境(详见 spider/php/readme.md) 不在这里赘述</ li >
2627< li > < a href ="/docs/catDebug.md "> 猫源调试教程</ a > </ li >
2728< li > < a href ="/docs/httpTest.md "> 接口压测教程</ a > </ li >
2829< li > < a href ="https://www.trae.ai/account-setting#subscription "> AI编程工具 trae</ a > | 邮编ZIP输入: 518000</ li >
Original file line number Diff line number Diff line change 22
33本文档总结了基于 ` spider.php ` 框架开发、调试、转换 PHP 爬虫源的核心经验与最佳实践。旨在帮助开发者快速上手,并作为后续开发的参考手册。
44
5+ ## 0. 环境搭建 (Windows)
6+
7+ 为了运行和调试 PHP 爬虫,需要在本地配置 PHP 环境。推荐使用 PHP 8.3+ NTS (Non Thread Safe) 版本。
8+
9+ ### 0.1 下载与安装
10+ 1 . ** 下载 PHP** :
11+ 可以直接点击下载推荐版本:
12+ [ php-8.3.29-nts-Win32-vs16-x64.zip] ( https://windows.php.net/downloads/releases/php-8.3.29-nts-Win32-vs16-x64.zip )
13+ 2 . ** 解压** :
14+ 将下载的压缩包解压到固定目录,例如 ` C:\php ` (建议路径不包含空格和中文)。
15+ 3 . ** 配置环境变量** :
16+ - 右键 "此电脑" -> "属性" -> "高级系统设置" -> "环境变量"。
17+ - 在 "系统变量" 中找到 ` Path ` ,点击 "编辑"。
18+ - 点击 "新建",输入你的 PHP 解压路径 (如 ` C:\php ` )。
19+ - 连续点击 "确定" 保存设置。
20+
21+ ### 0.2 配置 php.ini
22+ 1 . 进入 PHP 解压目录,找到 ` php.ini-development ` 文件,复制一份并重命名为 ` php.ini ` 。
23+ 2 . 使用文本编辑器打开 ` php.ini ` ,查找并修改以下配置 (去掉行首的 ` ; ` 分号以启用):
24+ ``` ini
25+ ; 指定扩展目录
26+ extension_dir = " ext"
27+
28+ ; 启用核心扩展 (爬虫必须)
29+ extension =curl
30+ extension =mbstring
31+ extension =openssl
32+ extension =sockets
33+ ```
34+ 3. **验证安装**:
35+ 打开新的 CMD 或 PowerShell 窗口,输入 `php -v`。
36+ 如果看到类似 `PHP 8.3.29 (cli) ...` 的输出,即表示环境配置成功。
37+
38+ # # 0.5 环境搭建 (Linux/Ubuntu - 升级至 PHP 8.3)
39+
40+ 如果您在 Linux 环境(如 Ubuntu/Debian)下使用,建议通过 PPA 源安装或升级到 PHP 8.3。
41+
42+ # ## 0.5.1 卸载旧版 (可选)
43+ 如果系统中已安装旧版(如 PHP 8.1),建议先卸载以避免冲突:
44+ ```bash
45+ sudo apt purge php8.1* -y
46+ sudo apt autoremove -y
47+ ```
48+
49+ ### 0.5.2 添加 PPA 源
50+ 使用 Ondřej Surý 的 PPA 源获取最新 PHP 版本:
51+ ``` bash
52+ sudo apt install software-properties-common -y
53+ sudo add-apt-repository ppa:ondrej/php -y
54+ sudo apt update
55+ ```
56+
57+ ### 0.5.3 安装 PHP 8.3 及扩展
58+ 安装 CLI 版本及 Drpy 爬虫所需的常用扩展 (curl, mbstring, xml, mysql 等):
59+ ``` bash
60+ # 注意:openssl 通常已包含在核心或 common 包中,无需单独指定 php8.3-openssl
61+ sudo apt install php8.3-cli php8.3-curl php8.3-mbstring php8.3-xml php8.3-mysql -y
62+ ```
63+
64+ ### 0.5.4 验证安装
65+ ``` bash
66+ php -v
67+ # 输出应显示 PHP 8.3.x
68+ ```
69+
570## 1. 核心架构与工具
671
772### 1.1 基础框架 (` lib/spider.php ` )
You can’t perform that action at this time.
0 commit comments