kevbot
Posts: 8
Joined: Sun Mar 23, 2014 5:31 am

PHP code commented out on apache server

Sun Mar 23, 2014 5:59 am

I have followed numerous tutorials on how to setup a basic LAMP server on my Pi running Raspbian Wheezy, and have got the initial 'index.html' to run correctly, and connected from another device on my home network.
Although I have supposedly successfully installed apache2, php5, mysql-server, mysql-client, and php5-mysql, PHP still isn't functioning properly. Any HTML code in a .php file will display - but PHP code is displayed in my browser element inspector as commented out, or other weird stuff. Here is an example. I have a file in my /var/www/ directory called phptest.php, and its content is simply:

Code: Select all

<?php 
phpinfo(); 
?>
When I open the page in-browser, however, it will show as:

Code: Select all

<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"><?php
phpinfo();
?>
</pre></body></html>
or

Code: Select all

<!--?php
phpinfo();
?-->
Can anyone please help me fix this?
I hope this is the right place to ask, sorry if not.
Thank you for your time.
Attachments
PHPfail.png
What Chrome displayed
PHPfail.png (4.51 KiB) Viewed 5174 times

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: PHP code commented out on apache server

Sun Mar 23, 2014 7:16 am

What's the output of:

Code: Select all

$ sudo a2enmod php5
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: PHP code commented out on apache server

Sun Mar 23, 2014 7:31 am

As php5 pulls in libapache2-mod-php5, you shouldn't need to do the a2enmod manually, but it is worth a try, as is restarting your apache server afterwards.

Your code should work. I just tried it and it did.

kevbot
Posts: 8
Joined: Sun Mar 23, 2014 5:31 am

Re: PHP code commented out on apache server

Sun Mar 23, 2014 8:49 am

Hi there, the a2enmod command returned:

Code: Select all

ERROR: Module php5 does not exist!
Does this mean it was incorrectly installed?

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: PHP code commented out on apache server

Sun Mar 23, 2014 8:59 am

Is libapache2-mod-php5 actually installed? It should be.

You can check with

Code: Select all

dpkg -l libapache2-mod-php5
If you get something that starts with "ii", then it is installed. It should look a bit like this (except I run apache on a PC, not a Pi, so some bits will differ, like it will say 'armhf' instead of 'i386', the rest should be the same)

Code: Select all

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libapache2-mod 5.4.4-14+deb i386         server-side, HTML-embedded script

kevbot
Posts: 8
Joined: Sun Mar 23, 2014 5:31 am

Re: PHP code commented out on apache server

Sun Mar 23, 2014 10:14 am

Okay, I tried that and it returned

Code: Select all

iU  libapache2-mod 5.4.4-14+deb armhf        server-side, HTML-embedded script
I'm sorry if I don't pick up on what you're doing, I'm pretty new to the Pi.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PHP code commented out on apache server

Sun Mar 23, 2014 10:16 am

sudo apt-get install libapache2-mod-php5
should fix it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

kevbot
Posts: 8
Joined: Sun Mar 23, 2014 5:31 am

Re: PHP code commented out on apache server

Sun Mar 23, 2014 10:22 am

DougieLawson wrote:sudo apt-get install libapache2-mod-php5
should fix it.
Hi, apparently it's already installed to to the newest version...

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: PHP code commented out on apache server

Sun Mar 23, 2014 10:23 am

It looks like the install has been requested, but failed for some reason.
The first "i" means "Desired state = Installed".
The "U" means "Current state = Unpacked", which is part way through the install procedure of Download, Unpack, Setup, Install, Configure.

The question is why it failed?

Try sudo apt-get -f install and if it fails post the entire output of the command here.

kevbot
Posts: 8
Joined: Sun Mar 23, 2014 5:31 am

Re: PHP code commented out on apache server

Sun Mar 23, 2014 10:36 am

rpdom wrote:It looks like the install has been requested, but failed for some reason.
The first "i" means "Desired state = Installed".
The "U" means "Current state = Unpacked", which is part way through the install procedure of Download, Unpack, Setup, Install, Configure.

The question is why it failed?
Try sudo apt-get -f install and if it fails post the entire output of the command here.
Okay it's pretty long, but here's what happened

Code: Select all

