问题描述
mac 电脑,
brew install httpd24
DocumentRoot is /usr/local/var/www.
The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To have launchd start httpd now and restart at login:
brew services start httpd
Or, if you don't want/need a background service you can just run:
apachectl start
==> Summary
? /usr/local/Cellar/httpd/2.4.34: 1,633 files, 26.6MB
==> Caveats
==> httpd
DocumentRoot is /usr/local/var/www.
The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To have launchd start httpd now and restart at login:
brew services start httpd
Or, if you don't want/need a background service you can just run:
apachectl start
macdeMacBook-Pro:~ mac$ brew services start httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)
新的 /usr/local/etc/httpd/httpd.conf
原来的 /etc/apache2/httpd.conf还存在的。
问题出现的环境背景及自己尝试过哪些方法
现在的问题是,sudo apachectl restart时,
报错为:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using macdeMacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
然后我又安装了nginx.
nginx的默认目录也在 /usr/local/var/www下。与新安装的apache一样。
localhost:8080时。
能读出index.html
但,
localhost:8080/index.php
就报错了。
An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.
If you are the system administrator of this resource then you should check the error log for details.
Faithfully yours, nginx.
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
你期待的结果是什么?实际看到的错误信息又是什么?
我是想让mac升级为php7的。目录在项目中用echo phpinfo()输出的是 php.5.6 。
php7也是安装过了的。brew install php7
如果我在原来的httpd.conf中加上:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
那么项目就不能打开,好象apache没启动。
报的错就是上面一样。
看上面,目前项目用的是老的apache,加载php7就报错。
新安装apache没使用上。
localhost:8080/index.php,nginx起作用了,但php没有起作用。
请问我该如何做呢?
找到你新安装的
php
和php-config
这两个文件,有可能在/usr/local/opt/php/bin这里,把这两个文件链接到/usr/bin/目录下。执行以下命令进行链接,10.11之后的版本需要使用sudo。(假如你新安装的php和php-config在/usr/local/opt/php/bin目录下)
完成后,再运行命令
php -v
查看php版本是不是改变了。