溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mac如何編譯安裝 php7

發(fā)布時(shí)間:2021-12-16 10:33:13 來(lái)源:億速云 閱讀:421 作者:小新 欄目:編程語(yǔ)言

這篇文章主要介紹mac如何編譯安裝 php7,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

mac編譯安裝php7的方法:1、通過(guò)“wget -c http://mirrors.sohu.com/php/php-7.1.8.tar.gz”下載PHP;2、通過(guò)“tar -zxvf php-7.1.8.tar.gz”解壓編譯即可。

本文操作環(huán)境:macOS10.15系統(tǒng),PHP7.1.8版,macbook pro 2020電腦。

Mac編譯安裝PHP7.1.8:

1、下載穩(wěn)定版本的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
遇到的問(wèn)題:
  • apxs報(bào)錯(cuò)的問(wèn)題

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 ,盡量不要寫(xiě)/usr/bin/apxs

  • 由于Mac自帶的openssl沒(méi)法升級(jí)(我沒(méi)找到升級(jí)的辦法),導(dǎo)致版本較低,報(bào)錯(cuò):

configure: error: OpenSSL version 1.0.1 or greater required.

解決方案:由于Mac自帶的openssl沒(méi)法升級(jí)(我沒(méi)找到升級(jí)的辦法),用

brew install openssl

安裝最新版的openssl,然后在參數(shù)中加上brew安裝的ssl的路徑

--with-openssl=/usr/local/Cellar/openssl@1.1/1.1.0e
  • --with-gettext報(bào)錯(cuò)

configure: error: Cannot locate header file libintl.h

解決方案:

brew install gettext

打開(kāi)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問(wèn)題,報(bào)錯(cuò)如下:

checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

解決方案:
安裝 libiconv (字符編碼轉(zhuǎn)換庫(kù))
網(wǎng)站地址: http://www.gnu.org/software/libiconv/
當(dāng)前版本: 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

以上是“mac如何編譯安裝 php7”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI