検索
ホームページバックエンド開発PHP8php8 環境をセットアップする方法を段階的に説明します (一般的な問題の解決策も含めて)。

この記事は、php8 チュートリアル コラムとして、php8 環境の構築方法をステップバイステップで詳しく紹介するもので、皆様のお役に立てれば幸いです。

1. ダウンロード

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

2.解凍、コンパイル、インストール

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

問題 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: error: Package requirements (oniguruma) were not met:

問題 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

問題 6:

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

問題 6 の解決策:

> yum install libzip libzip-devel

コンパイル パラメーターを正常に構成しました

+--------------------------------------------------------------------+
| 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. コンパイル ソースcode

> make -j2 # このコンパイルはシステム CPU コアの数に依存しており、これによりパフォーマンスがある程度向上します。通常、コアの数は半分を超えてはなりません。

4. インストール

make install

インストール成功

[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. 環境変数の追加

> 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. デフォルト設定の取得

// 复制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. 起動後に自動的に開始

設定コマンドが実行可能

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

自動起動スクリプトを確認##

> 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. 追加説明

##設定ファイルに関する説明

##php-fpm.conf は PHP-FPM 構成ファイルに固有です

php.ini はすべての php モードで必要な構成ファイルです

2 つの違いは、php-fpm であることです。 .conf は PHP-FPM プロセス マネージャーの構成ファイル、php.ini は PHP パーサーの構成ファイルです

一部の PHP バージョンでは、構成内に /fpm.d/www.conf 構成ファイルもありますファイルパス

これはphp-fpm.confファイル拡張子ファイルによって構成されます。php-fpm.confファイルを開いて表示できます

; include=fpm.d/*.conf

php-fpm.confを使用して構成できますスローログ

スローログ機能を有効にすることができます。

rree

以上がphp8 環境をセットアップする方法を段階的に説明します (一般的な問題の解決策も含めて)。の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事はsegmentfaultで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター