LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-05-2012, 11:42 PM   #1
dvah
LQ Newbie
 
Registered: Jan 2012
Posts: 13

Rep: Reputation: Disabled
UBUNTU 11.10 apache do not process PHP code inside HTML page


I installed LAMP on ubuntu 11.10 the test for running PHP file works but I can't get the apache to process PHP code embedded inside the HTML page.
I noticed some comments about adding "addhandler" & "addtype" but the httpd.conf file on ubuntu apache installation is empty and the apache2.conf does not have any such directives.
 
Old 02-06-2012, 01:14 AM   #2
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
The problem is most likely basic. So let's start from the beginning. Could you post the results of this first:

Quote:
dpkg -l | egrep 'php|apache'
 
Old 02-06-2012, 05:28 AM   #3
dvah
LQ Newbie
 
Registered: Jan 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Klearview
Thanks for your feedback, I managed to resolved the problem I found on another thread that relates to running apache on Windows that I need to add to httpd.conf:

LoadModule php5_module "c:/php/php5apache2_2.dll"
PHPIniDir "C:/Windows"
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .html .htm

1. My problem was that under ubuntu the httpd.conf is an empty file
2. The first 2 lines seems to be Windows specific

I end up placing the last 2 line in the httpd.conf-
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .html .htm

This solved the problem and my apache does process the php code inside html pages

I wonder why this setting is not produced automatically during the package installation, I assume that I am not the first one placing PHP inside HTML ......
Do I miss something or this is not the complete fix for the problem?
Thanks

Dvah
 
Old 02-06-2012, 05:38 AM   #4
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
"why this setting is not produced automatically during the package installation" - it is, I can't tell what was different in your case but it is.

On Debian and Debian-derived distros like Ubuntu one enables/disables Apache modules and virtual hosts using a2enmod/a2dismod and a2ensite/a2dissite utitlities, in your case:

sudo a2enmod php5.

One should NOT use httpd.conf on Debian/Ubuntu.
 
Old 02-06-2012, 05:42 AM   #5
dvah
LQ Newbie
 
Registered: Jan 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
the results for: dpkg -l | grep 'php | apache'

ii apache2 2.2.20-1ubuntu1.1
Apache HTTP Server metapackage
ii apache2-mpm-prefork 2.2.20-1ubuntu1.1
Apache HTTP Server - traditional non-threaded model
ii apache2-urils 2.2.20-1ubuntu1.1
utility programs for webservers
ii apache2.2-bin 2.2.20-1ubuntu1.1
Apache HTTP Server common binary files
ii apache2.2-common 2.2.20-1ubuntu1.1
Apache HTTP Server common files

I don't see here the PHP or MySQL BUT THEY ARE ENABLED AND WORKING???
 
Old 02-06-2012, 06:29 AM   #6
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
See the command - egrep, not grep!

But I already see that there is no libapache2-mod-php5 - are you running with CGI or PHP-FPM?
 
Old 02-06-2012, 07:04 AM   #7
dvah
LQ Newbie
 
Registered: Jan 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
I am new to linux and to ubuntu, first time installing so I am not sure how to check:
1. I didn't enable PHP-FPM intentionally so I assume I am running with CGI
2. I checked /etc/apache2/mods-enabled folder and can see there
cgi.load
php5.conf & php5.load
additional modules files, nothing with FPM
3. I checked /etc/apache2/mods-available and se there also
cgid.conf & cgid.load so I assume it is not installed
additional modules files but nothing with FPM
4. I ran dpkg -l | egrep 'php | apache'
and got the same results as grep

I understand that I have some mess here, is the best solution to remove apache/PHP/MySQL and reinstall them properly?

What is the best way to have a clean removal of all LAMP packages?

Thanks

dvah
 
Old 02-06-2012, 07:42 AM   #8
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Quote:
4. I ran dpkg -l | egrep 'php | apache'
Once again, see the command above! There are no spaces, it's 'php|apache', NOT 'php | apache'. Why not just copy/paste the command if you are going to run it anyway? (and a word of caution - do not copy/paste stuff off the Net without understanding what it does)

Quote:
I didn't enable PHP-FPM intentionally so I assume I am running with CGI
- actually either is unlikely because you would have known about it and especially seeing that you have php5 in mods-enabled.

So again - let's establish what you've installed already first.
 
Old 02-07-2012, 03:47 PM   #9
dvah
LQ Newbie
 
Registered: Jan 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
I decided to reinstall, after installation it did work fine and at a certain point I got again the same problem.
I will try to find out when/what cause it and post a new thread when I know more about the problem
Thanks again for your time and your help
dvah
 
Old 03-04-2012, 03:39 PM   #10
BBoppie
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
If have installed LAMP via the tasksel command and PHP doesn't doesn't display try using the instructions included in the php.conf file located in the apache2/mods-enabled directory. You will see the following:
<IfModule mod_php5.c>
AddHandler application/x-httpd-php .php .html .htm .file
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
# <IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
# </IfModule>
</IfModule>

Do what I did by following the instructions given by the comments...
This for apache server 2.2.1.7 version. Under version 2.2.1.4, I did not have to do this but we talking about software right?
 
Old 05-26-2012, 09:10 AM   #11
lenberman
LQ Newbie
 
Registered: Sep 2006
Posts: 3

Rep: Reputation: 0
I believe the reason that php inside html files doesn't work is that the pattern included in the FilesMatch stanza in php5.conf file doesn't match html! It matches phtml. changing the pattern to: <FilesMatch "\.p?h(p3?|tml)$"> (i.e. adding a '?' after the first p) fixes it.

What I'm not sure is whether the patter is a policy choice or a bug.
--Len
 
Old 05-27-2012, 08:08 AM   #12
BBoppie
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
This is what my php5.conf file looks like for 2.2.1.7:
<IfModule mod_php5.c>
AddHandler application/x-httpd-php .php .html .htm .file
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
# <IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
# </IfModule>
</IfModule>

In my experience with Apache, it tends to change I think because of software improvements and depending on which distro configured it.

Last edited by BBoppie; 05-27-2012 at 08:12 AM.
 
  


Reply

Tags
apache, html, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Two elements inside a form in HTML - how? (interfacing with PHP) resetreset Programming 3 09-18-2010 10:24 AM
using PHP inside of HTML on a Slackware server, Bobcat3Romeo1 Linux - Software 15 06-18-2010 05:53 AM
How do I output information from a PHP page to an HTML page? SentralOrigin Programming 3 01-10-2009 01:54 AM
simple q: can you use php inside an html document? BrianK Programming 2 12-10-2004 09:31 PM
Set up Apache to read php IN html code? WorldBuilder Linux - Networking 10 01-27-2004 12:16 PM


All times are GMT -5. The time now is 02:21 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration