搜尋
首頁後端開發PHP7mac安裝PHP7時出現的問題總表

mac安裝PHP7時出現的問題總表

背景

前幾天在mac上執行workrman,由於workerman需要開啟多個進程,因此多進程需要pcntl擴充的支持,我之前那個brew安裝的php71沒有這個擴展,就直接卸載了php71,然後想下載源碼編譯安裝php7的更高版本,也可以更自由的安裝擴展。

原始碼編譯安裝(php-7.2.7)

#問題一

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'

解決:都是因為—with前面多了個空格

問題二

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

問題三

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

問題四##

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

問題五

configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

解決辦法,編譯參數中加上

\--with-iconv=/usr/local/Cellar/libiconv/1.15

問題六

checking for libiconv in -liconv... no
checking for iconv in -liconv... no
configure: error: Please reinstall the iconv library.

#【最終卡在了這裡,沒解決。然後編譯安裝就沒有成功】

最後解決到問題五的時候的編譯安裝命令如下:

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

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/文件夹中

最後

透過原始碼編譯安裝沒有成功,還是brew install安裝成功。

更多PHP7相關知識,請造訪

PHP7專題欄位!

以上是mac安裝PHP7時出現的問題總表的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:segmentfault。如有侵權,請聯絡admin@php.cn刪除

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境