How to Resolve Raw PHP Text Display on Localhost
When developing PHP applications locally, you may encounter an issue where your PHP files are displayed as plain text in the browser. This can be frustrating, as it prevents you from viewing the actual output of your PHP code.
Problem Description:
Solution:
The root cause of this issue is the absence of the PHP 5 library for Apache. To resolve it, you need to install this library.
Library Installation Steps:
For Debian and Ubuntu:
apt-get install libapache2-mod-php5
service apache2 restart
Confirmation:
Once you have installed the PHP 5 library for Apache and restarted the server, your PHP files should now be parsed and executed properly. Navigate to your test.php file in the browser and verify that the PHPinfo() output is displayed as expected.
The above is the detailed content of Why is my PHP file displaying as plain text on localhost?. For more information, please follow other related articles on the PHP Chinese website!