问题描述
我正在尝试升级到通过自制软件安装的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!