LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-29-2016, 06:25 AM   #1
anis123
Member
 
Registered: Mar 2012
Posts: 95

Rep: Reputation: Disabled
(apache server ) phtml writes all the php code as text in the browser


I have gotten this job of managing an old website, but the problem is that all files end with *.phtml and not just *.php. When I try to view a php3 file on my localhost it just writes all the php code as text in the browser. (I'm running Apache/2.4.6 with php PHP 5.4.16 and centos 7.2 core installed on server .


i do the following steps but can't succeed
DirectoryIndex index.php index.php3 index.html

AddType application/x-httpd-php .php .phtml
.
kindly help to solve this problem
 
Old 09-30-2016, 01:29 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
according to this:
https://stackoverflow.com/questions/...n-php#11859093
there's no difference between phtml and php.
so you can just rename them.
but maybe your server simply doesn't have php enabled AT ALL?
 
Old 09-30-2016, 01:37 AM   #3
anis123
Member
 
Registered: Mar 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
server running other sites whose extension is .php and these sites are successfully running on server
 
Old 09-30-2016, 01:56 AM   #4
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
Take a look at the php scripts. What is the openening tag for php code in there? Could be
<?php
or
<?
maybe
<?php3

If it is the 2nd you have to tell the server to use the short version. In php.ini set
short_open_tag=On
and restart the server

If it is the last you at best change the scripts I guess. Anyway you should consider sorting these scripts out as PHP3 is really very very old and may not run on the server with PHP5.4. Very very likely it will not work in higher versions like 5.6 or 7.

Hope this helps
j
 
Old 09-30-2016, 04:12 AM   #5
anis123
Member
 
Registered: Mar 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
tags are used <? ?> and short tags are also open in php.ini but problem is sill there any other soulution
 
Old 09-30-2016, 10:55 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
To get php to handle phpx and phmtl extensions modify the /etc/httpd/conf.d/php.conf file. Be sure to restart the httpd service.

Code:
<FilesMatch "\.ph(p[2-7]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
It is possible that some of the old code may no longer work with PHP 5x.

Last edited by michaelk; 09-30-2016 at 10:59 AM.
 
Old 10-01-2016, 08:15 PM   #7
anis123
Member
 
Registered: Mar 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
I already did these steps but its work plesk 12.5 is also installed on server
 
Old 10-01-2016, 08:16 PM   #8
anis123
Member
 
Registered: Mar 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
Sory its can't work
 
Old 10-01-2016, 11:48 PM   #9
c0wb0y
Member
 
Registered: Jan 2012
Location: Inside the oven
Distribution: Windows
Posts: 421

Rep: Reputation: 74
What if you try to run a sample script via commandline, does it gets executed?
 
Old 10-03-2016, 12:11 AM   #10
anis123
Member
 
Registered: Mar 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
yes executed
 
Old 10-03-2016, 01:09 AM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by anis123 View Post
yes executed
what kind of answer is that?
give us something to work with, actual output, other things you tried and how they succeeded/failed...
be verbose.
 
Old 10-03-2016, 01:28 AM   #12
anis123
Member
 
Registered: Mar 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
i test the site which are build in latest version of php its run ok. but when i run phtml file its just print text in browser
 
Old 10-05-2016, 12:13 AM   #13
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
which php version?
how do you know php runs ok?

are saying that "normal" php pages work? which pages? is your site a mix of .php and .phtml pages?

what happens if you rename one of these files, say from index.phtml to index.php? does it display correctly then?

please answer ALL these questions (i count 5 question marks) with as much relevant detail as possible.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PHP code diplayibg ob browser jkd Linux - Newbie 2 05-25-2012 07:11 AM
php page displaying text that is supposed to be part of php code DragonM15 Programming 9 07-31-2008 04:58 PM
apache & *.phtml pau_kacang Slackware 3 05-07-2007 03:08 PM
php code exposed on browser Swakoo Linux - General 2 02-12-2006 07:01 AM
Server load code Apache+PHP mindfrost82 Linux - Software 1 01-03-2005 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration