Maison > développement back-end > PHP8 > le corps du texte

Vous apprendre étape par étape comment configurer un environnement php8 (avec des solutions aux problèmes courants)

藏色散人
Libérer: 2023-02-17 12:44:01
avant
5573 Les gens l'ont consulté

Cet article est fourni par la colonne php8tutorial pour vous donner une introduction détaillée sur la façon de créer un environnement php8 étape par étape. J'espère qu'il sera utile à tout le monde.

1. Téléchargez

1. Téléchargez https://www.php.net/distributions/php-8.0.0.tar.gz localement, transférez le fichier et téléchargez-le sur /usr/local/src/

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

2 Décompressez, compilez, installez

1. . Configurez les paramètres de compilation, reportez-vous à https://www.php.net/manual/zh... Sélectionnez les options dont vous avez besoin

> cd /usr/local/src/
> tar xzf php-8.0.0.tar.gz
> cd php-8.0.0
Copier après la connexion

Question 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
Copier après la connexion

Question 1 solution :

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.
Copier après la connexion

Question 2 :

> yum install libxml2-devel
Copier après la connexion

Question 2 résolue :

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
Copier après la connexion

Numéro 3 :

> yum install sqlite-devel
Copier après la connexion

Numéro 3 résolu :

configure: error: Package requirements (libcurl >= 7.29.0) were not met:
Copier après la connexion

Numéro 4 :

> yum install libcurl-devel
Copier après la connexion

Numéro 4 résolu :

configure: error: Package requirements (libpng) were not met:
Copier après la connexion

Numéro 5 :

> yum install libpng libpng-devel
Copier après la connexion

Numéro 5 résolu :

Numéro 6 :

configure: error: Package requirements (oniguruma) were not met:
Copier après la connexion

Solution au problème 6 :

> 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
Copier après la connexion

Configurez les paramètres de compilation avec succès

configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
Copier après la connexion

3. Compilez le code source

> make -j2 # Cette compilation dépend du nombre de cœurs de processeur du système, ce qui améliorera généralement les performances. le nombre de cœurs ne doit pas dépasser la moitié

4. Installation

> yum install libzip libzip-devel
Copier après la connexion

Installation réussie

+--------------------------------------------------------------------+
| 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.
Copier après la connexion

5. Ajouter des variables d'environnement

make install
Copier après la connexion

6. Obtenir la configuration par défaut

[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/
Copier après la connexion

7. être exécuté

> 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
Copier après la connexion

Vérifiez le script de démarrage automatique

// 复制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
Copier après la connexion

7 Instructions supplémentaires

Quelques notes sur le fichier de configuration

php-fpm.conf est un fichier de configuration unique à PHP-FPM

php.ini est nécessaire fichier de configuration dans tous les modes PHP

La différence entre les deux est que php-fpm.conf est le fichier de configuration du gestionnaire de processus PHP-FPM et php.ini est le fichier de configuration de l'analyseur PHP

Certaines versions de PHP également avoir le fichier de configuration /fpm.d/www.conf dans le chemin du fichier de configuration

Il s'agit d'un fichier d'extension du fichier configuré par php-fpm.conf Vous pouvez ouvrir le fichier php-fpm.conf pour voir

> chmod +x /etc/init.d/php-fpm # 添加可执行权限
Copier après la connexion

. Nous pouvons utiliser php-fpm.conf pour configurer le journal lent

Nous pouvons activer la fonction de journal lent.

> 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
Copier après la connexion

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
source:segmentfault.com
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!