Mobile app version of vmapp.org
Login or Join
Ann8826881

: Why isn't my PHP file running? I recently installed Apache and later installed PHP too. When I browse to http://localhost/index.html it displays the default Apache page "it works". But when i

@Ann8826881

Posted in: #Apache #Apache2 #Configuration #Localhost #Php

I recently installed Apache and later installed PHP too.

When I browse to localhost/index.html it displays the default Apache page "it works".

But when i try to run localhost/phpinfo.php it starts to get downloaded instead of running the PHP code


My Apache version 2.2
PHP Version 5.2.1

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

3 Comments

Sorted by latest first Latest Oldest Best

 

@Jennifer507

Personally I use wampserver (wampserver.com/en). Like Brad stated, go with a bundled package like this instead of independently installed components.
I had tried for a few weeks to install the "A.M.P" section of my WAMP stack independently without success. With the prepackaged WAMP bundle (or Brad's XAMPP) it should take you no time at all.

10% popularity Vote Up Vote Down


 

@Angela700

That means PHP was not configured properly. I assume you installed Apache and PHP independently.

Save yourself some trouble and just install something like XAMPP. It's easier to just stick with a prepackaged bundle, unless you have very particular needs.

10% popularity Vote Up Vote Down


 

@Bethany197

Probably the server doesn't recognize the script as executable, and that's why it offers it as a downloadable file.

These lines should be present in your Apache config. Note that the path may need to be changed for the .so modules, depending on your configuration:

*nix:

# -- if you're using PHP 5, uncomment this line to activate it
LoadModule php5_module libexec/libphp5.so

# -- if you're using PHP 4, uncomment this line to activate it #LoadModule php4_module libexec/libphp4.so

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps




Windows:

# -- assuming PHP 4
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps


Restart the Apache service and PHP should load into Apache to run just fine.

You might also want to make sure your php.ini file is located where you want it to be, which should generally be where you have PHP installed, e.g. c:php. In order to do so, you'd add the following directive in Apache's configuration file:

# configure the path to php.ini
PHPIniDir "C:php"

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme