我在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
并添加到主机
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.这没有任何区别。
答案 0 :(得分:5)
终于找到了一个有效的答案: PHP Files won't open in browser - only download. What do I need to change to make it work properly?
添加:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
到httpd.conf文件修复它
答案 1 :(得分:0)
使用F-12工具(Firebug / Chrome开发工具)显示哪些标题?
有哪些文件权限?
日志显示什么?