Apache on top of Domoticz

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
sghazagh
Posts: 9
Joined: Friday 28 October 2016 1:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Apache on top of Domoticz

Post by sghazagh »

Hi guys,
I have a little bit confused with Domoticz and the way it running it web contents!

First of all, I am talking about Domoticz on Raspberry Pi.
- So, I think Domotics does not use any standard web server like Apache or NginX. Does it?
If yes, why I cannot run my own .php file located in Domoticz www folder?
Is there any explanation why I cannot run PHP scripts on Domoticz and it always end up showing the "Domoticz Offline" message?
I also cannot run PHP on SSH login so it seams that PHP is not installed at all!

- If not, can I install Apache+PHP on top of Domoticz to serve my own PHP scripts on different port like 80 as normal web server on ex. /var/www/html ?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Apache on top of Domoticz

Post by Egregius »

To show a PHP page you need a PHP enabled webserver.
De built-in webserver of Domoticz doesn't.
It's perfectly possible to run Apache2 or Nginx together with Domoticz on a RPi.
I always use Apache2, just for the simple reason that it was the first webserver I used and it never let me down.
Some say Nginx is lighter and faster, don't know if you would sence a difference for single user pages.
Only thing to keep in mind is that you need to use different ports than Domoticz.
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Apache on top of Domoticz

Post by stlaha2007 »

A little addition to Egregius as he probebly missed it...

To run php-scripts on commandline php needs to be installed. As you don't need a webserver to run php.

What you need is google for instructions to install php, and apache2 with php enabled. Dont forget to change default listening ports [domoticz 8080 and 443] apache [80 and 443].

After that you can run php-scripts directly from CLI and you can also use apache as front for domoticz with reverse proxy like http://apache.ip.address/domoticz/
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Apache on top of Domoticz

Post by Egregius »

True, there's a difference between hosting a PHP webpage and running a php script from CLI.
Hosting a page => Apache2/Nginx with PHP enabled
CLI => php5-cli / php7.0-cli

PHP7.0 is definitely faster than PHP5.6 so that might be the better option.

In my pass2php script I noticed also a big difference in response time between executing these 2 commands:

Code: Select all

os.execute('/volume1/web/secure/pass2php.php "'..c..'" "'..s..'" "'..i..'" "'..t..'" &')
os.execute('curl -s --data "c='..c..'&s='..s..'&i='..i..'&t='..t..'" http://127.0.0.1/secure/pass2php.php &')
The curl is twice as fast!
That's probably because I have Opcache enabled in PHP7.0
edje1205
Posts: 34
Joined: Tuesday 20 December 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Apache on top of Domoticz

Post by edje1205 »

Egregius wrote:To show a PHP page you need a PHP enabled webserver.
De built-in webserver of Domoticz doesn't.
It's perfectly possible to run Apache2 or Nginx together with Domoticz on a RPi.
I always use Apache2, just for the simple reason that it was the first webserver I used and it never let me down.
Some say Nginx is lighter and faster, don't know if you would sence a difference for single user pages.
Only thing to keep in mind is that you need to use different ports than Domoticz.
Little bit OffT but:

what's the best way to install Apache2 in RPi for Domoticz?Floorplan ?

If

Code: Select all

sudo apt-get install apache2


do I have the best performance as you did discribe above ? Or some additional install settings needed.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Apache on top of Domoticz

Post by Egregius »

I think you'll come close with this:

Code: Select all

sudo apt-get install apache2 php5 php5-cli php5-common php5-curl php5-json
Needed packages will be selected automatically then.
If you find a php7 repository for your platform that would be faster but that's no more than 1 millisecond or so.
edje1205
Posts: 34
Joined: Tuesday 20 December 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Apache on top of Domoticz

Post by edje1205 »

Egregius wrote:I think you'll come close with this:

Code: Select all

sudo apt-get install apache2 php5 php5-cli php5-common php5-curl php5-json
Needed packages will be selected automatically then.
If you find a php7 repository for your platform that would be faster but that's no more than 1 millisecond or so.
yep php5 is oke to me I don't notice 1 millisecond :)
I will start next week with this

for now:

Happy days !
edje1205
Posts: 34
Joined: Tuesday 20 December 2016 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Apache on top of Domoticz

Post by edje1205 »

In another treath I did setup as above: I expected apache2. My floorplan is visible in the browser at /var/www/html
Egregius wrote:the folder depends on the settings of the webserver.
For apache2 that should be /var/www by default. I think for Nginx /var/www/html. For webstation on syno /volume1/web
I think my webserver is Nginx. Did I read somewere here apache2 is better for floorplan ? and how to switch on to apache2 ?
(can't figure it out with google)
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Apache on top of Domoticz

Post by Egregius »

I think they're both equally the same and shouldn't make a difference.
Only real difference is the config files.
Performance, cpu, memory doesn't differ much as you'll probably will have only one or two people using it, not thousands like on real loaded webservers.
per42
Posts: 8
Joined: Sunday 19 February 2017 11:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Apache on top of Domoticz

Post by per42 »

stlaha2007 wrote:... and you can also use apache as front for domoticz with reverse proxy like http://apache.ip.address/domoticz/
Just a little warning: If you do use apache as a front for domoticz make sure you don't add your local network in settings (to bypass password protection) since domoticz will see the ip address of the apache server, not wherever you browse from, which will let anyone in without password if you make it accessable from the internet.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest