一、准备工作
首先安装依赖。
1
2
liuxu:~$ sudo apt-get update
liuxu:~$ sudo apt-get install git build-essential libgccjit-6-dev libzip-dev autoconf re2c bison libxml2-dev sqlite3 libsqlite3-dev -y
下载php代码。
1
2
3
liuxu:~$ cd ~
liuxu:~$ git clone https://github.com/php/php-src.git
liuxu:~$ cd php-src
二、配置编译安装
配置configure文件,这里把php安装目录设置为/opt/php/php8
。
1
2
liuxu:~/php-src$ ./buildconf
liuxu:~/php-src$ ./configure --prefix=/opt/php/php8 --enable-opcache --with-zlib --enable-json --enable-sockets --without-pear
先看看CPU有几个核心。
1
2
liuxu:~/php-src$ nproc
16
开始编译。
1
liuxu:~/php-src$ make -j17
安装。
1
liuxu:~/php-src$ sudo make install
配置opcode。
1
2
3
4
liuxu:~$ cd /opt/php/php8/lib
liuxu:/opt/php/php8/lib$ sudo touch php.ini
liuxu:/opt/php/php8/lib$ echo 'zend_extension=opcache.so' | sudo tee php.ini
zend_extension=opcache.so
三、安装完成
1
2
3
4
PHP 8.0.0-dev (cli) (built: Sep 10 2019 10:12:40) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.0.0-dev, Copyright (c), by Zend Technologies