【问题标题】:Apache2 server file getting downloaded instead of giving outputApache2服务器文件被下载而不是输出
【发布时间】:2017-05-21 07:34:27
【问题描述】:

我正在使用 Apache2 服务器,我创建了这两个文件,如下所示:

/var/www/html/Roshan/web.html

/var/www/html/Roshan/cgi/mypage.php

但不是在单击submit 按钮时获得输出,而是正在下载文件mypage.php。 我该如何解决这个问题?

对于其他人提出的相同问题,我得到了这个答案,但我没有得到这个文件/etc/apache2/httpd.conf

取消注释/etc/apache2/httpd.conf 中的以下行为我解决了问题:

LoadModule php5_module libexec/apache2/libphp5.so

【问题讨论】:

  • Uncommenting the following line in /etc/apache2/httpd.conf fixed the problem for me: 那有什么问题呢?
  • "我没有得到这个文件 /etc/apache2/httpd.conf"——那么你的配置文件在别的地方。我们不知道您的特定构建设置在哪里寻找它。

标签: php html apache


【解决方案1】:

双击运行 web.html 文件或输入以下内容时出错:

file:///var/www/html/Roshan/web.html

在我的网络浏览器中这是错误的方式,因为这样我的 html 代码没有在 Apache 2 服务器中运行。 所以正确的方法是启动浏览器并输入:

http://localhost/Roshan/web.html

这将正确启动 Apache 2 服务器并且文件将被执行而不是被下载。

【讨论】:

    【解决方案2】:

    Ubuntu 默认没有 httpd.conf,您必须更改 /etc/apache2/apache2.conf。因此,在 apache2.confrestart apache 中添加以下行:

    LoadModule php5_module libexec/apache2/libphp5.so
    

    注意:将您的 php 文件移动到 /var/www/html/Roshan/mypage.php 中。运行 cgi 脚本而不运行 php 脚本的 Cgi 文件夹。

    【讨论】:

    • 是的,我也尝试移动 php 文件,但它仍然被下载。
    • 你的操作系统是什么?
    • 我使用的是 ubuntu 16.04
    • 对于ubuntu,可以改/etc/apache2/apache2.conf
    • 是的,现在我已经在 apache2.conf 中添加了上面的行,但它仍然被下载。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    • 2021-06-22
    • 2015-02-27
    • 1970-01-01
    • 1970-01-01
    • 2022-10-15
    相关资源
    最近更新 更多