Background
A few days ago I ran workrman on mac, because workman needs to open multiple processes, multiple processes It needs the support of pcntl extension. The php71 I installed with brew before did not have this extension, so I uninstalled php71 directly. Then I wanted to download the source code, compile and install a higher version of php7, and install the extension more freely.
Source code compilation and installation (php-7.2.7)
Problem 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'
Solution: all because -with There is an extra space in front
Problem 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)
Solution
brew install httpd find / -name apxs Centos下执行 yum install -y httpd-devel
Find the apxs file path, and then modify the compilation parameters as follows
--with-apxs2=/usr/local/bin/apxs
Problem 3
checking if the location of ZLIB install directory is defined... no ; configure: error: Cannot find libz.
Solution
brew install zlib find / -name lib
Add parameters
--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
Problem 4
configure: error: Cannot locate header file libintl.h
The reason is that there is no gettext
Solution:
$PHP_GETTEXT /usr/local /usr; do
configure file is changed to
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 , add
\--with-iconv=/usr/local/Cellar/libiconv/1.15
to the compilation parameters. Question 6
checking for libiconv in -liconv... no checking for iconv in -liconv... no configure: error: Please reinstall the iconv library.
[I ended up getting stuck here and couldn’t solve it. Then the compilation and installation failed]
The compilation and installation commands when finally solving problem five are as follows:
./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 installation
1. Search php
brew search php
in brew appeared: php@5.6 php@7.1 php@7.0
2. Then installed php7.0
brew install php70
3. Set php to the system Environment variable
find / -name php # 先找到php执行文件 cp /usr/local/Cellar/php@7.0/7.0.30_1/bin/php /usr/bin # 将php执行文件放到/usr/bin/文件夹中
Finally
failed to be installed successfully through source code compilation, but brew install was installed successfully.
For more PHP7 related knowledge, please visit the PHP7 special column!
The above is the detailed content of Summary of problems that occur when installing PHP7 on mac. For more information, please follow other related articles on the PHP Chinese website!