LAMP problem

From: Garrett Gaston 
------------------------------------------------------
I'M trying to learn a little php but my learning as been halted by some str=
ange behavior when executing my html/php files. Within my html documents I =
am attaching them to php files via:=20



When the html file executes the form=2C the browser downloads the somefile.=
php file as if I were a picture or song I was downloading from a website ra=
ther than executing and displaying the php page in the browser. Executing p=
hpinfo() from the browser via 'localhost/phptest.php' is working just fine.=
 This problem is only occurring when a php script is called to be executed =
from an html file within the browser. Also note that I have tried this in t=
wo browsers with the same result.

I've removed php5 and apache2 and re-installed both of them and I'M still g=
etting the same result.

Here's the info from /var/log/apache2/error.log

[Thu Feb 28 12:45:35 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubun=
tu3.5 with Suhosin-Patch configured -- resuming normal operations

Any ideas. I've hit a brick wall here and I can't continue my php book unti=
l I get this resolved.
 		 	   		  =

=============================================================== From: Dave Brockman ------------------------------------------------------ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sounds like PHP is not being loaded by apache. If Ubuntu follows the Debian playbook, you run a2enmod and enable PHP. Beyond that, stumble around in /etc/apache2 (or your apache config directory) and subdirs and find the file that has

=============================================================== From: Mike Smith ------------------------------------------------------ What Dan said. I can't remember the package name. I always : apt-cache search apache2 | grep php to remind remember. Thanks, Mike Smith (423) 650-4417

=============================================================== From: wes ------------------------------------------------------ what's the URL to the html file? is it possible it's using a hostname other than "localhost" and that is causing different behavior between the two examples? -wes

=============================================================== From: Dave Brockman ------------------------------------------------------ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Reading over that again.... can you post the output of phpinfo()? Specifically, what is PHP's memory limit? Regards, dtb

=============================================================== From: Garrett Gaston ------------------------------------------------------ It's all being done from localhost. everything is stored on my desktop at /= var/www/=20 As to apt-cache search apache2 | grep php=2C this is what I got. garrett@mint-desktop ~ $ apt-cache search apache2 | grep php libapache2-mod-php5 - server-side=2C HTML-embedded scripting language (Apac= he 2 module) php5-cgi - server-side=2C HTML-embedded scripting language (CGI binary) libapache2-mod-php5filter - server-side=2C HTML-embedded scripting language= (apache 2 filter module) libapache2-mod-suphp - Apache2 module to run php scripts with the owner per= missions php5-fpm - server-side=2C HTML-embedded scripting language (FPM-CGI binary) From: wes@the-wes.com Date: Thu=2C 28 Feb 2013 11:50:55 -0800 To: chugalug@chugalug.org Subject: Re: [Chugalug] LAMP problem what's the URL to the html file? is it possible it's using a hostname other= than "localhost" and that is causing different behavior between the two ex= amples? -wes=0A= =0A= =0A= =0A= =0A= =0A= =0A= I'M trying to learn a little php but my learning as been halted by some str= ange behavior when executing my html/php files. Within my html documents I = am attaching them to php files via:=20 =0A= =0A= When the html file executes the form=2C the browser downloads the somefile.= php file as if I were a picture or song I was downloading from a website ra= ther than executing and displaying the php page in the browser. Executing p= hpinfo() from the browser via 'localhost/phptest.php' is working just fine.= This problem is only occurring when a php script is called to be executed = from an html file within the browser. Also note that I have tried this in t= wo browsers with the same result. =0A= =0A= I've removed php5 and apache2 and re-installed both of them and I'M still g= etting the same result. Here's the info from /var/log/apache2/error.log [Thu Feb 28 12:45:35 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubun= tu3.5 with Suhosin-Patch configured -- resuming normal operations =0A= =0A= Any ideas. I've hit a brick wall here and I can't continue my php book unti= l I get this resolved. =0A=

=============================================================== From: Mike Smith ------------------------------------------------------ libapache2-mod-php5 You'll want to install that. It should restart apache2 and you should be in business. Thanks, Mike Smith (423) 650-4417

=============================================================== From: Dave Brockman ------------------------------------------------------ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I think he has that already, he stated phpinfo() will return valid info from a php script called directly.... That was my first reaction, until I re-read his entire post again. I suspect something else is afoot Watson... Regards, dtb -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJRL8zpAAoJEMP+wtEOVbcdjXIIAJScRcSDuN4CMia2mJyCnM2j +jaKcURiURv5HuSExse/XgMqxqtq0asi1vZE+ZISXiCpaLQL3rIpdvjOWnsma3DL 6x5o0c+QGKMQYioN+rETpb+k1xnMfXvW8dCEW8Cyxl4648z2wOlItfOjaH2lXgsf dlFb0JPxZBg6gUgravrY88CdSFhs6DG4/hgHTzeFFKzBicZhlz5ctrBgsI3k5Zzf 8dFdVNC6KSpjLT4WJu5w0xUiVllvds2DtdSzYYjLZUD15JB6LtgrhCz6hMxOWo/M XNbdAn3u9az6tcchmtCudYMmMWZJ+SytPtlByJGT3opV9w/MiJaCKxeJFlzODe8= =XNID -----END PGP SIGNATURE-----

=============================================================== From: Jason Brown ------------------------------------------------------ Or it could be as simple as the file missing the

=============================================================== From: Dean Warren ------------------------------------------------------ Hey Gary I just ran across a big hole in my LAMP setup..... My modules directory is WIDE OPEN to the web.....OMFG!! Make sure your permissions are set and you run through the directories to verify they are forbidden!!! Hope you have a great day, Dean Warren

=============================================================== From: Garrett Gaston ------------------------------------------------------ libapache2-mod-php5 is already installed. My opening tag are present. This problem is occurr= ing with my html & PHP files as well as files that I'M copying from else wa= re just to make sure. So the syntax should be good. The PHP files are worki= ng just as long as I point the URL straight to the file=2C 'localhost/somef= ile.php' but their downloading instead of executing when trigged from an ht= ml form. Date: Thu=2C 28 Feb 2013 17:06:01 -0500 From: deawar@gmail.com To: chugalug@chugalug.org Subject: Re: [Chugalug] LAMP problem Hey Gary I just ran across a big hole in my LAMP setup..... My modules dire= ctory is WIDE OPEN to the web.....OMFG!! Make sure your permissions are set and you run through the directories to v= erify they are forbidden!!!=0A= Hope you have a great day=2CDean Warren=0A= On Thu=2C Feb 28=2C 2013 at 4:56 PM=2C Jason Brown = wrote: =0A= Or it could be as simple as the file missing the

=============================================================== From: Dean Warren ------------------------------------------------------ Where does apache.conf think your DocumentRoot is? DocumentRoot /var/www/html/Drupal6 the "Drupal6" is a link to my /usr/share/drupal6 directory and with the exception of my permissions snafu it seems to work now. Take a look: http://wclug.net Hope you have a great day, Dean Warren

=============================================================== From: Joshua Estes ------------------------------------------------------ Check your mime.conf file and make sure apache knows its a php file, if its not there check and see if you have php enable, check the mods-enable folder. If its not, you need to run a2enmod php or something like that. Most of the time this happens to me, this is usually what it is.

=============================================================== From: Mike Harrison ------------------------------------------------------ While not the real problem, part if it the mime types for your files are wrong. In Apache, set your default mime document type to text/html You can also do this in your PHP code.. or server mime types comfig.. or.. or..

=============================================================== From: Garrett Gaston ------------------------------------------------------ I couldn't find an entry for DocumentRoot in apache2.conf=2C only #ServerRo= ot "/etc/apache2". I found two different mime.conf files=2C one in mods-available and one is i= n mods-enabled. Which one do I need to edit and what the line I need to loo= k for? curring with my html & PHP files as well as files that ood. The PHP files are working just as long as I point loading instead of executing when trigged from an html e=20 .=20

=============================================================== From: K I Goldman ------------------------------------------------------ You can also check the mime-type by telnetting to port 80. From the command line: telnet localhost 80 GET /somefile.php HTTP/1.0 Host: localhost (Two returns there) It should show you the mime-type in the headers. Text/html is good. Application/octet-stream not so much Keith

=============================================================== From: Dave Brockman ------------------------------------------------------ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 If you examine them more closely, what you see in mods-enabled should be a symlink to what's in mods-available. Regards, dtb -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJRMAIQAAoJEMP+wtEOVbcdjGgH/1QlfyR2qMQX0je8AdsKqm6m qLPVQpICBpU7CWLz1UkM/d+rs+3ZGBxVDdewposCVHBV4UwbfOQLYN4PspaQHPM/ r3I0SKNg9458nJFQw9LxkA3nysnV/f8jx4WPO/AovGkLPKNHXnCswMlxy9LzHCER U098iJjls9FzQ4jlM7fucVk3erThZubsFPQ48f31DEHaj8kyL0TJgc1oF52loQ1c H4586/AxxR0Fr2cXw8unGU21XLzLrGP5zVHsEgVytudshK9nmocEK3mU+a2pIcHN vu5nPQoIL3Uql2kNH0T5tFzEhTlX+DkwcmM1+E3GRb4mmAlL1GkPoIzX1zag1Iw= =Nhvo -----END PGP SIGNATURE-----

=============================================================== From: Garrett Gaston ------------------------------------------------------ I ran telnet localhost 80 in one terminal and GET in another=2C here is wha= t I got. garrett@mint-desktop ~ $ GET /var/www/phptest.php HTTP/1.0 Topic Related Searching at HTTP.COM.

=============================================================== From: Mike Harrison ------------------------------------------------------ http://httpd.apache.org/docs/2.2/mod/core.html#defaulttype is ONE of many ways to do this. Per: http://php.net/manual/en/function.header.php In your PHP code you could, at the FIRST line before anything else add: header('Content-type: text/html'); Is ANOTHER way of doing the same thing.

=============================================================== From: Dave Brockman ------------------------------------------------------ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 What are the permissions of "somefile.php"? What is your memory limit in PHP? phpinfo() should tell you if you do not wish to post the entire contents. Regards, dtb -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJRMAm/AAoJEMP+wtEOVbcdiKcH/1ATsK/XvxivtAJFrPpaJGg0 56AR8FNPcuItWOy3pXR+hUT4UjnchAcmFNcppq/gmxCctbuRUHsDN8mC6uCTJlIh K2nOPajKgiTY9A2D5cD3kKZEuUYwzEt8JROzNAOvGjPEurKDzv0dyB0OmfzcIBT4 iGECqe5ZX3MR9A7QRnVE4UDOHgVpZmOhhoCdyZF0peM67wwfL9JKVba1hs7HZrxy dULVhHiPYUq+aT4NHgbMVlKanC88glMcitq/DR37WZWxUwRDaa8wrVRAiceaocKc NlUOypZdfJKf3JxVO9N6WBxhdQ+6XDGWhjSscMqXHpg9Rq4a/olgGP7AkqDTUwI= =AYw1 -----END PGP SIGNATURE-----

=============================================================== From: Mike Harrison ------------------------------------------------------ Garrett. That command would be: GET http://localhost/phptest.php You parsed files.... If you actually see the php code in my example, you are missing the PHP module in your apache configs like /etc/apache2/mods-enabled ============================================================ Mike Harrison bogon@geeklabs.com cell: 423.605.6943

=============================================================== From: K I Goldman ------------------------------------------------------ Ok. I was on my phone last go around. Here is an example for google (belo= w). The "Content-Type: text/html=3B charset=3DISO-8859-1" is what you shou= ld be looking for. On the command line I type in "telnet www.google.com 80" I then see:Trying 74.125.137.147...Connected to www.google.com.Escape chara= cter is '^]'. I then type in:GET / HTTP/1.0Host:www.google.com and after hitting return a couple of times get the HTTP/1.0 200 OKDate: Fri= =2C 01 Mar 2013 02:29:24 GMTExpires: -1.... response. So if you are checking to see what "Content-Type" is being returned by your= web-server your session should be something like$ telnet localhost 80Tryin= g 127.0.0.1...Connected to localhost.Escape character is '^]'.GET /sometext= file.php HTTP/1.0Host:localhost You should then see the headers and content your web-server returns. Hope this helps. Keith $ telnet www.google.com 80Trying 74.125.137.147...Connected to www.google.c= om.Escape character is '^]'.GET / HTTP/1.0Host:www.google.com HTTP/1.0 200 OKDate: Fri=2C 01 Mar 2013 02:29:24 GMTExpires: -1Cache-Contro= l: private=2C max-age=3D0Content-Type: text/html=3B charset=3DISO-8859-1Set= -Cookie: PREF=3DID=3D5667ae3139af25ab:FF=3D0:TM=3D1362104964:LM=3D136210496= 4:S=3DfSLjFEEB2Xafhiha=3B expires=3DSun=2C 01-Mar-2015 02:29:24 GMT=3B path= =3D/=3B domain=3D.google.comSet-Cookie: NID=3D67=3DDMc6r8ExePJws1rYt2tKsFyH= S-jwVK

=============================================================== From: Garrett Gaston ------------------------------------------------------ I ran telnet localhost 80=2C then I ran=20 GET http://localhost/phptest.php It returned a lot of html/php code. Mike I think you mentioned a module tha= t was missing=2C how can I fix this? From: kigtest@hotmail.com To: chugalug@chugalug.org Date: Thu=2C 28 Feb 2013 21:42:36 -0500 Subject: Re: [Chugalug] LAMP problem =0A= =0A= =0A= =0A= Ok. I was on my phone last go around. Here is an example for google (belo= w). The "Content-Type: text/html=3B charset=3DISO-8859-1" is what you shou= ld be looking for. On the command line I type in "telnet www.google.com 80" I then see:Trying 74.125.137.147...Connected to www.google.com.Escape chara= cter is '^]'. I then type in:GET / HTTP/1.0Host:www.google.com and after hitting return a couple of times get the HTTP/1.0 200 OKDate: Fri= =2C 01 Mar 2013 02:29:24 GMTExpires: -1.... response. So if you are checking to see what "Content-Type" is being returned by your= web-server your session should be something like$ telnet localhost 80Tryin= g 127.0.0.1...Connected to localhost.Escape character is '^]'.GET /sometext= file.php HTTP/1.0Host:localhost You should then see the headers and content your web-server returns. Hope this helps. Keith $ telnet www.google.com 80Trying 74.125.137.147...Connected to www.google.c= om.Escape character is '^]'.GET / HTTP/1.0Host:www.google.com HTTP/1.0 200 OKDate: Fri=2C 01 Mar 2013 02:29:24 GMTExpires: -1Cache-Contro= l: private=2C max-age=3D0Content-Type: text/html=3B charset=3DISO-8859-1Set= -Cookie: PREF=3DID=3D5667ae3139af25ab:FF=3D0:TM=3D1362104964:LM=3D136210496= 4:S=3DfSLjFEEB2Xafhiha=3B expires=3DSun=2C 01-Mar-2015 02:29:24 GMT=3B path= =3D/=3B domain=3D.google.comSet-Cookie: NID=3D67=3DDMc6r8ExePJws1rYt2tKsFyH= S-jwVK

=============================================================== From: Garrett Gaston ------------------------------------------------------ I just look in /etc/apache2/mods-enabled/ =2C=2C=2C and I see two files wit= h php names=2C php5.conf & php5.load. From: garrett85@hotmail.com To: chugalug@chugalug.org Subject: RE: [Chugalug] LAMP problem Date: Fri=2C 1 Mar 2013 20:11:10 -0600 =0A= =0A= =0A= I ran telnet localhost 80=2C then I ran=20 GET http://localhost/phptest.php It returned a lot of html/php code. Mike I think you mentioned a module tha= t was missing=2C how can I fix this? From: kigtest@hotmail.com To: chugalug@chugalug.org Date: Thu=2C 28 Feb 2013 21:42:36 -0500 Subject: Re: [Chugalug] LAMP problem =0A= =0A= =0A= =0A= Ok. I was on my phone last go around. Here is an example for google (belo= w). The "Content-Type: text/html=3B charset=3DISO-8859-1" is what you shou= ld be looking for. On the command line I type in "telnet www.google.com 80" I then see:Trying 74.125.137.147...Connected to www.google.com.Escape chara= cter is '^]'. I then type in:GET / HTTP/1.0Host:www.google.com and after hitting return a couple of times get the HTTP/1.0 200 OKDate: Fri= =2C 01 Mar 2013 02:29:24 GMTExpires: -1.... response. So if you are checking to see what "Content-Type" is being returned by your= web-server your session should be something like$ telnet localhost 80Tryin= g 127.0.0.1...Connected to localhost.Escape character is '^]'.GET /sometext= file.php HTTP/1.0Host:localhost You should then see the headers and content your web-server returns. Hope this helps. Keith $ telnet www.google.com 80Trying 74.125.137.147...Connected to www.google.c= om.Escape character is '^]'.GET / HTTP/1.0Host:www.google.com HTTP/1.0 200 OKDate: Fri=2C 01 Mar 2013 02:29:24 GMTExpires: -1Cache-Contro= l: private=2C max-age=3D0Content-Type: text/html=3B charset=3DISO-8859-1Set= -Cookie: PREF=3DID=3D5667ae3139af25ab:FF=3D0:TM=3D1362104964:LM=3D136210496= 4:S=3DfSLjFEEB2Xafhiha=3B expires=3DSun=2C 01-Mar-2015 02:29:24 GMT=3B path= =3D/=3B domain=3D.google.comSet-Cookie: NID=3D67=3DDMc6r8ExePJws1rYt2tKsFyH= S-jwVK

=============================================================== From: "kitepilot@kitepilot.com" ------------------------------------------------------ Do: dpkg --list|grep -i php ET Garrett Gaston writes:

=============================================================== From: Mike Harrison ------------------------------------------------------ Garrett, I don't normally do this, but: Thwack: You're missing some small step of understanding in between A and C. Praise: You are tenacious and somehow seem to have a cluefullness index of almost 1.0 Almost.. I see the strain as you are reaching for it.. My hand is stretched out below: Add me to skype as 'meuoned' over the weekend, and I'll try to give you some real time feedback and help. Because I think you are -almost- there. If you can navigate via a shell and use a shell based text editor, we can get Step B taken care of quickly. Otherwise it'll be email chains for weeks. Other options are Google Hangouts, etc.. in which case you can add me as mike.geeklabs@gm... but let me know if you use that because I rarely do. --Mike--

=============================================================== From: "kitepilot@kitepilot.com" ------------------------------------------------------ You don't even begin to imagine how hard Garrett is working for it. He *TRULY* deserves all the help he can get!!! ET Mike Harrison writes:

=============================================================== From: Lisa Ridley ------------------------------------------------------ Do you have the following in your apache config file? AddType application/x-httpd-php .php=20 Lisa Ridley lhridley@gmail.com with php names, php5.conf & php5.load. and C. index of almost 1.0 is stretched out below: you some real time feedback and help. Because I think you are -almost- = there. can get Step B taken care of quickly. Otherwise it'll be email chains = for weeks. Other options are Google Hangouts, etc.. in which case you = can I rarely do.

=============================================================== From: Garrett Gaston ------------------------------------------------------ Thanks guys but my latest Mint Linux update fixed the problem. Don't know w= hat it was but I did notice that when it was updating it was configuring so= me combination of apache=2C php=2C and or mysql. Anyway=2C now that that's = fixed I'M trying to figure out why my php code doesn't seem to be displayin= g any results from it's MySQL query. From: lhridley@gmail.com Date: Mon=2C 11 Mar 2013 19:14:18 -0400 To: chugalug@chugalug.org Subject: Re: [Chugalug] LAMP problem Do you have the following in your apache config file? AddType application/x-httpd-php .php =0A= =0A= Lisa Ridleylhridley@gmail.com =0A= =0A= =2C Garrett Gaston wrote: I just look in /etc/apache2/mods-enabled/ =2C=2C=2C and I see two files wit= h php names=2C php5.conf & php5.load. Garrett=2C I don't normally do this=2C but: Thwack: You're missing some small step of understanding in between A and C= . Praise: You are tenacious and somehow seem to have a cluefullness index of= almost 1.0 Almost.. I see the strain as you are reaching for it.. My hand is = stretched out below: Add me to skype as 'meuoned' over the weekend=2C and I'll try to give you s= ome real time feedback and help. Because I think you are -almost- there. If you can navigate via a shell and use a shell based text editor=2C we can= get Step B taken care of quickly. Otherwise it'll be email chains for week= s. Other options are Google Hangouts=2C etc.. in which case you can add me as mike.geeklabs@gm... but let me know if you use that because I rar= ely do. --Mike--

=============================================================== From: Mike Robinson ------------------------------------------------------ When trying to diagnose a problem like this one, look at two places: = server logs (or wherever debugging-messages are put out to), and a = browser's HTML debugger .. such as the Firebug plugin for Firefox, the = Developer screens in Safari (you have to flip an option in preferences = to turn that on), and so on. Firebug will =3Dshow=3D you what HTTP packet is being sent to the host, = and what HTTP packet is returned. No more guessing about what was = actually sent or received. When debugging, make the code initially "chatty." Echo stuff out as you = go along the success-route, not just in case of failure. Comment those = out later. --------- Mike Robinson Technical Director Sundial Services International, LLC http://www.sundialservices.com miker@sundialservices.com (615) 268-3829 http://www.linkedin.com/pub/mike-robinson/51/532/5a

=============================================================== From: Ed King ------------------------------------------------------ hehe, I sent piratically identical advice to Garrett off-list.=A0=A0=A0 I g= uess I should have sent on-list, but I'm always afraid my suggestions are b= ourgeois and I will be laughed at for my simplicity ;) --- On Thu, 3/14/13, Mike Robinson wrote: From: Mike Robinson Subject: Re: [Chugalug] LAMP problem To: chugalug@chugalug.org Date: Thursday, March 14, 2013, 4:20 PM When trying to diagnose a problem like this one, look at two places: =A0ser= ver logs (or wherever debugging-messages are put out to), and a browser's H= TML debugger .. such as the Firebug plugin for Firefox, the Developer scree= ns in Safari (you have to flip an option in preferences to turn that on), a= nd so on. Firebug will =3Dshow=3D you what HTTP packet is being sent to the host, and= what HTTP packet is returned. =A0No more guessing about what was actually = sent or received. When debugging, make the code initially "chatty." =A0Echo stuff out as you = go along the success-route, not just in case of failure. =A0Comment those o= ut later. =0A---------Mike RobinsonTechnical DirectorSundial Services International, = LLChttp://www.sundialservices.commiker@sundialservices.com(615) 268-3829htt= p://www.linkedin.com/pub/mike-robinson/51/532/5a =0A=0A -----Inline Attachment Follows-----

=============================================================== From: Stephen Haywood ------------------------------------------------------ We need more bourgeois and simple troubleshooting advice. Sometimes the computer is actually unplugged and the guy/gal on the other end needs to be told to plug it up. Not aimed at you Garret. Just don't want Ed to think simple advice is not needed.