PHP file won't open in browser, only download

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I can't get .php files to run on my server. For example, I created a test file entitled "test.php" with the following content (only):

 

When I try to open this or other php files through a web browser, it tries to download them rather than run them. Responses to similar questions suggest that this issue means the server isn't set up to run php. I looked up how to enable php on the server and found that I am supposed to uncomment the line

LoadModule php5_module libexec/apache2/libphp5.so

in the httpd.conf in the etc/apache2 directory. However, when I checked that file, the above line was already uncommented. Is there some other thing I need to change to make php work correctly?

profilepic.png
manpreet 2 years ago

You also need to add the handler for the PHP extension, so that the scripts are actually handled by the PHP module.

AddHandler php5-script .php

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.