Home > Backend Development > PHP7 > Summary of problems that occur when installing PHP7 on mac

Summary of problems that occur when installing PHP7 on mac

藏色散人
Release: 2023-02-17 12:38:02
forward
4584 people have browsed it

Summary of problems that occur when installing PHP7 on mac

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'
Copy after login

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)
Copy after login

Solution

brew install httpd
find / -name apxs 
Centos下执行 yum install -y httpd-devel
Copy after login

Find the apxs file path, and then modify the compilation parameters as follows

--with-apxs2=/usr/local/bin/apxs
Copy after login

Problem 3

checking if the location of ZLIB install directory is defined... no ;
configure: error: Cannot find libz.
Copy after login

Solution

brew install zlib
find / -name lib
Copy after login

Add parameters

--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
Copy after login

Problem 4

configure: error: Cannot locate header file libintl.h
Copy after login

The reason is that there is no gettext

Solution:

$PHP_GETTEXT /usr/local /usr; do
Copy after login

configure file is changed to

for i in $PHP_GETTEXT /usr/local /usr /usr/local/opt/gettext; do
Copy after login

Question 5

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

Solution , add

\--with-iconv=/usr/local/Cellar/libiconv/1.15
Copy after login

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.
Copy after login

[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
Copy after login

brew installation

1. Search php

brew search php
Copy after login

in brew appeared: php@5.6 php@7.1 php@7.0

2. Then installed php7.0

brew install php70
Copy after login

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

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template