一步步教你如何搭建php8环境(附常见问题解决办法)

广告:宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取~~~

一步步教你如何搭建php8环境(附常见问题解决办法)

本篇文章由php8教程栏目给大家详细介绍如何一步步搭建php8环境,希望对大家有所帮助。

一、下载

1、https://www.php.net/distributions/php-8.0.0.tar.gz下载到本地,文件传输上传到 /usr/local/src/

2、wget -P /usr/local/src/ https://www.php.net/distributions/php-8.0.0.tar.gz

二、解压、编译、安装

1、解压缩

> cd /usr/local/src/> tar xzf php-8.0.0.tar.gz> cd php-8.0.0
登录后复制

2、配置编译参数,参考https://www.php.net/manual/zh... 选择自己需要的选项

./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
登录后复制

问题1:

configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:Package 'libxml-2.0', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables LIBXML_CFLAGSand LIBXML_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.
登录后复制

问题1解决:

> yum install libxml2-devel
登录后复制

问题2:

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
登录后复制

问题2解决:

> yum install sqlite-devel
登录后复制

问题3:

configure: error: Package requirements (libcurl >= 7.29.0) were not met:
登录后复制

问题3解决:

> yum install libcurl-devel
登录后复制

问题4:

configure: error: Package requirements (libpng) were not met:
登录后复制

问题4解决:

> yum install libpng libpng-devel
登录后复制

问题5:

./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-cgi0
登录后复制

问题5解决:

./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-cgi1
登录后复制

问题6:

./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-cgi2
登录后复制

问题6解决:

./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-cgi3
登录后复制

配置编译参数成功

./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-cgi4
登录后复制

3、编译源码

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

4、安装

./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-cgi5
登录后复制

安装成功

[root@54skyer php-8.0.0]# ./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-cgi5Installing 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-configInstalling 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.pharln -s -f phar.phar /usr/local/php8/bin/pharInstalling PDO headers:           /usr/local/php8/include/php/ext/pdo/
登录后复制

5、添加环境变量

./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-cgi7
登录后复制

6、获取默认配置

./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-cgi8
登录后复制

7、开机自启动

设置命令可被执行

./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-cgi9
登录后复制

检验自启动脚本

configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:Package 'libxml-2.0', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables LIBXML_CFLAGSand LIBXML_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.0
登录后复制

7、额外说明

关于配置文件的一些说明

php-fpm.conf是PHP-FPM特有的配置文件

php.ini是所有php模式中必须的配置文件

两者的区别是,php-fpm.conf是PHP-FPM进程管理器的配置文件,php.ini是PHP解析器的配置文件

有的PHP版本的配置文件路径中还有/fpm.d/www.conf配置文件

这是php-fpm.conf配置的文件的扩展文件,可以打开php-fpm.conf文件查看

configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:Package 'libxml-2.0', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables LIBXML_CFLAGSand LIBXML_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.1
登录后复制

我们可以使用php-fpm.conf配置慢日志

我们是可以开启慢日志功能的。

configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:Package 'libxml-2.0', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables LIBXML_CFLAGSand LIBXML_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.2
登录后复制

以上就是一步步教你如何搭建php8环境(附常见问题解决办法)的详细内容,更多请关注9543建站博客其它相关文章!

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。

作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:css 设置a
下一篇:详解Laravel资源路由的删除操作

发表评论

关闭广告
关闭广告