Hassio as a web server / addon

I’ve recently begun fiddling around with PHP at home, and so have installed Xampp on my Mac and I can access (locally) sites that I create. Nothing fancy but it’s a start. I’m thinking I might make a sort of household ‘organiser’ / to-do list that I can display on an iPad in our kitchen.

However the trouble is that my Mac is not always on, or always at home.

I have a Raspberry Pi running Hassio at home, so I wondered if there was a way / any add-ons for Hassio that essentially allow it to function as an apache / PHP web server?

The other option is to get another Pi and use that as the server but I’d rather not if I can avoid it.

2 Likes

Hi, you may have a look here.
The AddOn tutorial includes setting up a python3 http server.

EDIT: Link updated

Thanks, I’ll dig into it!

Old topic I know, but a generic web server add-on would be really useful (I’ve looked and not found one). I’ve got some simple php pages that I’d like to use for my weather station.

@frenck could you add one to your repertoire, please? :pleading_face:

1 Like

The problem is “what is generic?” You use PHP as a server side language. Some people use other languages. As a developer of such an add-on it would mean all kinds of people asking to add support for whatever language or Apache module or anything like that to add to the HA add-on. I don’t think this would be a good way to spend HA development time. If you install HA on your RPI on top of a normal raspbian image using docker (explained on the installation page in the documentation on the HA website) you can choose from the many LAMP docker containers on docker hub to run on the side.

Yes I acknowledge that. I’m sure there are solutions to that though. For me, it would certainly not be for anything that required a complex setup - it is for the hosting of a simple mini website. I also suspect that, for someone who knows the add-on system, it would be relatively quick as it seems that various parts are already templated. I would also wager that PHP modules could easily be included (much like Node-RED npm packages can be installed via the options).

My thought is that there are lots of custom views that could then be created using the iframe card in Lovelace that could point to this local webserver.

The problem with a generic docker, is it loses the integration with the supervisor, SSL etc.

2 Likes

If anyone is still searching for this. I have created a apache2 hassio addon.
More information is here: https://github.com/FaserF/hassio-addons/tree/master/apache2

8 Likes

I’ve installed the add-ons for DuckDNS, MariaDB, phpMyAdmin and your Apache2. My index.html displays just fine. Thank you very much! However, none of my .php programs will display. Perhaps you can tell me the most likely cause of php problems. I’m not sure where to start.

Have you tried it with my newest version? I have fixed some bugs.
Does no php page work or only some?

Thanks FaserF !! What whould be the way if I want to host more thant 1 web site. NGINX reverse proxy doesnt allow me to redirect to subpath, only other port.

Hey, when I try to install your add on (the full version) it is failing. Does this mean anything to you?

The command ‘/bin/ash -o pipefail -c apk add --no-cache $MUSL_LOCALE_DEPS && wget https://gitlab.com/rilian-la-te/musl-locales/-/archive/master/musl-locales-master.zip && unzip musl-locales-master.zip && cd musl-locales-master && cmake -DLOCALE_PROFILE=OFF -D CMAKE_INSTALL_PREFIX:PATH=/usr . && make && make install && cd … && rm -r musl-locales-master’ returned a non-zero code: 99

I have reproduced your issue and fixed it in the newest version 2.1.0
Please give it a new try with that version.

Btw on what hardware where you running the addon?

hmmm, good question. Right now I dont have support in my addons for multiple sites.
You could use for example the full apache2 addon and also a minimal apache2 addon from my addons.
Both at the same time. This would allow you to host multiple sites.

Hey - it’s working now, I was able to install the addon.

I do have another question, and it is probably extremely stupid, but… I’m not quite sure how to access the page I created.

I created it a while back and was hosting it (locally) with Xampp, so I just copied my htdocs folder to my Home Assistant PI (Pi\share\htdocs).

But when I launch the web UI from the addon I just get: 502: Bad Gateway

I’ve not configured SSL so basically the only thing of note in my configuration is the document_root: /share/htdocs

I feel extremely stupid. :slight_smile:

There is no need to feel stupid :slight_smile:
If you are launching the web ui from the addon (ingress) it is normal to get the 502 error.
That is due to the need of an SSL certificate, described here:

and here: Apache | Open Web UI results in 502: Bad Gateway · Issue #5 · FaserF/hassio-addons · GitHub

So you have to ways:

  • Open your website through your browser: http://ipfromyourpi:portdefinedinthehaaddon
  • Install my OpenSSL Addon and use a OpenSSL certificate, setup the certificate in the addon config → Then you should be able to use ingress

Doh! That makes sense now. I had been playing around with it that way too and was getting a connection error, now I realise it was actually a connection error generated from my php failing to connect to the DB. I remembered that when I installed through XAMPP it went through the process of creating the underlying DB etc too.

Now I’ll try figure that out - thanks again for your help.

When it says Open Web UI this does not mean a web UI for Apache2, it means your actual page?

Exactly, it will open your website, that you have defined in the addon settings which is just hosted by the apache2 addon.

okay, okay, great! thank you! basically the key to getting everything to wokr is understanding nginx whcih i messed with all day today. I was thinking Open WebUI was supposed to open some kind of special admin page for apache or whatever.

Thank you!!

Hey man, I thought of something else I Wanted to ask you. Is there really no way to like run multiple instances of the add-on through 1 HA OS install? I’d really like to try and host another page becauze neither of them are going to get alot of traffic. Have you ever see nanyone host 2 pages with your add-on?

Thanks