Home > Backend Development > PHP8 > body text

PHP 8.0 source code compilation and installation and JIT early adopter

Guanhui
Release: 2023-02-17 11:28:01
forward
6051 people have browsed it

Special Skills Guide

PHP 8.0 Alpha 1 has been released on June 25, 2020. Today I will share with you the most simplified PHP 8 Source code compilation and installation method to quickly try out the new feature JIT of PHP 8.0.

  • Operating system: CentOS Linux release 7.4.1708 (Core)

  • GCC: 4.8.5 20150623 (Red Hat 4.8.5-28 )

  • PHP version: php-8.0.0alpha1

1. Download page

https://downloads.php.net/~pollita/
Copy after login

2. Download PHP 8.0

wget https://downloads.php.net/~pollita/php-8.0.0alpha1.tar.gz
Copy after login

3. Unzip

tar -zxvf php-8.0.0alpha1.tar.gz
Copy after login

4. Create a new installation directory

Since multiple PHP versions coexist on this machine, it is necessary to create a meaningful directory, a directory name that can be known without thinking about the PHP version.

 mkdir -p /usr/local/php80
Copy after login

5. configure options

This is a simplified version of the configuration options, a richer description of PHP configuration options: https://www.php.net/manual /en/configure.about.php

 cd php-8.0.0alpha1 
 ./configure --prefix=/usr/local/php80/ --enable-debug --enable-fpm  --with-config-file-path=/usr/local/php80/etc/ --with-config-file-scandir=/usr/local/php80/etc/php.d/
Copy after login

If you encounter the prompt configure: error during the configure process, pay attention to the error details below. The following lists a summary of key information for error conditions that occur during the configuration process. For other error conditions not listed, the solutions are the same:

Error #1:

configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met: 
No package 'libxml-2.0' found
Copy after login

Solution:

yum install libxml2-devel.x86_64
Copy after login

Error #2:

configure: error: Package requirements (sqlite3 > 3.7.4) were not met: 
No package 'sqlite3' found
Copy after login

Solution:

yum install sqlite-devel.x86_64
Copy after login

If you see the following prompt message, it means that the configure step has been successful.

PHP 8.0 source code compilation and installation and JIT early adopter

6. Compilation & Installation

 make
Copy after login

The time consumed in the make phase is related to the machine configuration. If you see the following information, Indicates that the make phase has been completed.

Build complete. 
Don't forget to run 'make test'.
Copy after login

make test Since this is an early adopter, this step is omitted.

 make install
  exit 0;  -v -d /home/fanjiapeng/php-8.0.0alpha1/Zend/zend_ini_parser.y -o
  /home/fanjiapeng/php-8.0.0alpha1/Zend/zend_ini_parser.c
  Installing shared extensions:     
  /usr/local/php80/lib/php/extensions/debugnon-zts-20190128/ 
  Installing PHP CLI binary:        /usr/local/php80/bin/ 
  Installing PHP CLI man page:      /usr/local/php80/php/man/man1/ 
  Installing PHP FPM binary:        /usr/local/php80/sbin/ 
  Installing PHP FPM defconfig:     /usr/local/php80/etc/ 
  Installing PHP FPM man page:      /usr/local/php80/php/man/man8/ 
  Installing PHP FPM status page:   /usr/local/php80/php/php/fpm/ 
  Installing phpdbg binary:         /usr/local/php80/bin/ 
  Installing phpdbg man page:       /usr/local/php80/php/man/man1/ 
  Installing PHP CGI binary:        /usr/local/php80/bin/ 
  Installing PHP CGI man page:      /usr/local/php80/php/man/man1/ 
  Installing build environment:     /usr/local/php80/lib/php/build/ 
  Installing header files:          /usr/local/php80/include/php/ 
  Installing helper programs:       /usr/local/php80/bin/   
  program: phpize   
  program: php-config 
  Installing man pages:             /usr/local/php80/php/man/man1/   
  page: phpize.1   
  page: php-config.1 
  /home/fanjiapeng/php-8.0.0alpha1/build/shtool install -c ext/phar/phar.phar /usr/local/php80/bin/phar.phar 
  ln -s -f phar.phar /usr/local/php80/bin/phar 
  Installing PDO headers:           /usr/local/php80/include/php/ext/pdo/
Copy after login

7. Verify PHP

