Mac homebrew install php7自定义参数生成libphp7.so

Mac中如何安装PHP7,为什么brew 安装php7为什么找不到.so文件呢,安装php7后丢失libphp7.so了吗 。那安装brew install php72时怎么配置参数呢

常见问题 找不到libphp7.so

首先系统中brew 1.4.0版本

➜  apache2 git:(stable) ✗brew -v

Homebrew 1.4.0

Homebrew/homebrew-core (git revision 7990; last commit 2017-12-14)

➜  apache2 git:(stable) ✗

查看php72有哪些options选项可以安装,那其中--with-httpd看到没,这个就是libphp7.so文件的关键参数,其他参数根据需要自行选择。

➜  apache2 git:(stable) ✗brew options php72

--with-cgi

Enable building of the CGI executable (implies --without-fpm)

--with-debug

Compile with debugging symbols

--with-enchant

Build with enchant support

--with-gmp

Build with gmp support

--with-homebrew-curl

Include Curl support via Homebrew

--with-homebrew-libressl

Include LibreSSL instead of OpenSSL via Homebrew

--with-homebrew-libxml2

Include Libxml2 support via Homebrew

--with-homebrew-libxslt

Include LibXSLT support via Homebrew

--with-httpd

Enable building of shared Apache Handler module

--with-imap

Include IMAP extension

--with-libmysql

Include (old-style) libmysql support instead of mysqlnd

--with-mssql

Include MSSQL-DB support

--with-pdo-oci

Include Oracle databases (requries ORACLE_HOME be set)

--with-pear

Build with PEAR

--with-phpdbg

Enable building of the phpdbg SAPI executable

--with-postgresql

Build with postgresql support

--with-thread-safety

Build with thread safety

--with-webp

Build with webp support

--without-bz2

Build without bz2 support

--without-fpm

Disable building of the fpm SAPI executable

--without-ldap

Build without LDAP support

--without-legacy-mysql

Do not include the deprecated mysql_ functions

--without-mysql

Remove MySQL/MariaDB support

--without-pcntl

Build without Process Control support

--without-unixodbc

Build without unixODBC support

--HEAD

Install HEAD version

那这里根据开发需要我选择了自己需要的参数,命令如下,要先解绑之前的PHP版本,如下执行过程:

➜  apache2 git:(stable) ✗ brew install php72  --with-httpd --with-debug  --with-imap --with-mssql --with-pear --with-postgresql  --with-webp

==> Installing php72 from homebrew/php

Error: Cannot install homebrew/php/php72 because conflicting formulae are installed.

php71: because different php versions install the same binaries.

Please `brew unlink php71` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can

link the formula again after the install finishes. You can --force this

install, but the build may fail or cause obscure side-effects in the

resulting software.

➜  apache2 git:(stable) ✗ brew unlink php71

Unlinking /usr/local/Cellar/php71/7.1.12_23... 39 symlinks removed

➜  apache2 git:(stable) ✗ brew install php72  --with-httpd --with-debug  --with-imap --with-mssql --with-pear --with-postgresql  --with-webp

Updating Homebrew...

==> Installing php72 from homebrew/php

==> Installing dependencies for homebrew/php/php72: libsodium

==> Installing homebrew/php/php72 dependency: libsodium

==> Downloading https://homebrew.bintray.com/bottles/libsodium-1.0.16.sierra.bottle.tar.gz

############################################################ 100.0%

==> Pouring libsodium-1.0.16.sierra.bottle.tar.gz

🍺  /usr/local/Cellar/libsodium/1.0.16: 71 files, 945.3KB

==> Installing homebrew/php/php72 --with-webp --with-postgresql --with-httpd --with-debug --with-imap --with-mssql --with-pear

==> Downloading https://php.net/get/php-7.2.0.tar.bz2/from/this/mirror

==> Downloading from https://secure.php.net/get/php-7.2.0.tar.bz2/from/this/mirror

########################################################### 100.0%

==> ./configure --prefix=/usr/local/Cellar/php72/7.2.0_11 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.2 --with-config-file-path=

==> make

==> make install

==> /usr/local/Cellar/php72/7.2.0_11/bin/pear config-set php_ini /usr/local/etc/php/7.2/php.ini system

==> Caveats

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php7_module /usr/local/opt/php72/libexec/apache2/libphp7.so

SetHandler application/x-httpd-php

Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini file can be found in:

/usr/local/etc/php/7.2/php.ini

✩✩✩✩ PEAR ✩✩✩✩

If PEAR complains about permissions, 'fix' the default PEAR permissions and config:

chmod -R ug+w /usr/local/opt/php72/lib/php

pear config-set php_ini /usr/local/etc/php/7.2/php.ini system

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

PATH="/usr/local/bin:$PATH"

PHP72 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩ PHP CLI ✩✩✩✩

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:

export PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:

mkdir -p ~/Library/LaunchAgents

cp /usr/local/opt/php72/homebrew.mxcl.php72.plist ~/Library/LaunchAgents/

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php72.plist

The control script is located at /usr/local/opt/php72/sbin/php72-fpm

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

PATH="/usr/local/sbin:$PATH"

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'homebrew-php.josegonzalez.php72.plist' in old versions of this formula.

With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd option. See  brew options php72 for more details.

To have launchd start homebrew/php/php72 now and restart at login:

brew services start homebrew/php/php72

==> Summary

🍺  /usr/local/Cellar/php72/7.2.0_11: 508 files, 69.4MB, built in 10 minutes 20 seconds

到此安装步骤完成,libphp7.so在目录/usr/local/Cellar/php72/7.2.0_11/libexec/apache2/libphp7.so下,具体使用请在apache配置文件httpd.conf中引入切换。

另外之前有版本的参数是--with--apache,旧版本在这里不予赘述。 希望本文可以帮助到你,欢迎指正和提问。

作者博客:开发者说PHPersay

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 161,513评论 4 369
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,312评论 1 305
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 111,124评论 0 254
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,529评论 0 217
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,937评论 3 295
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,913评论 1 224
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,084评论 2 317
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,816评论 0 205
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,593评论 1 249
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,788评论 2 253
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,267评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,601评论 3 261
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,265评论 3 241
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,158评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,953评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,066评论 2 285
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,852评论 2 277