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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-05-2012, 11:42 PM
|
#1
|
LQ Newbie
Registered: Jan 2012
Posts: 13
Rep: 
|
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.
|
|
|
02-06-2012, 01:14 AM
|
#2
|
Member
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572
Rep:
|
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'
|
|
|
|
02-06-2012, 05:28 AM
|
#3
|
LQ Newbie
Registered: Jan 2012
Posts: 13
Original Poster
Rep: 
|
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
|
|
|
02-06-2012, 05:38 AM
|
#4
|
Member
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572
Rep:
|
"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.
|
|
|
02-06-2012, 05:42 AM
|
#5
|
LQ Newbie
Registered: Jan 2012
Posts: 13
Original Poster
Rep: 
|
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???
|
|
|
02-06-2012, 06:29 AM
|
#6
|
Member
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572
Rep:
|
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?
|
|
|
02-06-2012, 07:04 AM
|
#7
|
LQ Newbie
Registered: Jan 2012
Posts: 13
Original Poster
Rep: 
|
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
|
|
|
02-06-2012, 07:42 AM
|
#8
|
Member
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572
Rep:
|
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.
|
|
|
02-07-2012, 03:47 PM
|
#9
|
LQ Newbie
Registered: Jan 2012
Posts: 13
Original Poster
Rep: 
|
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
|
|
|
03-04-2012, 03:39 PM
|
#10
|
LQ Newbie
Registered: Mar 2009
Posts: 4
Rep:
|
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?
|
|
|
05-26-2012, 09:10 AM
|
#11
|
LQ Newbie
Registered: Sep 2006
Posts: 4
Rep:
|
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
|
|
|
05-27-2012, 08:08 AM
|
#12
|
LQ Newbie
Registered: Mar 2009
Posts: 4
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 02:48 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|