successgo / blog

This is Success Go's blog.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RPS-1: 环境搭建

successgo opened this issue · comments

环境搭建

PHP 是使用 C 语言写,编译 PHP 跟编译其他的 C 语言项目类似,那就是三部曲:

  • ./configure
  • make
  • make install

Get PHP source code

PHP 源码项目用 github.com 托管。项目地址是:https://github.com/php/php-src

PHP 官网地址:https://php.net

configure

configure 脚本用于配置编译参数。

它有哪些参数? 通过命令 ./configure --help 获取。

$ ./configure --disable-all

本节为了加快编译速度,使用 --disable-all 禁止了所有的扩展。
稍后有需要,再重新指定参数,再编译。

使用 git 迁出的代码库没有生成 configure 脚本,我们需要执行命令 ./buildconf 生成。
而从 php.net 官网下载的 PHP 代码则有 ./configure 脚本。

make

$ make -j$(nproc)

nproc 用于获取 cpu 的核心数。

make -j 用于指定同时进行的任务个数,一般不要超过 cpu 的核心数。

*make install

make install 是安装命令,将编译好的文件复制到相应的目录。在本次学习中,这是可选的操作。

结果

本次编译好的 php 位于 sapi/cli/php

$ ./sapi/cli/php -v

FAQs

Add later.