Page 1 of 1
Apache on top of Domoticz
Posted: Sunday 20 November 2016 23:18
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 ?
Re: Apache on top of Domoticz
Posted: Monday 21 November 2016 6:40
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.
Re: Apache on top of Domoticz
Posted: Monday 21 November 2016 7:44
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/
Re: Apache on top of Domoticz
Posted: Monday 21 November 2016 7:58
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
Re: Apache on top of Domoticz
Posted: Saturday 24 December 2016 14:56
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
do I have the best performance as you did discribe above ? Or some additional install settings needed.
Re: Apache on top of Domoticz
Posted: Saturday 24 December 2016 15:02
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.
Re: Apache on top of Domoticz
Posted: Saturday 24 December 2016 15:24
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 !
Re: Apache on top of Domoticz
Posted: Wednesday 28 December 2016 13:27
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)
Re: Apache on top of Domoticz
Posted: Wednesday 28 December 2016 13:46
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.
Re: Apache on top of Domoticz
Posted: Thursday 23 February 2017 9:22
by per42
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.