4

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?

5
  • 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
    May 7, 2015 at 8:15
  • apache2 is instaleed.What i expect is when pi has boot an ngrok tunnel to be created
    – cssGEEK
    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
    May 7, 2015 at 11:48
  • how can i install ngrok from repo?
    – cssGEEK
    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
    May 7, 2015 at 12:49

3 Answers 3

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 & 
1
  • 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. Jul 25, 2016 at 0:41
2

Have you tried exporting the path variables in the bashrc files?

My best guess is you do the following:

  1. put the ngrokdirectory in a bin/ directory in /home/pi

    mkdir bin
    
  2. give it executable mode

    sudo chmod +x bin/
    
  3. change path variables in .bashrc

    sudo nano ~/.bashrc
    # at the end of the file
    export PATH=$PATH:bin/
    
  4. press CTRL+O and CTRL+X and then

    source ~/.bashrc
    

and maybe try rebooting it again.

I somehow think that maybe there might be problems with path variable settings.

0

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
7
  • what is > /dev/null 2>&1?
    – cssGEEK
    May 7, 2015 at 12:25
  • refer this link stackoverflow.com/a/10508862/4870299 May 7, 2015 at 12:26
  • I tried this but it is not working
    – cssGEEK
    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/tunnels May 7, 2015 at 13:11
  • I don't need a paid account.If I try this from a terminal it works
    – cssGEEK
    May 7, 2015 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.