Problem install Raspcontrol on Raspbian


23 posts
by FeersumEndjinn » Tue Aug 21, 2012 8:16 pm
Hi all,

I'm trying to follow the instructions to install Raspcontrol on my pi - however the current guide is confusing?

I'm following the guide at http://raspcontrol.com/getting-started-guide/ but I only want to deploy it with PHP as it states. I have installed PHP 5.4 but when I run:

Code: Select all
sudo ./start.sh


I get :
Code: Select all
[Tue Aug 21 21:13:02 2012] Failed to listen on 0.0.0.0:80 (reason: Address already in use)


If I edit start.sh to use a different port (such as 8080) it works (kind of). I don't have Apache or nginx installed, so I don't know what else is already using 0.0.0.0:80.

If I use port 8080 the server runs and I can get the first page up from another machine on my network, but it won't let me login? The guide says you will be prompted to create an account but I'm not, and I can't login with pi username.

I don't want to install Apache (it says you can deploy purely under php 5.4) but I don't get whats going on due to the badly written guide. I've tried exploring other .php files in the directory as well but with no luck.

Regards,
Morrolan / FeersumEndjinn

"And the lord God said unto John, 'Come forth and receive eternal life', but John came fifth and won a toaster."
User avatar
Posts: 148
Joined: Mon Nov 21, 2011 4:02 pm
by Keschy » Tue Aug 21, 2012 9:03 pm
did you try "netstat -plnt" ?
My Webpage: http://derkev.in
User avatar
Posts: 21
Joined: Sat Aug 18, 2012 9:30 pm
Location: Mainz / Germany
by FeersumEndjinn » Tue Aug 21, 2012 9:13 pm
No I didn't - I have no idea what -pint does (although I know what netstat does.

The following is returned when I run netstat -pint:

Code: Select all
pi@raspberrypi ~/Raspcontrol $ netstat -pint
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0     13179      0      0 0          4147      0      0      0 BMRU
lo        16436 0         0      0      0 0             0      0      0      0 LRU
Morrolan / FeersumEndjinn

"And the lord God said unto John, 'Come forth and receive eternal life', but John came fifth and won a toaster."
User avatar
Posts: 148
Joined: Mon Nov 21, 2011 4:02 pm
by Pugsey » Tue Aug 21, 2012 9:37 pm
You can delete the "database.aptmnt" file from /etc/raspcontrol, and then it will create a new login
when you goto the login page again.

or you can view the login username and password in that file /etc/raspcontrol/database.aptmnt
i use winscp its a lot easier.

Paul
Posts: 1
Joined: Tue Aug 21, 2012 9:27 pm
by Keschy » Wed Aug 22, 2012 6:41 am
it's a L (uncapitalized) - not an i :D

p - Show the PID and name of the program to which each socket belongs.
l - Show only listening sockets
n - Show numerical addresses instead of trying to determine symbolic host, port or user names.
t - TCP
My Webpage: http://derkev.in
User avatar
Posts: 21
Joined: Sat Aug 18, 2012 9:30 pm
Location: Mainz / Germany
by FeersumEndjinn » Wed Aug 22, 2012 7:34 am
Code: Select all
pi@raspberrypi ~/Raspcontrol $ netstat -plnt
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 10.12.3.9:8080          0.0.0.0:*               LISTEN      -   


Strange that it won't let me start anything on 0.0.0.0:80 when nothing else is using it though.
Morrolan / FeersumEndjinn

"And the lord God said unto John, 'Come forth and receive eternal life', but John came fifth and won a toaster."
User avatar
Posts: 148
Joined: Mon Nov 21, 2011 4:02 pm
by FeersumEndjinn » Wed Aug 22, 2012 12:31 pm
Pugsey wrote:can view the login username and password in that file /etc/raspcontrol/database.aptmnt
i use winscp its a lot easier.


That would be great if I used Windows :)
Morrolan / FeersumEndjinn

"And the lord God said unto John, 'Come forth and receive eternal life', but John came fifth and won a toaster."
User avatar
Posts: 148
Joined: Mon Nov 21, 2011 4:02 pm
by FeersumEndjinn » Wed Aug 22, 2012 1:34 pm
Whenever I installed php5 it was installing apache2 along with it - I've now edited the Apache2 ports.conf file to make Apache listen on another port (8081) freeing up port 80.

