


This article is provided by the php8 tutorial column to give you a detailed introduction on how to build a php8 environment step by step. I hope it will be helpful to everyone.
1. Download
1. Download https://www.php.net/distributions/php-8.0.0.tar.gz locally and upload the file to /usr/local /src/
2. wget -P /usr/local/src/ https://www.php.net/distributions/php-8.0.0.tar.gz
2. Unzip, compile, install
1, decompress
> cd /usr/local/src/ > tar xzf php-8.0.0.tar.gz > cd php-8.0.0
2, configure compilation parameters, refer to https://www.php.net/manual/zh... to choose the options you need
./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-openssl --with-mysqli --with-pdo-mysql --with-iconv --with-mhash --with-zlib --enable-mbstring --enable-gd --enable-gd-jis-conv --enable-sockets --enable-fpm --enable- --enable-xml --enable-pdo --enable-cli --enable-pcntl --enable-soap --enable-opcache --enable-fileinfo --disable-rpath --enable-mysqlnd --with-zip --enable-simplexml --with-libxml --with-sqlite3 --with-pdo-sqlite --enable-phar --enable-tokenizer --enable-cgi
Problem 1:
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met: Package 'libxml-2.0', required by 'virtual:world', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBXML_CFLAGS and LIBXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
Problem 1 solved:
> yum install libxml2-devel
Problem 2:
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
Problem 2 solved:
> yum install sqlite-devel
Problem 3:
configure: error: Package requirements (libcurl >= 7.29.0) were not met:
Problem 3 solved:
> yum install libcurl-devel
Problem 4:
configure: error: Package requirements (libpng) were not met:
Problem 4 solved:
> yum install libpng libpng-devel
Problem 5:
configure: error: Package requirements (oniguruma) were not met:
Solution to problem 5:
> cd /usr/local/src/ > wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic/liboniguruma5-6.9.6-alt1.x86_64.rpm -O liboniguruma5-6.9.6-alt1.x86_64.rpm > rpm -ivh liboniguruma5-6.9.6-alt1.x86_64.rpm > wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic/liboniguruma-devel-6.9.6-alt1.x86_64.rpm -O liboniguruma-devel-6.9.6-alt1.x86_64.rpm > rpm liboniguruma-devel-6.9.6-alt1.x86_64.rpmcli
Problem 6:
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
Solution to problem 6:
> yum install libzip libzip-devel
Configuring compilation parameters successfully
+--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP.
3. Compile source code
> make -j2 # This compilation relies on the number of system CPU cores, which will improve performance to a certain extent. Generally, the number of cores should not exceed half.
4. Installation
make install
Installation successful
[root@54skyer php-8.0.0]# make install Installing shared extensions: /usr/local/php8/lib/php/extensions/no-debug-non-zts-20200930/ Installing PHP CLI binary: /usr/local/php8/bin/ Installing PHP CLI man page: /usr/local/php8/php/man/man1/ Installing PHP FPM binary: /usr/local/php8/sbin/ Installing PHP FPM defconfig: /usr/local/php8/etc/ Installing PHP FPM man page: /usr/local/php8/php/man/man8/ Installing PHP FPM status page: /usr/local/php8/php/php/fpm/ Installing phpdbg binary: /usr/local/php8/bin/ Installing phpdbg man page: /usr/local/php8/php/man/man1/ Installing PHP CGI binary: /usr/local/php8/bin/ Installing PHP CGI man page: /usr/local/php8/php/man/man1/ Installing build environment: /usr/local/php8/lib/php/build/ Installing header files: /usr/local/php8/include/php/ Installing helper programs: /usr/local/php8/bin/ program: phpize program: php-config Installing man pages: /usr/local/php8/php/man/man1/ page: phpize.1 page: php-config.1 /usr/local/src/php-8.0.0/build/shtool install -c ext/phar/phar.phar /usr/local/php8/bin/phar.phar ln -s -f phar.phar /usr/local/php8/bin/phar Installing PDO headers: /usr/local/php8/include/php/ext/pdo/
5. Add environment variables
> vim /etc/profile # 在文件末尾加入 # PATH=$PATH:/usr/local/php8/bin/ # export PATH # :wq 保存并退出 > source /etc/profile # 立刻生效配置 > php -v # 获得如下信息 php -v PHP 8.0.0 (cli) (built: Dec 15 2020 02:46:59) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
6. Obtain default configuration
// 复制php.ini到编译配置参数指定的目录。php.ini在解压的源码目录里 > cp /usr/local/src/php-8.0.0/php.ini-production /usr/local/php8/etc/php.ini // 复制一份php-fpm的配置模版文件到同级目录 方便备份和修改 > cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf // 复制一份php-fpm的扩展配置模板文件到同级目录 方便备份和修改 > cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf // 复制开启自起脚本到系统启动自动加载脚本目录。fpm/init.d.php-fpm在解压的源码目录里 > cp /usr/local/src/php-8.0.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
7. Start automatically after booting
The setting command can be executed
> chmod +x /etc/init.d/php-fpm # 添加可执行权限
Check the self-starting script
> service php-fpm start # 检验服务启动 > service php-fpm stop # 检验服务关闭 // 均正常提示 > chkconfig php-fpm on # 设置开机自动执行php-fpm开机自启动脚本 > reboot # 重启,ssh重连 # 重启后 [root@54skyer ~]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1097/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1061/sshd tcp 0 0 0.0.0.0:16379 0.0.0.0:* LISTEN 1090/redis-server 0 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1083/php-fpm: maste
7. Additional instructions
Some instructions about the configuration file
php-fpm.conf is unique to PHP-FPM Configuration file
php.ini is a necessary configuration file in all php modes
The difference between the two is that php-fpm.conf is the configuration file of the PHP-FPM process manager, php. ini is the configuration file of the PHP parser
Some PHP versions also have the /fpm.d/www.conf configuration file in the configuration file path
This is configured by php-fpm.conf File extension file, you can open the php-fpm.conf file to view
; include=fpm.d/*.conf
We can use php-fpm.conf to configure the slow log
We can enable the slow log function.
slowlog = /usr/local/var/log/php-fpm.log.slow request_slowlog_timeout = 5s
The above is the detailed content of Teach you step by step how to set up a php8 environment (with solutions to common problems). For more information, please follow other related articles on the PHP Chinese website!

php8加mysql扩展的步骤是:1、安装MySQL客户端库;2、安装PHP 8的开发工具;3、下载MySQL扩展源代码;4、编译和安装MySQL扩展;5、启用MySQL扩展;6、重启Web服务器即可。

php5和php8的区别在性能、语言结构、类型系统、错误处理、异步编程、标准库函数和安全性等方面。详细介绍:1、性能提升,PHP8相对于PHP5来说在性能方面有了巨大的提升,PHP8引入了JIT编译器,可以对一些高频执行的代码进行编译和优化,从而提高运行速度;2、语言结构改进,PHP8引入了一些新的语言结构和功能,PHP8支持命名参数,允许开发者通过参数名而不是参数顺序等等。

本文给大家介绍如何安装apache2.4,以及如何配置php8.0,文中附有图文详细步骤,下面就带大家一起看看怎么安装配置apache2.4+php8.0吧~

php8数据类型的方法有字符串转换为整数、整数转换为字符串、字符串转换为浮点数、浮点数转换为字符串、数组转换为字符串、字符串转换为数组、布尔值转换为整数、整数转换为布尔值和变量类型判断和转换。详细介绍:1、字符串转换为整数包括intval()函数和(int)强制类型转换;2、整数转换为字符串包括strval()函数和(string)强制类型转换;3、字符串转换为浮点数等等。

PHP8可以使用mysqli和PDO来连接数据库。详细介绍:1、使用mysqli连接数据库,通过传入数据库服务器名称、用户名、密码和数据库名称来进行连接。然后,使用`connect_error`属性来检查连接是否成功,如果连接失败,则输出错误信息。最后,通过调用`close()`方法关闭连接;2、使用PDO连接数据库,通过传入数据库服务器名称、密码和数据库名称来进行连接等等。

php8提高的性能包括:1、JIT编译器的引入;2、函数调用的优化;3、垃圾回收机制的改进;4、类型系统的改进;5、新的语言特性;6、优化字符串处理;7、改进数组处理;8、引入新的内存管理机制;9、优化代码生成。详细介绍:1、JIT编译器的引入,PHP8引入了JIT编译器,这是一种动态编译技术,能够将PHP代码转换为机器码,以便更高效地执行;2、函数调用的优化等等。

PHP8相较于PHP7在性能、新特性和语法改进、类型系统、错误处理和扩展等方面都有一些优势和改进。然而,选择使用哪个版本要根据具体的需求和项目情况来决定。详细介绍:1、性能提升,PHP8引入了Just-in-Time(JIT)编译器,可以提高代码的执行速度;2、新特性和语法改进,PHP8支持命名参数和可选参数的声明,使得函数调用更加灵活;引入了匿名类、属性的类型声明等等。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
