xampp虚拟主机下载php文件在浏览器(Mac)


xampp virtual host downloading php files in browser (Mac)

我已经在Mac上安装了xampp。我已经设置了虚拟主机,这是在httpd-vhosts.conf

    <VirtualHost *:80>
        DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
        ServerName localhost
    </VirtualHost>
    <VirtualHost *:80>
        DocumentRoot "/Users/username/Dropbox/folder/cms backup/test"
        ServerName cms.local
        ServerAlias cms.local
        <Directory "/Users/username/Dropbox/folder/cms backup/test">
           Options Indexes FollowSymLinks Includes ExecCGI
           AddType application/x-httpd-php .php3 .php 
           AddOutputFilter INCLUDES .php
           AllowOverride All
           Order allow,deny
           Allow from all
        </Directory>
     </VirtualHost>

我没有注释

    # Virtual hosts
    Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

更改用户和组

    User "my username"
    #Group nogroup
    Group admin

并添加到hosts

    127.0.0.1 cms.local

但是当我去cms.local/php_file.php时,我得到一个服务器500错误,php文件被浏览器下载而不是显示。当我尝试在localhost/php_file.php

中查看同一页面时,一切正常。

谁能告诉我为什么要下载这个文件?

日志和报头信息:

头信息:

    Request URL:http://cms.local/diary.php
    Request Method:GET
    Status Code:200 OK
    Request Headersview source
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
    Cache-Control:max-age=0
    Connection:keep-alive
    Host:cms.local
    User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
    Response Headersview source
    Accept-Ranges:bytes
    Connection:Keep-Alive
    Content-Type:application/x-httpd-php
    Date:Tue, 07 May 2013 23:01:58 GMT
    Keep-Alive:timeout=5, max=100
    Server:Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1
    Transfer-Encoding:chunked

访问日志:

    127.0.0.1 - - [08/May/2013:09:01:58 +1000] "GET /diary.php HTTP/1.1" 200 61851
错误日志:

    [Wed May 08 09:05:54 2013] [notice] caught SIGTERM, shutting down
    [Wed May 08 09:06:05 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
    [Wed May 08 09:06:06 2013] [notice] Digest: generating secret for digest authentication ...
    [Wed May 08 09:06:06 2013] [notice] Digest: done
    [Wed May 08 09:06:06 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

文件和目录的权限设置为644,然后我将它们更改为755。

终于找到了一个可行的答案:PHP文件不能在浏览器中打开-只能下载。我需要做什么改变才能使它正常工作?

添加:

    <FilesMatch '.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

到httpd.conf文件修复它

F-12工具(Firebug/Chrome Dev. tools)显示的标题是什么?

文件权限是什么?

日志显示什么?