How can I permanently disable Apache to prevent it from starting?

Also, how can I start raspcontrol automatically on bootup? adding the start.conf to etc/init.d and issuing:
Code: Select all
sudo update-rc.d start.sh defaults 19


and performing a reboot didn't automatically start it?
Morrolan / FeersumEndjinn

"And the lord God said unto John, 'Come forth and receive eternal life', but John came fifth and won a toaster."
User avatar
Posts: 148
Joined: Mon Nov 21, 2011 4:02 pm
by Bioshox » Thu Aug 23, 2012 1:52 pm
Hai,

I'm the creator of the Raspcontrol project.

Sorry about my poorly written guide, more focused on development than a guide...

Anyway you can't start the server on boot as it runs on a PHP Development Server also if you can't kick the server up on port 80, it seems like something else is running on port 80.

Also, you probably didn't realize that you were setting the account up... I need to make that more intuitive, sorry!
Owner of: http://www.fusionstrike.com - I make gorgeous Raspberry Pi Tutorials :)
Posts: 100
Joined: Sun May 27, 2012 12:18 pm
Location: Manchester, United Kingdom.
by banjax » Sun Sep 09, 2012 1:26 am
can you elaborate on why it can't be run on startup? When I boot my raspberry pi, the only thing I have to do to fire up raspcontrol is sudo ./start.sh so it stands to reason that I should be able to add start.sh to a list of things to run on startup. I'm fairly new to this, so I am probably wrong. I would just like to understand why.
Posts: 2
Joined: Thu Aug 23, 2012 1:55 pm
by red6 » Thu Sep 20, 2012 7:29 pm
Stands to reason that raspcontrol startup script should run if put in 'rc.local'. I'll test it out.
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by red6 » Thu Sep 20, 2012 7:55 pm
Try these steps.

1. Move apache2 to port 8080 by editing ports.conf.

