无法在macOS Sierra上安装带有Homebrew的PHP 7

我正在尝试设置Laravel的Valet,作为依赖项,需要PHP 7.当我尝试安装PHP时 7与Homebrew我收到以下错误:</ p>

 通过DSX通过APXS配置SAPI模块
检查Apache 2.0处理程序模块支持...

对不起,我无法运行 APXS。 可能的原因如下:

1。 没有安装Perl
2。 找不到apxs。 尝试使用--with-apxs2 = / path / to / apxs
3传递路径。 Apache不是使用--enable-so构建的(显示apxs用法页面)

/ usr / sbin / apxs的输出如下:
apxs:错误:/Applications/Xcode.app/Contents/Developer/Toolchains/ OSX10.12.xctoolchain / usr / local / bin / apr-1-config not found!。

configure:error:Aborting

READ THIS:https://git.io/brew-troubleshooting
如果报告此情况 问题请在(不是Homebrew / brew)这样做:
https://github.com/Homebrew/homebrew-php/issues

这些公开问题也可能有所帮助:
php70-dbase https://github.com / Homebrew / homebrew-php / issues / 3508
php70-intl not found https://github.com/Homebrew/homebrew-php/issues/3591
php70-opcache install issue https://github.com/Homebrew/homebrew -php / issues / 3586
Problem在El Capitan上安装php70-mcrypt,php70-opcache,php70-xdebug https://github.com/Homebrew/homebrew-php/issues/3587
Add php70-zmq公式https:// github.com/Homebrew/homebrew-php/pull/3474
Problem安装homebrew / php / php70-imagick https://github.com/Homebrew/homebrew-php/issues/3571
I 安装PHP70:不兼容的库版本https://github.com/Homebrew/homebrew-php/issues/3444
brew安装php70-redis https://github.com/Homebrew/homebrew-php/issues/2762
Allow- enable-redis-igbinary for php70-redis https://github.com/Homebrew/homebrew-php/pull/3473
添加头部公式为php70-uploadprogress https://github.com/Homebrew/homebrew-php/pull/ 3178
</ code> </ pre>

这是全新安装的macos Sierra(实际版本,不</ strong>测试版),全新安装Homebrew(已更新) )。 我已安装,运行并同意Xcode许可协议。</ p>

我不知道这些错误是什么意思或如何解决它们。 任何人都可以提供任何帮助吗?</ p>

谢谢。</ p>
</ div>

展开原文

原文

I'm trying to setup Laravel's Valet which, as a dependency, requires PHP 7. When I try to install PHP 7 with Homebrew I get the following error:

Configuring SAPI modules
checking for Apache 2.0 handler-module support via DSO through 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)

The output of /usr/sbin/apxs follows:
apxs:Error: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/apr-1-config not found!.

configure: error: Aborting

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
  https://github.com/Homebrew/homebrew-php/issues

These open issues may also help:
php70-dbase  https://github.com/Homebrew/homebrew-php/issues/3508
php70-intl not found https://github.com/Homebrew/homebrew-php/issues/3591
php70-opcache install issue https://github.com/Homebrew/homebrew-php/issues/3586
Problem installing php70-mcrypt, php70-opcache, php70-xdebug on El Capitan https://github.com/Homebrew/homebrew-php/issues/3587
Add php70-zmq formula https://github.com/Homebrew/homebrew-php/pull/3474
Problem installing homebrew/php/php70-imagick https://github.com/Homebrew/homebrew-php/issues/3571
Install PHP70: Incompatible library version https://github.com/Homebrew/homebrew-php/issues/3444
brew install php70-redis https://github.com/Homebrew/homebrew-php/issues/2762
Allow --enable-redis-igbinary for php70-redis https://github.com/Homebrew/homebrew-php/pull/3473
Add head formula for php70-uploadprogress https://github.com/Homebrew/homebrew-php/pull/3178

This is on a fresh install of macOS Sierra (actual release, not a beta) with a fresh install of Homebrew (updated). I have installed, ran and agreed to the Xcode licensing agreement.

