I've been spending some time to get SonWeb running with a docker container with the final goal to build a docker image for it. Unfortunately until now i did not exceed to run SonWeb from a docker container.
I took the guide from here https://github.com/reloxx13/SonWEB/wiki/Guide-for-Ubuntu-Server-16.04 as a base.
First I started a docker image with the following command:
docker run -ti -p9080:80 -p9999:9999 --name ubuntu-test arm32v7/ubuntuHere port 9080 and 9999 are exposed to the out-side-world in preparation of the default apache webpage (9080) and SonWeb website (9999).
Then is installed the required packages with the following command:
apt-get install -y \
apache2 php libapache2-mod-php php7.0-curl php7.0-zip git nano net-tools curl && \
mkdir -p /var/www/sonweb && \
cd /var/www/sonweb && git clone https://github.com/reloxx13/SonWEB.git . && \
rm /etc/php/7.0/mods-available/opcache.ini && \
cd /var/www/sonweb/ && \
chown www-data:www-data * -R && \
chmod 777 tmp && \
chmod 777 data
Then i created /etc/apache2/sites-available/sonweb.conf with the following content:
<VirtualHost *:9999>
ServerName sonweb
ServerAdmin webmaster@localhost
DocumentRoot /var/www/sonweb/
<Directory /var/www/sonweb/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
And added port 9999 to /etc/apache2/sites-enabled/000-default.conf
Listen 80
Listen 9999
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Then I executed these commands
a2ensite sonweb
a2enmod rewrite
service apache2 reload
service apache2 restart
And finally I checked the listening ports within the container
netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
Until now all steps are as expected and according to the guide, but after accessing SonWeb from an out-site-world browser using http://
Not Found
The requested URL /login was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 192.168.2.101 Port 9999
But when accessing the default apache url http://
I am not an Apache nor a php expert but I hope with some advise to have this issue tackled and finally build a docker image for SonWeb.
Any help is appreciated :-)
Update:
From http://192.168.2.101:9999/ I get redirected to http://192.168.2.101:9999/login which shows me the 404 Not Found. However when I change the url to http://192.168.2.101:9999/login.php it shows me the login page !
After registering with a username and password I could login and add a Sonoff device! Unfortunately the state of this devices showed ERROR and after some time it looks oke with the info of the devices, but toggled into error after a few seconds....
The restart message from the sonoff console shows this message:
00:00:06 MQT: tele/sonoff-pow-1/INFO3 = {"RestartReason":"Fatal exception:9 flag:2 (EXCEPTION) epc1:0x40204eec epc2:0x00000000 epc3:0x00000000 excvaddr:0x000014e9 depc:0x00000000"}
I tried different devices with the same results ...
Heya,
please check if the _/var/www/sonweb/.htaccess_ file exists in your directory.
Its a hidden file and easily happens that it does not get copied.
if not done, best way would be to checkout sonweb with git
cd /var/www/sonweb
git clone https://github.com/reloxx13/SonWEB .
should do it.
also pls double check that this worked and reload&restart apache
a2enmod rewrite
if it worked, their should be a rewrite.mod (dunno exact name, but you will see it) in the /etc/apache2/mods-enabled/ directory.
Hi,
I just checked the .htaccess file and it exists in the given directory:
root@12ae994c0018:/var/www/sonweb# ls -al
drwxr-xr-x 11 root root 4096 Feb 15 20:08 .
drwxr-xr-x 4 root root 4096 Feb 15 20:08 ..
drwxr-xr-x 8 root root 4096 Feb 15 20:08 .git
-rw-r--r-- 1 root root 260 Feb 15 20:08 .gitignore
-rw-r--r-- 1 root root 1956 Feb 15 20:08 .htaccess
-rw-r--r-- 1 www-data www-data 2499 Feb 15 20:08 CHANGELOG.md
-rw-r--r-- 1 www-data www-data 3214 Feb 15 20:08 CODE_OF_CONDUCT.md
-rw-r--r-- 1 www-data www-data 35147 Feb 15 20:08 LICENSE
-rw-r--r-- 1 www-data www-data 3228 Feb 15 20:08 README.md
drwxrwxrwx 4 www-data www-data 4096 Feb 15 21:00 data
drwxr-xr-x 2 www-data www-data 4096 Feb 15 20:08 dev
drwxr-xr-x 2 www-data www-data 4096 Feb 15 20:08 includes
-rw-r--r-- 1 www-data www-data 1467 Feb 15 20:08 index.php
drwxr-xr-x 2 www-data www-data 4096 Feb 15 20:08 lang
drwxr-xr-x 4 www-data www-data 4096 Feb 15 20:08 libs
-rw-r--r-- 1 www-data www-data 4475 Feb 15 20:08 login.php
drwxr-xr-x 3 www-data www-data 4096 Feb 15 20:08 pages
drwxr-xr-x 5 www-data www-data 4096 Feb 15 20:08 resources
drwxrwxrwx 3 www-data www-data 4096 Feb 15 21:00 tmp
I also executed the following commands once more:
$ a2enmod rewrite
Module rewrite already enabled
$ service apache2 reload
* Reloading Apache httpd web server apache2 *
$ service apache2 restart
* Restarting Apache httpd web server apache2
And checked if rewrite.load -> ../mods-available/rewrite.load exists in /etc/apache2/mods-enabled/ and is does ...
try setting the ownership of the .htaccess file
chown www-data:www-data .htacces
or on all
chown www-data:www-data /var/www/sonweb -R
Unfortunately that didn't help either ...
chown www-data:www-data /var/www/sonweb -R
root@12ae994c0018:/var/www/sonweb# ls -al
total 112
drwxr-xr-x 11 www-data www-data 4096 Feb 15 20:08 .
drwxr-xr-x 4 root root 4096 Feb 15 20:08 ..
drwxr-xr-x 8 www-data www-data 4096 Feb 15 20:08 .git
-rw-r--r-- 1 www-data www-data 260 Feb 15 20:08 .gitignore
-rw-r--r-- 1 www-data www-data 1956 Feb 15 20:08 .htaccess
-rw-r--r-- 1 www-data www-data 2499 Feb 15 20:08 CHANGELOG.md
-rw-r--r-- 1 www-data www-data 3214 Feb 15 20:08 CODE_OF_CONDUCT.md
-rw-r--r-- 1 www-data www-data 35147 Feb 15 20:08 LICENSE
-rw-r--r-- 1 www-data www-data 3228 Feb 15 20:08 README.md
drwxrwxrwx 4 www-data www-data 4096 Feb 15 21:00 data
drwxr-xr-x 2 www-data www-data 4096 Feb 15 20:08 dev
drwxr-xr-x 2 www-data www-data 4096 Feb 15 20:08 includes
-rw-r--r-- 1 www-data www-data 1467 Feb 15 20:08 index.php
drwxr-xr-x 2 www-data www-data 4096 Feb 15 20:08 lang
drwxr-xr-x 4 www-data www-data 4096 Feb 15 20:08 libs
-rw-r--r-- 1 www-data www-data 4475 Feb 15 20:08 login.php
drwxr-xr-x 3 www-data www-data 4096 Feb 15 20:08 pages
drwxr-xr-x 5 www-data www-data 4096 Feb 15 20:08 resources
drwxrwxrwx 3 www-data www-data 4096 Feb 15 21:00 tmp
root@12ae994c0018:/var/www/sonweb# service apache2 restart
* Restarting Apache httpd web server apache2
im sorry, this all looks correct for me :(
Listen should be in httpd.conf ( i believe ), but it should not matter, the site configs gets included in teh httpd.conf
check if the 000-defaul.... conf has no
AllowOverride None
in it and if it is change it to All
i would just google for apache htaccess rewrit enot working and try everything.
What I just don't understand is
"From http://192.168.2.101:9999/ I get redirected to http://192.168.2.101:9999/login which shows me the 404 Not Found. However when I change the url to http://192.168.2.101:9999/login.php it shows me the login page !" 馃
cuz the htacces does not getting loaded.
the htacces is intern routing /login to /login.php
Just to let you know... After logging in it looks as if all other pages are accessible as they should be...
Unfortunately I came across the other issues, I mentioned earlier :(
without .php at the end of the url? thats strange.
e.g. http://192.168.178.10:9999/start
i also checked it locally, http://192.168.178.10:9999/login works for me
00:00:06 MQT: tele/sonoff-pow-1/INFO3 = {"RestartReason":"Fatal exception:9 flag:2 (EXCEPTION) epc1:0x40204eec epc2:0x00000000 epc3:0x00000000 excvaddr:0x000014e9 depc:0x00000000"}
this is very strange, too. sonweb only starts the http command like
http://sonoffip/cm?cmnd=status%200
i never heard of it crashing the devices Oo
Are you running from a windows setup or Ubuntu? Maybe there is a difference in the setup between those 馃
windows with xampp and ubuntu in vmware checked
That's good to know! I'll try to setup an Ubuntu machine in a virtual environment but not in a docker container and follow the same setup as described before and see what happens then... I'll keep you posted.
From google:
New apache version has change in some way. If your apache version is 2.4 then you have to go to /etc/apache2/. There will be a file named apache2.conf. You have to edit that one(you should have root permission). Change directory text like this
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Now restart apache.
service apache2 reload
Hope it works.
This is the section from apache2.config without any modifications
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
So basically the change you mentioned it already in there ...
nuuu, see this:
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
you could set all None to All and try
but basically teh sonweb.conf should overwrite it
Wooow sharp eyes at this hour! ... I changed as you suggested and it WORKS!
I guess this was not as expected, like you said .. sonweb.conf should override it right?
yup and im pretty sure i did not change this on my ubuntu vm.
i dunno why it did not get overwritten, but if it works 馃憤
ill add a hint for that in the wiki tomorrow, off for sleep now :p
do a git pull or selfupdate first pls :)
Most helpful comment
nuuu, see this:
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
you could set all None to All and try
but basically teh sonweb.conf should overwrite it