在Mac apache设置上,我全神贯注。我运行了一个建议Brew的教程,然后才意识到Mojave已经预装了Apache。现在没有php文件加载
我运行which httpd
时得到以下结果:
/usr/local/bin/httpd
此命令ps -aef | grep httpd
产生这个:
0 69773 1 0 12:59PM ?? 0:00.51 /usr/local/opt/httpd/bin/httpd -k start
70 75531 69773 0 5:00PM ?? 0:00.01 /usr/local/opt/httpd/bin/httpd -k start
70 75532 69773 0 5:00PM ?? 0:00.00 /usr/local/opt/httpd/bin/httpd -k start
70 75533 69773 0 5:00PM ?? 0:00.00 /usr/local/opt/httpd/bin/httpd -k start
70 75534 69773 0 5:00PM ?? 0:00.00 /usr/local/opt/httpd/bin/httpd -k start
70 75535 69773 0 5:00PM ?? 0:00.02 /usr/local/opt/httpd/bin/httpd -k start
70 75537 69773 0 5:00PM ?? 0:00.00 /usr/local/opt/httpd/bin/httpd -k start
70 75538 69773 0 5:00PM ?? 0:00.00 /usr/local/opt/httpd/bin/httpd -k start
70 75539 69773 0 5:00PM ?? 0:00.00 /usr/local/opt/httpd/bin/httpd -k start
501 75680 89456 0 5:08PM ttys002 0:00.00 grep httpd
,表明我的Apache正在运行。从关于类似问题的问题中,我已经看到它说我需要取消对PHP的LoadModule的注释,但是在我的配置中,没有针对PHP的LoadModule。 httpd.conf
中没有任何有关php的内容。我手动更改或添加了此内容:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule
#Stackoverflow answer
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
但是找不到这行:
LoadModule **php7_module** libexec/apache2/**libphp7.so**
根据php -v
PHP已加载并正在运行。
PHP 7.2.8 (cli) (built: Jul 19 2018 12:14:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.8, Copyright (c) 1999-2018, by Zend Technologies
当我转到本地主机时,它将解决。但是,显示的php页面只是代码,因此不会呈现php页面。
看来我的httpd.conf的来源是这样:
/usr/local/etc/httpd/httpd.conf
LoadModule php7_module libexec/apache2/libphp7.so
我收到错误
httpd: Syntax error on line 182 of /usr/local/etc/httpd/httpd.conf: Cannot load libexec/apache2/libphp7.so into server: dlopen(/usr/local/opt/httpd/libexec/apache2/libphp7.so, 10): image not found