pi@raspberrypi ~ $ sudo apt-get -f install libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-php5 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
9 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up mysql-server-5.5 (5.5.35+dfsg-0+wheezy1) ...
[ ok ] Stopping MySQL database server: mysqld.
insserv: warning: script 'mathkernel' missing LSB tags and overrides
insserv: There is a loop between service rpc_shellinaboxd and mathkernel if stopp   ed
insserv:  loop involving service mathkernel at depth 2
insserv:  loop involving service rpc_shellinaboxd at depth 1
insserv: Stopping mathkernel depends on rpc_shellinaboxd and therefore on system    facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up apache2.2-common (2.2.22-13+deb7u1) ...
insserv: warning: script 'mathkernel' missing LSB tags and overrides
insserv: There is a loop between service rpc_shellinaboxd and mathkernel if stopp   ed
insserv:  loop involving service mathkernel at depth 2
insserv:  loop involving service rpc_shellinaboxd at depth 1
insserv: Stopping mathkernel depends on rpc_shellinaboxd and therefore on system    facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
dpkg: error processing apache2.2-common (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of apache2-mpm-prefork:
 apache2-mpm-prefork depends on apache2.2-common (= 2.2.22-13+deb7u1); however:
  Package apache2.2-common is not configured yet.

dpkg: error processing apache2-mpm-prefork (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of apache2:
 apache2 depends on apache2-mpm-worker (= 2.2.22-13+deb7u1) | apache2-mpm-prefork    (= 2.2.22-13+deb7u1) | apache2-mpm-event (= 2.2.22-13+deb7u1) | apache2-mpm-itk    (= 2.2.22-13+deb7u1); however:
  Package apache2-mpm-worker is not installed.
  Package apache2-mpm-prefork is not configured yet.
  Package apache2-mpm-event is not installed.
  Package apache2-mpm-itk is not installed.
 apache2 depends on apache2.2-common (= 2.2.22-13+deb7u1); however:
  Package apache2.2-common is not configured yet.

dpkg: error processing apache2 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libapache2-mod-php5:
 libapache2-mod-php5 depends on apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk   ; however:
  Package apache2-mpm-prefork is not configured yet.
  Package apache2-mpm-itk is not installed.
 libapache2-mod-php5 depends on apache2.2-common; however:
  Package apache2.2-common is not configured yet.

dpkg: error processing libapache2-mod-php5 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php5:
 php5 depends on libapache2-mod-php5 (>= 5.4.4-14+deb7u8) | libapache2-mod-php5fi   lter (>= 5.4.4-14+deb7u8) | php5-cgi (>= 5.4.4-14+deb7u8) | php5-fpm (>= 5.4.4-14   +deb7u8); however:
  Package libapache2-mod-php5 is not configured yet.
  Package libapache2-mod-php5filter is not installed.
  Package php5-cgi is not installed.
  Package php5-fpm is not installed.

dpkg: error processing php5 (--configure):
 dependency problems - leaving unconfigured
Setting up shellinabox (2.14-1) ...
insserv: warning: script 'mathkernel' missing LSB tags and overrides
insserv: There is a loop between service rpc_shellinaboxd and mathkernel if stopp   ed
insserv:  loop involving service mathkernel at depth 2
insserv:  loop involving service rpc_shellinaboxd at depth 1
insserv: Stopping mathkernel depends on rpc_shellinaboxd and therefore on system    facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
dpkg: error processing shellinabox (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up tomcat6 (6.0.35-6+deb7u1) ...
insserv: warning: script 'mathkernel' missing LSB tags and overrides
insserv: There is a loop between service rpc_shellinaboxd and mathkernel if stopp   ed
insserv:  loop involving service mathkernel at depth 2
insserv:  loop involving service rpc_shellinaboxd at depth 1
insserv: Stopping mathkernel depends on rpc_shellinaboxd and therefore on system    facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
dpkg: error processing tomcat6 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.5
 apache2.2-common
 apache2-mpm-prefork
 apache2
 libapache2-mod-php5
 mysql-server
 php5
 shellinabox
 tomcat6
E: Sub-process /usr/bin/dpkg returned an error code (1)

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: PHP code commented out on apache server

Sun Mar 23, 2014 10:51 am

Ok, thanks for that. The detailed report is exactly what was needed to diagnose this issue.

It looks like mysql can't be configured due to a problem with "mathkernel" which I believe is part of the wolfram maths system that is installed on Raspis by default now. I don't have that package installed (it's too big, has this annoying bug and I don't need it for anything I do). I can't remember the full name of it, but if you can find it, or someone else can prompt with details) and you don't use it, then removing it would be a good idea and free up about 0.5GB of space on your card. If you do need it, I'm sure someone who knows what they are doing can tell you how to edit the start up files for that software so they work correctly.

Then, you should be able to run that apt-get -f install and complete the install of mysql, apache and php

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: PHP code commented out on apache server

Sun Mar 23, 2014 2:08 pm

sudo apt-get purge wolfram*
gets rid of that mathkernel script and frees up 500MB of space.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

kevbot
Posts: 8
Joined: Sun Mar 23, 2014 5:31 am

Re: PHP code commented out on apache server

Wed Mar 26, 2014 10:48 am

Thank you so much to everyone, the wolram thingy worked :) PHP is working!

Return to “Networking and servers”