Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 12623  / 2 Years ago, wed, august 3, 2022, 8:18:25

I installed LAMP



sudo tasksel install lamp-server


I can run my site, but the php code is just displayed as text.



I have tried this solution, but it didn't help me.



When I try to run php script with terminal:



user@pc:~/ooo$ php index.htm


I get just php code.



When



sudo /etc/init.d/apache2 status
php -v


I get



 * apache2 is running
PHP 5.5.9-1ubuntu4 (cli) (built: Apr 9 2014 17:11:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies


How to solve this?


More From » apache2

 Answers
7

It would appear that your script is not getting passed to the php interpreter, and is simply outputting the text of the file. This is a common error and is almost always due:




  1. Using a file ending other than php (e.x. htm or html)

  2. Not using php tag <?php ... ?> or as Nathan mentioned using improper tags.



You may see other servers that use file extensions other than .php or use shorthand tags.



Both of these can be configured to be permitted:



Allowing php short tags



Allowing additional file extensions



Short tags used to be allowed by default, but have fallen out of favour.
Its best to use the full tags <?php ?> if your starting something new or just learning php.


[#26027] Friday, August 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cocal

Total Points: 236
Total Questions: 111
Total Answers: 123

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;