升级到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 /主机
##
# 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'
答案 0 :(得分:1)
升级OS X会将Apache配置文件恢复为默认值。您需要再次编辑它们。从记忆中,这包括:
AllowOverride
至All
答案 1 :(得分:0)
我遇到了同样的问题,发现我的httpd.conf中缺少配置部分。添加以下内容并重新启动Apache后,PHP文件处理正确。
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>