Mac に PHP7 をインストールするときに発生する問題のまとめ

藏色散人
リリース: 2023-02-17 12:38:02
転載
4421 人が閲覧しました

Mac に PHP7 をインストールするときに発生する問題のまとめ

背景

数日前、Mac 上で workman を実行しました。workman は複数のプロセスを開く必要があるためです。プロセス pcntl 拡張機能のサポートが必要です。以前 brew でインストールした php71 にはこの拡張機能がなかったので、php71 を直接アンインストールしました。その後、ソース コードをダウンロードし、php7 の上位バージョンをコンパイルしてインストールし、拡張機能をインストールしたいと思いました。もっと自由に。

ソース コードのコンパイルとインストール (php-7.2.7)

問題 1

configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --enable-fpm
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-mysqli
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-pdo-mysql
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-iconv-dir
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-eeeetype-dir
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-zlib
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-jpeg-dir
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-png-dir
configure: error: invalid variable name: ` --with-libxml-dir'
ログイン後にコピー

解決策: すべての理由は -前に余分なスペースがあります

問題 2

Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
ログイン後にコピー

解決策

brew install httpd
find / -name apxs 
Centos下执行 yum install -y httpd-devel
ログイン後にコピー

apxs ファイル パスを見つけて、コンパイル パラメーターを次のように変更します。次は

--with-apxs2=/usr/local/bin/apxs
ログイン後にコピー

問題 3

checking if the location of ZLIB install directory is defined... no ;
configure: error: Cannot find libz.
ログイン後にコピー

解決策

brew install zlib
find / -name lib
ログイン後にコピー

パラメータの追加

--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
ログイン後にコピー

問題 4

configure: error: Cannot locate header file libintl.h
ログイン後にコピー

理由は gettext がないためです

#解決策:

$PHP_GETTEXT /usr/local /usr; do
ログイン後にコピー

configure ファイルを

for i in $PHP_GETTEXT /usr/local /usr /usr/local/opt/gettext; do
ログイン後にコピー

Question 5## に変更します#

configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>
ログイン後にコピー
Solution 、コンパイル パラメーターに

\--with-iconv=/usr/local/Cellar/libiconv/1.15
ログイン後にコピー

を追加します。質問 6

checking for libiconv in -liconv... no
checking for iconv in -liconv... no
configure: error: Please reinstall the iconv library.
ログイン後にコピー
[結局ここで行き詰まり、解決できませんでした。その後、コンパイルとインストールが失敗しました]

最終的に問題 5 を解決するときのコンパイルとインストールのコマンドは次のとおりです:

./configure --prefix=/usr/local/php/7.2.7\—with-config-file-path=/usr/local/php/7.2.7/etc \--with-config-file-scan-dir=/usr/local/php/7.2.7/etc/conf.d  \--with-apxs2=/usr/local/bin/apxs \--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 \--enable-fpm \--with-fpm-user=www \--with-fpm-group=www \--with-mysqli \--with-pdo-mysql  \--with-iconv=/usr/local/Cellar/libiconv/1.15 \--with-eeeetype-dir \--with-zlib \--with-jpeg-dir \--with-png-dir \--with-libxml-dir=/usr/bin/xml2-config \--enable-xml \--disable-rpath \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--enable-mbregex \--enable-mbstring \--with-mcrypt \--enable-ftp \--with-gd \--enable-gd-native-ttf \--with-onsnssl \--with-mhash \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--disable-fileinfo \--enable-maintnener-zts \--enable-mysqlnd
ログイン後にコピー

brew install

1。 brew で php

brew search php
ログイン後にコピー

を検索すると、php@5.6 php@7.1 php@7.0

2 が表示され、php7.0

brew install php70
ログイン後にコピー

3 をインストールし、php をシステム環境に設定します。変数

find / -name php # 先找到php执行文件
cp /usr/local/Cellar/php@7.0/7.0.30_1/bin/php /usr/bin  # 将php执行文件放到/usr/bin/文件夹中
ログイン後にコピー

Finally

はソース コードのコンパイルによって正常にインストールできませんでしたが、brew install は正常にインストールされました。

PHP7 関連の知識については、

PHP7 特別コラムをご覧ください。

以上がMac に PHP7 をインストールするときに発生する問題のまとめの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:segmentfault.com
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!