浏览器下载来自Apache Web服务器的PHP文件 [英] browser downloads php file from apache web server

查看:292
本文介绍了浏览器下载来自Apache Web服务器的PHP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Apache Web服务器。比方说,这台服务器的域名的 example.com

I have an apache web server. Let's say this server's domain is example.com.

在我访问的 example.com 的,那么的index.php 文件正确显示在浏览器。

When I access example.com, then the index.php file is correctly displayed in the browser.

然而,当我访问例如的 example.com/~user 的,然后的的index.php 文件 /home/user/public_html/index.php 文件下载,而不是显示。

However, when I access e.g. example.com/~user, then the index.php file of /home/user/public_html/index.php file is downloaded rather than displayed.

我该如何解决这个问题?我换expose_php =关的php.ini ,但一切都没有改变。

How do I fix this problem? I changed "expose_php = Off" in php.ini, but nothing has changed.

推荐答案

如果你是在Debian / Ubuntu的看看这个文件 /etc/apache2/mods-available/php5.conf

If you are on Debian/Ubuntu take a look at this file /etc/apache2/mods-available/php5.conf

矿看起来像这样,你可以看到,我不得不发表评论一些行让PHP在用户目录工作

mine looks like this and you can see I had to comment some line to get PHP working in the user dir

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<IfModule mod_userdir.c>
    #    <Directory /home/*/public_html>
    #        php_admin_value engine Off
    #    </Directory>
    #</IfModule>
</IfModule>

请注意,编辑的文件后,你将不得不重新启动Apache以使修改生效,重新启动基于Debian的系统上的Apache的命令是: /etc/init.d/apache2重启

Please note that after editing the file you would have to restart apache for the modifications to take effect, the command to restart apache on a debian based system is: /etc/init.d/apache2 restart

这篇关于浏览器下载来自Apache Web服务器的PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