Homebrew安装的PHP7不适用于macOS上的Apache [英] PHP7 installed by Homebrew doesn't work with Apache on macOS

查看:121
本文介绍了Homebrew安装的PHP7不适用于macOS上的Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试升级到通过自制软件安装的php7.

I am trying to upgrade to php7 which I installed via homebrew.

在CLI中php -v返回

In CLI php -v returns

PHP 7.0.10 (cli) (built: Aug 21 2016 19:14:33) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

但是对于localhost,firefox弹出一个加载页面的问题,而我无法查看localhost/phpinfo.php.如果我将模块行换回php5,则可以正常工作.

But for localhost, firefox pops up a problem loading page, and I can't view a localhost/phpinfo.php; if I swap the module lines out back to php5 it works fine.

这是我的apache2/httpd.conf的pastebin http://pastebin.com/950yC7wA 不知道如何解决这个问题.

Here's a pastebin http://pastebin.com/950yC7wA of my apache2/httpd.conf, I have no idea how to go about fixing this.

  • osx版本El Capitan 10.11

推荐答案

请确保:

  • 您已按照brew info php@7.1中的说明进行操作:

==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so

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

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

  • 您通过sudo apachectl restart重新启动了Apache.

  • You restarted Apache via sudo apachectl restart.

    有关分步教程,请参见:

    For step by step tutorial, see: Setup Apache, MySQL and PHP using Homebrew on macOS Sierra.

    • 当某些操作无效时,请通过以下方式实时检查日志:

    • When something doesn't work, check the logs in real-time via:

    tail -f /usr/local/var/log/apache2/*error*
    

    然后启动/重新启动服务器.

    Then start/restart the server.

    注意:完成后,按 Control - C 退出tail.

    Note: When finished, hit Control-C to quit tail.

    这篇关于Homebrew安装的PHP7不适用于macOS上的Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