I have L-Ubuntu 11.04. I've installed Apache2 and I'm trying to simulate a server on my local file system by navigating to localhost in the browser.
The problem is that I can't seem to get php to execute when on localhost. The PHP code is simply printed in the browser (instead of being executed and the result being printed).
libapache2-mod-php5is installed and the latest version.- The Apache module php5 is enabled.
How can I get PHP to run on localhost?
Answer
The configuration file /etc/apache2/mods-available/php5.conf controls which files Apache recognizes as php scripts (based on their extensions).
Be default (in PHP 5.3.2), the file contains the following code:
SetHandler application/x-httpd-php
This affects files with the following extensions:
.php.php3.phtml
From our discussion in chat, I know that your files have a html extension. The server was configured to treat .html files as php files, but your home computer is not. That leaves you with two options:
Rename your
.htmlfiles that contain php code to one of the above extensions.Replace the line
in your
php5.confbyand reload apache by executing the following command:
sudo service apache2 reloadIn addition to the previously mentioned extensions, the new configuration also affects:
.htm.html
No comments:
Post a Comment