Question

I am trying to open .php file in any browser but it is being downloaded.. What is the problem? somebody plz help me..

When i type localhost/hel.php in address bar of browser it shows me download dialog.

Thanks in advance

Was it helpful?

Solution

The webserver needs to know that the requested file is to be executed using the PHP interpreter. If the webserver is not installed, running or configured, the file will be downloaded very much the same as a .zip or .mp3 file would.

It is not clear what server you use, if any, so I will not post particular instructions unless you clarify.

[EDIT]

Alright, for Apache, it's quite simple. I assume you're using a UNIX-like OS, since most popular Windows packages, such as XAMPP or WAMP, come with PHP + Apache already configured and ready to go.

Apart from Apache and PHP, you also need to install mod_php, which is an Apache extension that allows the webserver to use the PHP interpreter to run PHP files. Use your favourite package manager and install the missing package. Its exact name varies between Linux distributions, so I cannot tell you which one to look for exactly, but it will usually be something along the lines of "libapache2-mod-php".

Once that is installed, go to your php.ini file and make sure the module is enabled. After restarting the webserver, PHP files should be working as expected.

OTHER TIPS

Maybe this is the answer? apache2 on ubuntu - php files downloading

For second question from your comment:

Do you include

Include /etc/phpmyadmin/apache.conf

in

/etc/apache2/apache2.conf

and restart apache with

sudo service apache2 restart

?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top