源码编译安装PHP

查看可用的参数

./configure –help

编译安装

MacOS

1
2
3
4
5
6
7
8
9
./configure --enable-fpm  --with-openssl=/usr/local/Cellar/[email protected]/1.1.1i/ \
--enable-bcmath --with-curl --enable-exif --with-mysqli --with-pdo-mysql \
--enable-zip --with-zlib=/usr/local/Cellar/zlib/1.2.11/ --enable-intl --enable-pcntl --enable-mbstring --enable-soap \
--with-icu-dir=/usr/local/Cellar/icu4c/67.1 \
--with-iconv=/usr/local/Cellar/libiconv/1.16 \
--with-libxml-dir=/usr/local/Cellar/libxml2/2.9.10_2

make
sudo make install

./configure –enable-debug 如果需要 debug 版本的

Linux

1
2
3
4
5
./configure --enable-fpm  --with-openssl \
--enable-bcmath --with-curl --enable-exif --with-mysqli --with-pdo-mysql \
--enable-zip --with-zlib --enable-intl --enable-pcntl --enable-mbstring --enable-soap
make
sudo make install

配置文件

1
2
3
4
5
6
# /usr/local/etc/
sudo cp php-fpm.conf.default php-fpm.conf


# /usr/local/etc/php-fpm.d
sudo cp www.conf.default www.conf

修改 php-fpm.conf 的最后一行

1
include=/usr/local/etc/php-fpm.d/*.conf

部分问题

Unable to detect ICU prefix or no failed. Please verify ICU install prefix

1
./configure --with-icu-dir=/usr/local/Cellar/icu4c/63.1

php.ini

1
2
3
4
5
6
7
8
extension=mongodb.so
extension=swoole.so
extension=yaf.so

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9001