Home >Backend Development >PHP Tutorial >Why Are My PHP Files Displaying as Plain Text in Apache?

Why Are My PHP Files Displaying as Plain Text in Apache?

DDD
DDDOriginal
2024-11-09 08:28:02494browse

Why Are My PHP Files Displaying as Plain Text in Apache?

How to Configure PHP Support in Apache HTTP Server

In this article, we'll address the issue of PHP files being rendered as plain text, despite having PHP and Apache installed on a system. To resolve this, we need to ensure that Apache is configured to recognize and execute PHP scripts.

The solution involves installing the PHP library for Apache. Here's how you can do it:

On Debian and Ubuntu Systems:

  1. Open a terminal window.
  2. Run the following command to install the PHP 5 library for Apache:
apt-get install libapache2-mod-php5
  1. Restart Apache to apply the changes:
service apache2 restart

Once the PHP library is installed and Apache is restarted, PHP files should be executed and interpreted correctly when accessed through your localhost. You should now be able to see the output of your PHP scripts in the browser instead of plain text.

The above is the detailed content of Why Are My PHP Files Displaying as Plain Text in Apache?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn