Home Backend Development PHP8 Teach you how to build a php8 environment from scratch

Teach you how to build a php8 environment from scratch

Mar 15, 2021 pm 05:30 PM
php php8

Recommended: "PHP8 Tutorial"

Build a php environment from scratch-php8

1. Download

1, https://www.php.net/distributions/php-8.0.0.tar.gz Download to local, file transfer upload 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. Unzip

1

2

3

> cd /usr/local/src/

> tar xzf php-8.0.0.tar.gz

> cd php-8.0.0

Copy after login

2. Configure compilation parameters, refer to https://www.php.net/manual/zh/configure.about.php to choose what you need Options

1

./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

Copy after login

Problem 1:

1

2

3

4

5

6

7

8

9

10

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.

Copy after login

Problem 1 solved:

1

> yum install libxml2-devel

Copy after login

Problem 2:

1

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

Copy after login

Problem 2 solved:

1

> yum install sqlite-devel

Copy after login

Problem 3:

1

configure: error: Package requirements (libcurl >= 7.29.0) were not met:

Copy after login

Problem 3 solution:

1

> yum install libcurl-devel

Copy after login

Problem 4:

1

configure: error: Package requirements (libpng) were not met:

Copy after login

Problem 4 solution:

1

> yum install libpng libpng-devel

Copy after login

Problem 5:

1

configure: error: Package requirements (oniguruma) were not met:

Copy after login

Solved problem 5:

1

2

3

4

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

Copy after login

Problem 6:

1

configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

Copy after login

Solved problem 6:

1

> yum install libzip libzip-devel

Copy after login

Configuring compilation parameters successfully

1

2

3

4

5

6

7

8

9

10

+--------------------------------------------------------------------+

| 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.

Copy after login

3. Compile source code

1

> make -j2 # 这里是依赖系统cpu核心数进行编译,对性能有一定提升,通常利用核心数不要超过一半,

Copy after login

4. Installation

1

make install

Copy after login

Successful installation

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

[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/

Copy after login

5. Add environment variables

1

2

3

4

5

6

7

8

9

10

11

> 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

Copy after login

6. Get the default configuration

1

2

3

4

5

6

7

8

// 复制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

Copy after login

7. Auto-start at boot
The setting command can be executed

1

chmod +x /etc/init.d/php-fpm # 添加可执行权限

Copy after login

Check the auto-start script

1

2

3

4

5

6

7

8

9

10

11

12

13

> 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

Copy after login

7. Additional instructions
For some instructions on the configuration file, please refer to: https:// www.cnblogs.com/xiaozong/p/5724984.html
php-fpm.conf is a configuration file unique to PHP-FPM
php.ini is a necessary configuration file in all php modes
Both The difference is that php-fpm.conf is the configuration file of the PHP-FPM process manager, and php.ini is the configuration file of the PHP parser.

Some PHP versions also have /fpm.d in the configuration file path. /www.conf configuration file

This is the extension file of the file configured by php-fpm.conf. 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 how to build a php8 environment from scratch. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

See all articles