Home > Backend Development > PHP7 > How to compile and install php7 on mac

How to compile and install php7 on mac

藏色散人
Release: 2023-02-18 09:36:01
Original
3612 people have browsed it

How to compile and install php7 on mac: 1. Download PHP through "wget ​​-c http://mirrors.sohu.com/php/php-7.1.8.tar.gz"; 2. Through "tar -zxvf php-7.1.8.tar.gz" to decompress and compile.

How to compile and install php7 on mac

The operating environment of this article: macOS10.15 system, PHP7.1.8 version, macbook pro 2020 computer.

How to compile and install php7 on mac?

Compile and install PHP7.1.8 on Mac:

1. Download the stable version of PHP

wget -c http://mirrors.sohu.com/php/php-7.1.8.tar.gz
Copy after login

2. Problems encountered when decompressing and compiling

tar -zxvf php-7.1.8.tar.gz

./configure --prefix=/usr/local/php/7.1.8 \
--with-config-file-path=/usr/local/php/7.1.8/etc \
--with-config-file-scan-dir=/usr/local/php/7.1.8/etc/conf.d \
--with-apxs2=/usr/sbin/apxs \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli \
--with-pdo-mysql \
--with-iconv-dir \
--with-freetype-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-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--disable-fileinfo \
--enable-maintainer-zts \
--enable-mysqlnd
Copy after login
:
  • apxs error reporting problem
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: Find For apxs in the bin directory under the httpd installation directory, try not to write /usr/bin/apxs

  • because the openssl that comes with Mac cannot be upgraded (I have not found a way to upgrade), resulting in a later version. Low, error:
configure: error: OpenSSL version 1.0.1 or greater required.
Copy after login

Solution: Since the openssl that comes with Mac cannot be upgraded (I did not find a way to upgrade), use

brew install openssl
Copy after login

to install the latest version of openssl, and then Add the path of ssl installed by brew in the parameters

--with-openssl=/usr/local/Cellar/openssl@1.1/1.1.0e
Copy after login
  • --with-gettext error reporting
configure: error: Cannot locate header file libintl.h
Copy after login

Solution:

brew install gettext
Copy after login

Open PHP configure file, modify the

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

of the file to

for i in $PHP_GETTEXT /usr/local /usr/ usr/local/opt/gettext;do
Copy after login
  • libiconv problem, the error is as follows:
checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>
Copy after login

Solution:
Install libiconv ( Character encoding conversion library)
Website address: http://www.gnu.org/software/libiconv/
Current version: https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15 .tar.gz

$ wget [https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
$ tar zxvf libiconv-1.15.tar.gz
$ cd libiconv-1.15
$ ./configure --prefix=/usr/local/lib/libiconv
$ make
$ sudo make install
Copy after login

Installation

make && sudo make install
Copy after login

Recommended study: "PHP7 Tutorial"

The above is the detailed content of How to compile and install php7 on mac. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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