Cannot 'Start Script' after following instruction for remote access

Hi Guys. This is my first post after receiving a BrewPi. I had it all working perfectly and accessible remotely but i wanted to pasword protect it so after looking at this forum i followed the setup on this site: http://www.homebrewtalk.com/showpost.php?p=6594822 . Now i have the remote access set up with password protect for the admin user but it will not run the python script. The site cannot receive LCD text from Python script, i can’t start the script and if i try and apply a beer profile i get the status message: ‘Couldn’t write to socket: [2] No such file or directory
Is the script running?’. Can anyone tell me what i have done wrong and how to put it right?

It would be really appreciated!

You have to include the subpages you want to have access to else this will not work. When in doubt look at the logs they will almost always point you in the right direction.

To help guide you in the right direction you need to modify your .htaccess file to include the files:

<FilesMatch "(beer-panel|config|configuration|control-panel|maintenance-panel|program_arduino|save_beer_profile|start_script).php">

Cheers,
-Stephen

Thanks Stephen. I’ve managed to getting working again without this added functionality so going to buy a new sd card tomorrow and clone the current one to it before attempting this phase again. Can i ask a couple of questions to help me? Firstly the instructions say: " modify the first line where it is bold and replace it with what you plan to call your Private PHP file", however nothing is in bold, which part should i be modifying and does it matter what i call it / do i need to change any setting after calling it something different? The other thing is how do i look at the logs to compare?

Sorry for what must be incredibly naive questions but i’m on steep learning curve here.

Many thanks,
Chris.

Not a problem happy to help.

Ok so you’ve reconfigured Apache to look for the .htaccess file which should look like this:

<FilesMatch "index.php">
   AuthUserFile /var/www/private/.htpasswd
  AuthGroupFile /dev/null
  AuthName "YOUR LOGIN ID"
  AuthType Basic
   <Limit GET POST>
   require valid-user
   </Limit>
</FilesMatch>
<FilesMatch "(beer-panel|config|configuration|control-panel|maintenance-panel|program_arduino|save_beer_profile|start_script).php">
 Order deny,allow
 Deny from All
    Allow from YOUR_PRIVATE_IP
</FilesMatch>

In the above you need to change “YOUR LOGIN ID” to the login ID you wish to use and change “YOUR_PRIVATE_IP” to the IP address on your network you wish to allow access from. The last part means you can only login from the host that has that IP on it. As far as what the user is saying to change the first line they are referring to (if you did this verbatim) if you performed this:

sudo mv index.php admin.php

To be honest this is totally not necessary and can be skipped, as you can see in my above example I left mine as index.php and it works fine.

I strongly suggest before you do any of this you take the time to read up on htaccess and really understand what you are doing, as you have already seen you can mess it up in a hurry. Learn the conf figure out what each element does so you have a full understanding of what you are doing. End of the day if you do get stuck we are always here to help.

Cheers,
-Stephen

I now have it working. it took a bit more figuring out because the version of apache2 that i have makes you put the install into /var/www/html in order to run and the default file in etc/apache2/sites-available is now called 000-default.conf.

Thanks again for your help.

Hi Stephen.

 Thanks for your reply a moment ago about the power /sd card.

I thought i had the above fixed and working but i still have something amiss. It all works fine until i stop the script, after i do that i can’t re-start it, the stderr log shows:

wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1

Any ideas?

That’s an error from the network stack on the RPI. WPA is used to control the wlan0 interface and if that daemon is having issues you will have WiFi connection problems.

This article might help get you a fix.

If you still are stuck let us know and we will see what we can figure out.

Cheers,
-Stephen

Hi Stephen.

That error was just a historic one from before the script was stopped, i fixed that issue by removing the wifichecker function. The error that i was having was occurring because for some reason both the script for the .htaccess file as written in the instruction that i was following and by yourself was not running correctly on my install. Elco sorted it for me by amending the script to:

<FilesMatch 
"admin.php|beer-panel.php|config.php|configuration.php|control-panel.php|maintenance-panel.php|previous_beers.php|program_arduino.php|save_beer_profile.php|start_script.php">

Allow from all

authuserFile /var/www/private/.htpasswd

AuthName "YOUR USER NAME"

AuthType Basic

Require valid-user

</FilesMatch>

All working perfectly now so going to stop messing!

Chris.

Dear Chris,

I seem to be having the same problem that you were. Is the above code the ENTIRE .htaccess file or just the top 7 lines.

Thanks,

Matt