I have a raspberry pi which I want to turn into a web server. I have installed everything needed. Now my problem: I am using ngrok
to get the server online. To do this all I have to do is running the following command in the terminal:
/home/pi/Downloads/ngrok http -subdomain=asimpledomain 80
Now I want this command to be executed on startup so I changed my rc.local file to this:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/pi/Downloads/ngrok http -subdomain=asimpledomain 80 &
exit 0
I have saved the files and rebooted but after booting up I found out that this is not working. Any ideas?
-
I have no idea. It might help if you say in your post what you expected to happen and how you know it's not working. As a side question why not just do sudo apt-get install apache2?joan– joan2015年05月07日 08:15:08 +00:00Commented May 7, 2015 at 8:15
-
apache2 is instaleed.What i expect is when pi has boot an ngrok tunnel to be createdcssGEEK– cssGEEK2015年05月07日 11:18:32 +00:00Commented May 7, 2015 at 11:18
-
As a matter of interest did you install ngrok from the Raspbian repository? I'd have assumed it would handle the initialisation automatically.joan– joan2015年05月07日 11:48:54 +00:00Commented May 7, 2015 at 11:48
-
how can i install ngrok from repo?cssGEEK– cssGEEK2015年05月07日 12:24:14 +00:00Commented May 7, 2015 at 12:24
-
apt-cache search ngrok shows ngrok-client and ngrok-server packages. Install the one(s) you want with sudo apt-get install ngrok-client and/or sudo apt-get install ngrok-server.joan– joan2015年05月07日 12:49:01 +00:00Commented May 7, 2015 at 12:49
3 Answers 3
You may want to try running a test to see if it throws errors without a reboot:
sudo service rc.local start
then check it from there. You may have to run it as a specific user:
sudo -u pi /home/pi/Downloads/ngrok http -subdomain=asimpledomain 80 &
-
So if service rc.local start doesn't show an error, then it should execute correctly upon every boot of pi? Ngrok doesn't start for me.IgorGanapolsky– IgorGanapolsky2016年07月25日 00:41:41 +00:00Commented Jul 25, 2016 at 0:41
Have you tried exporting the path variables in the bashrc
files?
My best guess is you do the following:
put the
ngrok
directory in abin/
directory in/home/pi
mkdir bin
give it executable mode
sudo chmod +x bin/
change path variables in
.bashrc
sudo nano ~/.bashrc # at the end of the file export PATH=$PATH:bin/
press
CTRL+O
andCTRL+X
and thensource ~/.bashrc
and maybe try rebooting it again.
I somehow think that maybe there might be problems with path variable settings.
Have to tried accessing website without reboot and without modifying rc.local?
I suppose you can opt for crontab instead of rc.local..
crontab entry via crontab -e
:
@reboot /home/pi/Downloads/ngrok http -subdomain=asimpledomain 80 & > /dev/null 2>&1
-
what is > /dev/null 2>&1?cssGEEK– cssGEEK2015年05月07日 12:25:10 +00:00Commented May 7, 2015 at 12:25
-
refer this link stackoverflow.com/a/10508862/4870299nageswar rao– nageswar rao2015年05月07日 12:26:49 +00:00Commented May 7, 2015 at 12:26
-
I tried this but it is not workingcssGEEK– cssGEEK2015年05月07日 13:05:10 +00:00Commented May 7, 2015 at 13:05
-
Do you have paid account in ngrok? AFAIK ngrok allows own subdomain in paid account. For free account, try this command /home/pi/Downloads/ngrok tcp 80 See active tunnels with this command (if ngrok running in backgound) curl localhost:4040/api/tunnelsnageswar rao– nageswar rao2015年05月07日 13:11:24 +00:00Commented May 7, 2015 at 13:11
-
I don't need a paid account.If I try this from a terminal it workscssGEEK– cssGEEK2015年05月07日 13:12:13 +00:00Commented May 7, 2015 at 13:12