I have no idea what these errors mean or how to fix them. Can anyone offer any help?

Thanks.

4个回答



对,我已经弄明白了。 我正在发布成功安装下面的需求组件的步骤,以防其他人偶然发现此问题:</ p>

1)。 确保Homebrew是最新的:</ p>

  brew update 
</ code> </ pre>

2)。 通过确保安装Xcode然后在终端中键入以下内容来修复PHP 7错误:</ p>

  brew install apr apr-util 
sudo mkdir -p / Applications / Xcode。 app / Contents / Developer / Toolchains / OSX10.12.xctoolchain / usr / local / bin /
sudo ln -s / usr / local / opt / apr / bin / apr-1-config /Applications/Xcode.app/Contents/ 开发人员/工具链/ OSX10.12.xctoolchain / usr / local / bin /
sudo ln -s / usr / local / opt / apr-util / bin / apu-1-config /Applications/Xcode.app/Contents/Developer/ 工具链/ OSX10.12.xctoolchain的/ usr / local / bin中/
</代码> </ PRE>

3)。 运行以下命令(否则PHP安装将抱怨缺少libz):</ p>

  xcode-select --install 
</ code> </ pre>

4)。 您现在可以使用Homebrew安装PHP 7:</ p>

  brew install homebrew / php / php70 
</ code> </ pre>
</ div>

展开原文

原文

Right I've figured it out. I'm posting the steps to successfully install the require components below in case anybody else stumbles upon this issue:

1). make sure Homebrew is up to date:

brew update

2). Fix the PHP 7 error by making sure Xcode is installed and then typing the following into the Terminal:

brew install apr apr-util
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/opt/apr/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/opt/apr-util/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/

3). Run the following command (otherwise the PHP installation will complain about missing libz):

xcode-select --install

4). You can now install PHP 7 with Homebrew:

brew install homebrew/php/php70

doulan8054
doulan8054 给出错误:homebrew / php已被弃用。 此抽头现在为空,因为它的所有公式都已迁移。 看起来他们已经移动了homebrew / php / php70。
大约 2 年之前 回复



对于那些使用macOS交付安装的Apache和PHP通过Homebrew的人来说也许是重要的(引用自制的php70安装): </ p>

随着macOS Sierra的发布,Apache模块现在默认不构建。 如果你想在你的系统上构建它,你必须使用--with-apache选项安装php。 有关详细信息,请参阅brew选项php70。</ p>
</ div>

展开原文

原文

It may also be important for those using the macOS-delivered installation of Apache with PHP via Homebrew that (quote from Homebrew php70 install):

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-apache option. See brew options php70 for more details.

duanbishai5271
duanbishai5271 现在不推荐使用--with-apache选项,而是使用--with-httpd24
3 年多之前 回复

I used the following commands to make it work.

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew update && brew install apr apr-util
brew link apr-util --force
brew link apr --force
which apu-1-config
which apr-1-config
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
brew install php70

Here is how I upgrade PHP 5.6 to 7.2 in my Macbook Pro (macOS Sierra)

a. Update the brew package first.

$ brew update && brew upgrade

b. Unlink the old version of PHP if it was installed with Homebrew.

$ brew unlink php56

c. Install the new version of PHP.

$ brew install php72

After installation, it shows: To enable PHP in Apache add the following to httpd.conf (/etc/apache2) and restart Apache:

d. Using vim edit httpd.conf of apache2.

$ sudo vim /etc/apache2/httpd.conf

Search “php5_module” then commend out the statements as follows:

#Comment out the PHP5 module
#LoadModule php5_module libexec/apache2/libphp5.so

Add the commands as follows:

#Enable PHP 7 module
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

e. Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:

/usr/local/etc/php/7.2/

f. Restart Apache service

$ sudo apachectl restart

g. check the php version:

$ php -v
PHP 7.2.7 (cli) (built: Jun 22 2018 06:29:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Done!

Please visit the article "Upgrade PHP version from 5.6 to 7.2 on macOS Sierra (10.12)" of my blog for more information!

Cheer!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问