【发布时间】:2014-11-17 21:45:04
【问题描述】:
升级到 OS X Yosemite,现在我的虚拟主机正在吐出 PHP 文件内容,而不是执行文件。
这可以正常工作:
http://localhost
这会将文件内容吐出到屏幕上:
http://localhost/~MYUSERNAME
<?php phpinfo();
<?php and the contents of this file (which is WordPress)
apachectl -t
Syntax OK
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName testing.dev
ServerAlias www.testing.dev
DocumentRoot "/Users/*/Sites/testing"
ErrorLog "/private/var/log/apache2/testing.dev-error_log"
<Directory "/Users/*/Sites/testing-env/">
Options Indexes FollowSymLinks
AllowOverride AlL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 testing.dev
为什么会吐出 PHP 文件而不是执行它?
运行 php -v 给我
PHP 5.5.3 (cli) (built: Aug 28 2013 13:28:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans
错误日志显示:
[Mon Nov 17 17:30:08.338143 2014] [auth_digest:notice] [pid 3633] AH01757: generating secret for digest authentication ...
[Mon Nov 17 17:30:08.339341 2014] [mpm_prefork:notice] [pid 3633] AH00163: Apache/2.4.9 (Unix) PHP/5.5.14 configured -- resuming normal operations
[Mon Nov 17 17:30:08.339391 2014] [core:notice] [pid 3633] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
【问题讨论】:
-
根据我的升级记忆,它没有保留我的文件版本,所以我只是从备份中恢复它以检查差异。在my earlier answer to virtually the same question 中,我所要做的就是恢复 LoadModule 行,重新启动 apache,一切顺利。 (虽然要让虚拟主机正常工作,但我认为,从记忆中,您还需要取消注释包含
http-vhosts.conf... 的行) -
你的文件肯定是用 PHP 文件扩展名命名的? apache错误日志中有任何内容吗?即使语法正确,在尝试加载扩展模块时可能会抛出错误,但仍在启动。
-
@MattGibson 我发布了错误日志。它说配置了 PHP/5.4.14,但是当我执行 php -v 时,它显示 5.5.3。这可能是问题吗?
-
没有。
php -v将运行任何 CLI 版本的 PHP 恰好在您的路径中最早的版本(要找出您正在运行的版本的安装位置,请使用which php。)我猜它只是拿起 Mavericks'/ usr/bin/php,它在你的路径中可能比你安装在 /usr/local 中的自定义版本更高。我看不出这与您在 Apache 中使用的 php 模块有很大关系。 -
/usr/local/php5/bin/php
标签: php apache osx-mavericks