问题描述
我正在尝试升级到我通过自制软件安装的 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 [email protected]
中的说明进行操作:
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/[email protected]/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
.
有关分步教程,请参阅:在 macOS Sierra 上使用 Homebrew 设置 Apache、MySQL 和 PHP.
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.
这篇关于Homebrew 安装的 PHP7 不适用于 macOS 上的 Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!