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

时间:2016-09-21 20:46:37

标签: php homebrew macos-sierra

我试图设置Laravel的Valet作为依赖,需要PHP 7.当我尝试使用Homebrew安装PHP 7时,我收到以下错误:

<!DOCTYPE html>

<html>
<head>

  <link type="text/css" rel="stylesheet" href="stylesheet.css" />

 <title> My Portfolio </title>
</head>

<body>
	<div id="container">
		<div id="header"> 
			<h1> CIS 2336- Internet Applications </h1>
			<h2> DeVoll </h2>
		</div>
		<div id="navigation">
			<a href="http://tdevoll16f.heyuhnem.com/index1.html/CIS 2336/My Portfolio/MyPage1.html">Home</a>
			<a href="#">HTML/CSS</a>
			<a href="#">PHP</a>       
		</div>
		<div id="content"> 
		
			<div id="sidebar1">
				<h4> Instuctor: Natalia Fofanova </h4>
				<ul>
					<li> Lectures </li>
					<li> Syllabus </li>
					<li> Helpful Videos </li>
				</ul>
			</div>
			
			<div id="column1">
				<h2> HTML and CSS </h2>
				<p>HTML (Hypertext Markup Language) 
				and CSS (Cascading Style Sheets) are two
				of the core technologies 
				for bulding a website. <p>
				
 <p>HTML provides a structure for the page by using "Hypertext" which refers to the hyperlinks that an HTML page may contain. Also, "Markup language" refers to the way tags are used to define the page layout and elements within the page. </p>
<p>CSS provides the visual layout of web pages. They can be used to define text styles, table sizes, and other aspects of Web pages that previously could only be defined in a page's HTML. CSS helps Web developers create a uniform look across several pages of a Web site. Instead of defining the style of each table and each block of text within a page's HTML, commonly used styles need to be defined only once in a CSS document. </p>
 </p>
			</div>
			
			<div id="sidebar2">
			dddd
			</div>
	 
		</div> 
		
		<footer>
			<div id="footer"> 
				<div class="CR"> 
					<h4> Copyright 2016 </h4>
			</div>
				<div class="Instructor"> 
					<a href="http://heyuhnem.com/"><h4>Copyright Natalie Fofanova </h4> </a>
			</div>
				
		</footer>

</body>
</html>

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

我不知道这些错误是什么意思或如何修复它们。任何人都可以提供任何帮助吗?

感谢。

4 个答案:

答案 0 :(得分:10)

对,我已经弄清楚了。我发布了以下成功安装必需组件的步骤,万一其他人偶然发现了这个问题:

1)。确保Homebrew是最新的:

brew update

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

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)。运行以下命令(否则PHP安装将抱怨缺少libz):

xcode-select --install

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

brew install homebrew/php/php70

答案 1 :(得分:2)

对于那些使用macOS交付的Apache安装和PHP通过Homebrew安装的人来说也很重要(引自Homebrew php70安装):

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

答案 2 :(得分:1)

我使用以下命令使其正常工作。

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

答案 3 :(得分:0)

这是我在Macbook Pro(macOS Sierra)中将PHP 5.6升级到7.2的方式

a。首先更新冲泡包装。

$ brew update && brew upgrade

b。如果旧版本的PHP是与Homebrew一起安装的,则取消链接。

$ brew unlink php56

c。安装新版本的PHP。

$ brew install php72

安装后,它显示: 要在Apache中启用PHP,请将以下内容添加到httpd.conf(/ etc / apache2)并重新启动Apache:

d。使用vim编辑apache2的httpd.conf。

$ sudo vim /etc/apache2/httpd.conf

搜索“ php5_module”,然后推荐以下语句:

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

添加如下命令:

#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。最后,检查DirectoryIndex是否包含index.php

DirectoryIndex index.php index.html

可以在以下位置找到php.ini和php-fpm.ini文件:

/usr/local/etc/php/7.2/

f。重新启动Apache服务

$ sudo apachectl restart

g检查php版本:

$ 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

完成!

请访问文章“ Upgrade PHP version from 5.6 to 7.2 on macOS Sierra (10.12)”  的博客以获取更多信息!

加油!