/usr/local/php80/bin/php -v 
 PHP 8.0.0alpha1 (cli) (built: Jul  2 2020 15:47:26) ( NTS DEBUG ) 
Copyright (c) The PHP Group
 Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
Copy after login

8. Environment configuration

ln -s /usr/local/php80/bin/php /usr/bin/php80 
cp php.ini-development /usr/local/php80/etc/php.ini
cp /usr/local/php80/etc/php-fpm.conf.default /usr/local/php80/etc/phpfpm.conf
cp /usr/local/php80/etc/php-fpm.d/www.conf.default /usr/local/php80/etc/php-fpm.d/www.conf 
cp sapi/fpm/init.d.php-fpm /etc/init.d/php80-fp
chmod +x /etc/init.d/php80-fpm
Copy after login

9. Verify configuration path

Verify whether the customized configuration items take effect: --with-config-file-path, --with-config-file-scan-dir

php80 --ini 
Configuration File (php.ini) Path: /usr/local/php80/etc/ 
Loaded Configuration File:         /usr/local/php80/etc/php.ini 
Scan for additional .ini files in: /usr/local/php80/etc/php.d/ 
Additional .ini files parsed:      (none)
Copy after login

10, Start FPM

/etc/init.d/php80-fpm 
start Starting php-fpm  done
Copy after login

11. Verify FPM

ps aux | grep php-fpm 
root     26876  0.0  0.0  52084  2828 ?        Ss   Jul02   0:14 php-fpm: 
master process (/usr/local/php80/etc/php-fpm.conf) 
nobody   26877  0.0  0.0  52084  3648 ?        S    Jul02   0:00 php-fpm: 
pool www 
nobody   26878  0.0  0.0  52084  3624 ?        S    Jul02   0:00 php-fpm: pool www 
/etc/init.d/php80-fpm -h 
Usage: /etc/init.d/php80-fpm {start|stop|forcequit|restart|reload|status|configtest} 
/etc/init.d/php80-fpm status 
php-fpm (pid 26876) is running... 
/etc/init.d/php80-fpm configtest 
[06-Jul-2020 11:06:42] NOTICE: configuration file /usr/local/php80/etc/php
fpm.conf test is successful
Copy after login

The Nginx configuration details are omitted here, mainly to quickly test whether the installed PHP-FPM mode is available of.

// index.php 
<?php 
var_dump(PHP_VERSION); 
var_dump(PHP_VERSION_ID);
Copy after login
curl localhost 
string(11) "8.0.0alpha1" 
int(80000)
Copy after login

12. Try new features JIT

Machine configuration: 8-core 16G, SATA disk, operating system: CentOS Linux release 7.4.1708 (Core)

Zend OPCache (/usr/local/php80/etc/php.ini) is configured as follows. Most of the [opcache] configuration items have default values. In order to highlight the importance of these configuration items, they are listed:

; 加载 Zend OPCache 扩展 
zend_extension=opcache 
; 启用 Zend OPCache 
opcache.enable=1 
; 启用 Zend OPCache,在 CLI 模式下 
opcache.enable_cli=1
 ; OPCache 共享内存存储大小,默认值 128 
 opcache.memory_consumption=128 
 ; interned string 内存大小,默认值 8 
 opcache.interned_strings_buffer=8 
 ; 缓存脚本文件数量的上限,默认值 10000 
 opcache.max_accelerated_files=10000 
; 10秒检查一次文件的更新,默认值 2s 
opcache.revalidate_freq=10 
; 删除所有 PHPDoc 注释,默认值 1,表示保留注释 
opcache.save_comments=0
Copy after login

This is a virtual machine with idle resources. After repeatedly turning on JIT and turning off JIT many times, the test results show that there is almost no change in the result value. The test results did not specifically select the most beautiful data. In fact, there is no need. As shown in the figure below:

PHP 8.0 source code compilation and installation and JIT early adopter

13. Summary

This is a general PHP source code compilation and installation method. Other PHP versions can be compiled The installation method is similar. In actual business applications, the configure options are much richer, and the class libraries that need to be installed will be more comprehensive. In this article, the new feature JIT of PHP 8 is tested. According to the test results of Zend/bench.php, it is still eye-catching. For an introduction to PHP 8 JIT, we recommend "PHP8 New Features JIT Usage Introduction".

Recommended article: "PHP8.0"

The above is the detailed content of PHP 8.0 source code compilation and installation and JIT early adopter. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template