0

I am using Apache2 server and i have created these two files as below:

/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. 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

Uncommenting the following line in /etc/apache2/httpd.conf fixed the problem for me:

LoadModule php5_module libexec/apache2/libphp5.so
timiTao
  • 1,417
  • 3
  • 20
  • 34
Roshan Nalawade
  • 172
  • 1
  • 16
  • 1
    `Uncommenting the following line in /etc/apache2/httpd.conf fixed the problem for me:` What is the problem then? – Yash Karanke May 21 '17 at 07:36
  • 2
    Possible duplicate of [Apache is downloading php files instead of displaying them](http://stackoverflow.com/questions/18422140/apache-is-downloading-php-files-instead-of-displaying-them) – hassan May 21 '17 at 07:36
  • " i am not getting this file /etc/apache2/httpd.conf" — Then you config file is somewhere else. We don't know where your particular build is set to look for it. – Quentin May 21 '17 at 07:52

2 Answers2

0

Ubuntu don't have httpd.conf by default and you must change /etc/apache2/apache2.conf. So add following line to apache2.conf and restart apache:

LoadModule php5_module libexec/apache2/libphp5.so

Note: Move your php file in /var/www/html/Roshan/mypage.php. Cgi folder running cgi scripts and not running php scripts.

Mohammad Hamedani
  • 3,304
  • 3
  • 10
  • 22
0

I was doing a mistake of running the web.html file by double clicking on it or by entering this:

file:///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. so the correct method is start the browser and type :

http://localhost/Roshan/web.html

this will correctly start the Apache 2 server and file will be executed instead of getting downloaded.

Roshan Nalawade
  • 172
  • 1
  • 16