You are not logged in.

#1 2012-03-11 17:18:04

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

PHP Hello World

Hi,

I've configured my LAMP server and tried a minimal php app from PHP and MySQL for Dummies (test.php):

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<p>
<?php
echo “This is a PHP line”;
phpinfo();
?>
</body></html>

http://localhost/bimbo/test.php

Produces HTTP Error 500 (Internal Server Error). Very enlightening. It isn't probably a case of misconfiguration, as the Joomla Web Installer which lives right alongside bimbo works just fine. What then? I tried to change test.php file ownership to 501:80, like joomla/index.php, but no cigar. I tried Google, but Error 500 is obviously too broad a question. What my next step is supposed to be?

Offline

#2 2012-03-11 17:32:45

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: PHP Hello World

Do you get a HTTP 500 response as well if you use a plain html file (without php)?

If the issue doesn't occur then; have a look at this.


Burninate!

Offline

#3 2012-03-11 17:47:42

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: PHP Hello World

Logs are everything...


ᶘ ᵒᴥᵒᶅ

Offline

#4 2012-03-11 20:12:20

kaen
Member
Registered: 2012-03-03
Posts: 3

Re: PHP Hello World

Look in /etc/httpd/logs/error_log and perhaps post anything relevant.
My prediction is permissions error, but that's just me trying to be psychic.

Offline

#5 2012-03-11 20:36:28

RichAustin
Member
From: Wakefield, Yorkshire, England
Registered: 2011-07-27
Posts: 186

Re: PHP Hello World

Did you set permissions to +x on the folders? You have to set executable rights on the folders as I recall. In my case it would be:

sudo chmod +x -R /media/htdocs/

Last edited by RichAustin (2012-03-11 20:36:58)

Offline

#6 2012-03-12 03:22:05

yaffare
Member
Registered: 2011-12-29
Posts: 71

Re: PHP Hello World

your php-code is wrong.

you used “ as quotes (ascii-code 226), instead you should use " (ascii-code 34).

heres the correct code:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<p>
<?php
echo "This is a PHP line";
phpinfo();
?>
</body></html>

systemd is like pacman. enjoys eating up stuff.

Offline

#7 2012-03-12 13:05:00

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: PHP Hello World

Right you are, yaffare. Thanks! That's a consequence of copy-pasting from a pdf file. Not for the first time, too...  A couple of questions:

(1) Is /etc/httpd/logs/error_log the only source for php syntax errors? More generally, what are preferred php debug instruments?

(2) Is 501:80 file ownersip a security requirement?

Offline

#8 2012-06-13 22:01:56

pe7er
Member
From: Nijmegen, Netherlands
Registered: 2012-03-15
Posts: 45
Website

Re: PHP Hello World

Llama wrote:

More generally, what are preferred php debug instruments?

Any text editor with code highlighting would be good.

Or an integrated development environment (IDE) like:
Eclipse (with PHP plugin, or Eclipse PDT)
or my weapon of choice: Netbeans


Peter Martin - Joomla Open Source CMS specialist www.db8.nl
OS: Arch Linux | Arch Linux ARM | Debian | Ubuntu
Toys;-) Raspberry Pi | SheevaPlug | PogoPlug

Offline

#9 2012-06-13 22:09:52

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: PHP Hello World

I have heard too many complaints about Eclipse not running so great within a linux environment recently. I haven't used it in quite a bit, so I am just spreading possible rumors. If you don't have a horse in the race, then you are better off trying netbeans or any php enabled editor. I believe Geany, Bluefish, Scite  (jEdit too) - I think have php support. These give you  syntax coloring and some with plugins will also give you code completion. These editors will be much lighter than any IDE like Eclipse or Netbeans. - with maybe a few less features. But I find syntax coloring, code completion and code traversing as the only 3 important features (in that order) while coding.

I on the other hand am trying to learn php along with vim, which also provides syntax coloring, code completion etc with plugins -- but vim is a language on its own wink


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#10 2012-06-13 22:18:20

pe7er
Member
From: Nijmegen, Netherlands
Registered: 2012-03-15
Posts: 45
Website

Re: PHP Hello World

Inxsible wrote:

I believe Geany, Bluefish, Scite  (jEdit too) - I think have php support. These give you  syntax coloring and some with plugins will also give you code completion. These editors will be much lighter than any IDE like Eclipse or Netbeans. - with maybe a few less features.

Yeah, I forgot to mention that using an IDE for such small pieces of code is a bit of overkill.
And Eclipse & Netbeans both need Java.

I would recommend using an IDE when you are working on bigger projects (use > 1 file) and especially if you are coding in PHP with OOP.
e.g. Netbeans Navigator = overview of classes / functions in the file you are working on = very handy...


Peter Martin - Joomla Open Source CMS specialist www.db8.nl
OS: Arch Linux | Arch Linux ARM | Debian | Ubuntu
Toys;-) Raspberry Pi | SheevaPlug | PogoPlug

Offline

#11 2012-06-14 22:25:56

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,094

Re: PHP Hello World

obligatory url

Last edited by Mr.Elendig (2012-06-14 22:26:13)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

Board footer

Powered by FluxBB