Page 1 of 1

Webpage with PHP not working

Posted: Saturday 23 January 2016 14:31
by Marq
'
Hi there,

I am trying to setup PHP on a Raspberry Pi.

What does work: PHP is installed (' sudo apt-get install php5 '). This code is entered in ' ~/domoticz/scripts/firstexample.php '

Code: Select all

#!/usr/bin/php
<?php
  phpinfo();
?>
then saved, made executable (' chmod +x firstexample.php ')
executing the script from a CLI (eg. Putty) with (' ./firstexample.php ') gives the expected/desired result

What does not work:
Entering this code in a file ' ~/domoticz/www/secondexample.php ' :

Code: Select all

<?php
  phpinfo();
?>
and then calling this webpage from a web browser: http://192.168.1.1:8080/secondexample.php
just results in an echo of the entered code (so not executing the code, and (thus) not displaying the outcome)

I expect that something is missing in the internal webserver.
Can someone give a (link to a) solution ?

Thanks !
Mark

Re: Webpage with PHP not working

Posted: Saturday 23 January 2016 16:04
by bizziebis
The built-in webserver of Domoticz is a HTML one. It doesn't handle PHP. If you want PHP, you have to run your own PHP webserver on a different port.

Re: Webpage with PHP not working

Posted: Saturday 23 January 2016 20:37
by Marq
Thanks for the reply.

Any suggestion how to build a webserver which runs php ?

Thanks, Mark

Re: Webpage with PHP not working

Posted: Saturday 23 January 2016 21:20
by chimit
If you have installed php, then probably you also have apache installed.
Put your php scripts in /var/www.

Re: Webpage with PHP not working

Posted: Saturday 23 January 2016 21:21
by Egregius
Apache2 and nginx runs fine on RPi.

Re: Webpage with PHP not working

Posted: Tuesday 26 January 2016 21:11
by Marq
chimit wrote:If you have installed php, then probably you also have apache installed.
Put your php scripts in /var/www.
Indeed, this is true. It works. Thanks !