2. Change the default Raspcontrol 'start.sh' script as follows:
(this assumes that RaspControl dir is in /root
Code: Select all
#! /bin/sh

INIFILE="/root/Raspcontrol/server/server.ini"
DOCROOT="/root/Raspcontrol/app/"
ROUTER="/root/Raspcontrol/server/router.php"
HOST=0.0.0.0
PORT=80

PHP=$(which php)

if [ $? != 0 ] ; then
        echo "Unable to find PHP"
        exit 1
fi

$PHP -S $HOST:$PORT -c $INIFILE -t $DOCROOT $ROUTER

exit 0



3. Add a line /root/Raspcontrol/start.sh to rc.local before the exit 0 .

3. Reboot

4. Run the following to see if php is running on port 80 and apache2 is running on port 8080
Code: Select all
 netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1437/sshd
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1473/php
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      1276/apache2
udp        0      0 192.168.1.139:123       0.0.0.0:*                           1401/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           1401/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           1401/ntpd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1218/dhclient
udp        0      0 0.0.0.0:10095           0.0.0.0:*                           1218/dhclient
root@raspberrypi:~#
root@raspberrypi:~#


5. Got to "http:/xxx.yyy.zzz.www" with your favourite browser.

Seems to work for me.
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by red6 » Fri Sep 21, 2012 12:16 am
Oops. The above works but puts output on the hdmi console.

Try this inside 'start.sh' to get running on startup and in background.

Code: Select all
nohup $PHP -S $HOST:$PORT -c $INIFILE -t $DOCROOT $ROUTER > /dev/null 2>&1


Although this seems to block the hdmi console from presenting a login prompt so still not a perfect solution.
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by red6 » Fri Sep 21, 2012 6:44 pm
capture.PNG
capture.PNG (49.54 KiB) Viewed 3388 times
Here is a way that works nicely and I have tested it:

You want you RaspControl to start at boot, running under 'screen' detached from the hdmi console.

So you use this in your start.sh script:
Code: Select all
screen -dmS myraspcontrolname /usr/bin/php -S 0.0.0.0:80 -c /home/me/Raspcontrol/server/server.ini -t /home/me/Raspcontrol/app/ /me/Raspcontrol/server/router.php
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by mcgyver83 » Tue Dec 04, 2012 6:41 pm
You mean to add your lines under the already present lines in start.sh?
I ask instead of trying because I'm configuring my raspberry from remote and I cannot do anything if it hangs.
Posts: 316
Joined: Fri Oct 05, 2012 11:49 am
by red6 » Tue Dec 04, 2012 7:33 pm
Here is my start.sh. But I must admit I haven't actually used Raspcontrol since September...

Code: Select all
root@rasp2:~/Raspcontrol# cat start.sh
#! /bin/sh

INIFILE="/root/Raspcontrol/server/server.ini"
DOCROOT="/root/Raspcontrol/app/"
ROUTER="/root/Raspcontrol/server/router.php"
HOST=0.0.0.0
PORT=80

PHP=$(which php)

if [ $? != 0 ] ; then
        echo "Unable to find PHP"
        exit 1
fi

screen -dmS raspcontrol $PHP -S $HOST:$PORT -c $INIFILE -t $DOCROOT $ROUTER

exit 0

#INIFILE="$(pwd)/server/server.ini"
#DOCROOT="$(pwd)/app/"
#ROUTER="$(pwd)/server/router.php"
#HOST=0.0.0.0
#PORT=80

#PHP=$(which php)

#if [ $? != 0 ] ; then
#       echo "Unable to find PHP"
#       exit 1
#fi

# $PHP -S $HOST:$PORT -c $INIFILE -t $DOCROOT $ROUTER

Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by mcgyver83 » Tue Dec 04, 2012 8:27 pm
Thanks!
Why you don't use it?
Posts: 316
Joined: Fri Oct 05, 2012 11:49 am
by red6 » Tue Dec 04, 2012 8:45 pm
Waiting for newer features in it. And maybe I should check to see if there is a new release :D
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by mcgyver83 » Tue Dec 04, 2012 9:00 pm
I tried your start.sh but how can I autorun it at boot time?
If I type
Code: Select all
sudo ./start.sh
it complains about "screen"
Posts: 316
Joined: Fri Oct 05, 2012 11:49 am
by red6 » Tue Dec 04, 2012 9:42 pm
Is 'screen' installed? If not then do
[code]
apt-get install screen
[/code]
if you are root.

Or
[code]
sudo apt-get install screen
[/code]
if you are not root.
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by mcgyver83 » Tue Dec 04, 2012 9:49 pm
I find find out what "screen" is and installed it :D

Now I'm facing with the " missing LSB tags and overrides" problem.
I added
Code: Select all
### BEGIN INIT INFO
# Provides:          raspcontrol
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start raspcontrol
### END INIT INFO


to your start.sh, symbolic link from /home/pi/raspcontrol/start.sh to /etc/init.d/startRaspControl.sh, run
Code: Select all
sudo update-rc.d startRaspControl.sh defaults
and now I'm going to reboot :-)


:cry:
Something goes wrong and now my raspberry won't boot...I asked to my father to insert the sd into my desktop pc and I'm restoring the card from a backup img...Damn...I'm far from home and I have to handle all from remote...
Posts: 316
Joined: Fri Oct 05, 2012 11:49 am
by red6 » Tue Dec 04, 2012 10:22 pm
'screen' is really handy. We use it on a linux box to run a minecraft server under CentOS 6.3
Minecraft is game that runs under java and 'screen' seems to be the way most people get Minecraft running.
Posts: 47
Joined: Thu Sep 20, 2012 12:32 am
Location: Toronto, Canada
by mcgyver83 » Wed Dec 05, 2012 3:09 pm
I red something about "screen" but how can I achieve raspcontrol autostart?
I made a symbolic link from /home/pi/raspcontrol/start.sh to /etc/init.d/startRaspControl.sh, executed
Code: Select all
sudo update-rc.d startRaspControl.sh defaults
but my raspberry wasn't accesible from remote after the reboot.
Posts: 316
Joined: Fri Oct 05, 2012 11:49 am