[英]Apache2 server file getting downloaded instead of giving output
I am using Apache2 server and i have created these two files as below: 我正在使用Apache2服务器,并且创建了以下两个文件:
/var/www/html/Roshan/web.html
/var/www/html/Roshan/cgi/mypage.php
But instead of getting output on clicking submit
button, file mypage.php
is getting downloaded. 但是,文件mypage.php
的下载不是单击“ submit
按钮时的输出。 How can i fix this problem? 我该如何解决这个问题?
I got this answer for same question asked by someone else but i am not getting this file /etc/apache2/httpd.conf
我得到了别人问的同样问题的答案,但我没有得到这个文件/etc/apache2/httpd.conf
Uncommenting the following line in /etc/apache2/httpd.conf
fixed the problem for me: 在/etc/apache2/httpd.conf
取消注释以下行对我来说解决了该问题:
LoadModule php5_module libexec/apache2/libphp5.so
Ubuntu don't have httpd.conf by default and you must change /etc/apache2/apache2.conf
. Ubuntu默认没有httpd.conf ,您必须更改/etc/apache2/apache2.conf
。 So add following line to apache2.conf and restart apache : 因此, 将以下行添加到apache2.conf并重新启动apache :
LoadModule php5_module libexec/apache2/libphp5.so
Note: Move your php file in /var/www/html/Roshan/mypage.php . 注意:将您的php文件移动到/var/www/html/Roshan/mypage.php中 。 Cgi folder running cgi scripts and not running php scripts. 运行cgi脚本而不运行php脚本的Cgi文件夹。
I was doing a mistake of running the web.html file by double clicking on it or by entering this: 我双击或输入以下内容来运行web.html文件时出错:
file:///var/www/html/Roshan/web.html 文件:///var/www/html/Roshan/web.html
in my web browser which is a wrong way because by this way my html code was not running in Apache 2 server. 在我的Web浏览器中,这是错误的方式,因为通过这种方式,我的html代码未在Apache 2服务器中运行。 so the correct method is start the browser and type : 因此正确的方法是启动浏览器并输入:
http://localhost/Roshan/web.html HTTP://localhost/Roshan/web.html
this will correctly start the Apache 2 server and file will be executed instead of getting downloaded. 这将正确启动Apache 2服务器,并且将执行文件而不是下载文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.