首頁  >  文章  >  後端開發  >  mac 怎麼編譯安裝 php7

mac 怎麼編譯安裝 php7

藏色散人
藏色散人原創
2021-12-16 10:15:013345瀏覽

mac編譯安裝php7的方法:1、透過「wget -c http://mirrors.sohu.com/php/php-7.1.8.tar.gz」下載PHP;2、透過「tar -zxvf php-7.1.8.tar.gz」解壓縮編譯即可。

mac 怎麼編譯安裝 php7

本文操作環境:macOS10.15系統,PHP7.1.8版,macbook pro 2020電腦。

mac 怎麼編譯安裝php7?

Mac編譯安裝PHP7.1.8:

#1、下載穩定版的PHP

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

2、解壓縮編譯

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
遇到的問題:
  • apxs報錯的問題
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)

解決方案:查找httpd安裝目錄下的bin目錄裡的apxs ,盡量不要寫/usr/bin/apxs

  • 由於Mac自帶的openssl沒法升級(我沒找到升級的辦法),導致版本較低,報錯:
configure: error: OpenSSL version 1.0.1 or greater required.

解決方案:由於Mac自帶的openssl沒辦法升級(我沒找到升級的辦法),用

brew install openssl

安裝最新版的openssl,然後在參數中加上brew安裝的ssl的路徑

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

解決方案:

brew install gettext

開啟PHP的configure文件,修改文件的

for i in $PHP_GETTEXT /usr/local /usr/ ;do

改成

for i in $PHP_GETTEXT /usr/local /usr/ usr/local/opt/gettext;do
  • libiconv問題,報錯如下:
checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=

解決方案:
安裝libiconv (字元編碼轉換庫)
網址: http://www.gnu.org/software/libiconv/
目前版本: 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

安裝

make && sudo make install

推薦學習:《PHP7教程

以上是mac 怎麼編譯安裝 php7的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn