Announcement

Collapse
No announcement yet.

Standalone server on a Raspberry Pi

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Standalone server on a Raspberry Pi

    Pi Server Setup capable of hosting SellerDeck sites.

    This demo used Raw Images / Raspbian from http://www.raspberrypi.org/downloads

    Install Raspbian:
    Enabling SSH as part of the initial configuration / Advanced Options).
    Also set a hostname like raspberrypi.

    Now install Samba so we can see the Pi from Windows PC's on our LAN and connect to it by name:
    Code:
    sudo apt-get update
    sudo apt-get install samba samba-common-bin
    You can set up shares, etc but they aren't needed - we just want the hostname to show up on our LAN.
    The Pi should appear on the LAN some time after this.

    Alternatively / or (you can have both) we could set up static IP as per http://elinux.org/RPi_Setting_up_a_static_IP_in_Debian
    This may be useful if you want to port forward on your router so to make the Pi accessible from the Internet at large.
    Be wary of security implications if you let the world in.
    My LAN is 192.168.0.nnn so I chose 192.168.0.141

    From this point on, you no longer need a mouse, keyboard or screen on the Pi and can connect to it by SSH via putty.
    See http://www.chiark.greenend.org.uk/~sgtatham/putty/
    Run putty on your PC, select SSH and enter raspberrypi into Hostname. Open and login.

    Setting up server as per http://www.wikihow.com/Make-a-Raspberry-Pi-Web-Server

    Part 1 of 7: Skipped as the pi is already running.

    Part 2 of 7: Did all of this as I'm using a freshly baked pi.

    Part 3 of 7: Skipped this but you can do it if you want auto updating

    Part 4 of 7: Skipped this as I enabled SSH when initially configuring Pi.
    And I already have putty installed on my main machine.
    Do the putty bit if you want SSH access.

    Part 5 of 7: Did all of this.

    Part 6 of 7: Skipped this as Mysql isn't needed for SD to run and we've a only a 512Mb machine.

    Part 7 of 7: Did all of this.

    That's the server and FTP up and running.
    You should get the default page from http://raspberrypi or http://192.168.0.141

    A change is needed to the FTP server to fix file permissions.
    Code:
    sudo nano /etc/vsftpd.conf
    Scroll down (using down arrow keys) until you see a line:
    Code:
    #local_umask=022
    Delete the inital # to get:
    Code:
    local_umask=022
    Now save and exit the file by pressing CTRL-O, Enter, CTRL-X

    Now we need to get Perl scripts running from the default cgi-bin that's in /usr/lib/cgi-bin
    Code:
    sudo chown pi /usr/lib/cgi-bin
    And make sure permissions are good on our www folder.
    Code:
    sudo chmod 0777 -R /var/www
    However the SellerDeck Search will fail with an internal server error message so we need to load some missing Perl modules.
    First get cpanm installed:
    Code:
    sudo apt-get install curl gcc-4.7
    sudo curl -L http://cpanmin.us | perl - --sudo App::cpanminus
    Then the modules we need are loaded via:
    Code:
    sudo cpanm HTML::Entities Exporter File::Temp LWP::UserAgent CGI CGI::Carp Digest::MD5
    Probably a good idea to reboot the pi after all this.
    Code:
    sudo shutdown -r now
    To create a site, FTP to to e.g. raspberrypi and move to the www directory.
    I'm expecting to upload more than 1 site so each one will go in it's own directory within www.
    Create a new directory for your site. E.g. "testsite" within www.
    Change permissions on testsite to be 777 (check any option to recurse these settings into sub-directories).

    Now SD should run using these network settings.

    Change SCRIPTID, all raspberrypi and FTPPASSWORD to suit.
    Then copy them to a textfile and import them into network settings:
    Code:
    HTTPPROXYMODE	0
    HTTPPROXYADDRESS	
    HTTPPROXYPORT	80
    HTTPPROXYUSER	
    HTTPPROXYPASSWORD	
    FTPPROXYMODE	0
    FTPPROXYADDRESS	
    FTPPROXYPORT	21
    FTPPROXYUSER	
    FTPPROXYPASSWORD	
    SCRIPTID	12011
    SCRIPTEXT	.pl
    SMTPHOST	dummy
    WEBSITEURL	http://raspberrypi/testsite/index.html
    IGNOREPASSIVEERRORS	true
    USERELATIVECGIURLS	false
    PATHTOPERL	/usr/bin/perl -X
    USEENHANCEFTP	true
    FTPBUFFERSIZE	4
    FTPCLIENTTIMEOUT	5000
    FTPRETRYDELAY	3000
    FTPKEEPALIVEINTERVAL	30000
    FTPSILENT	false
    FTPMAXRETRIES	3
    FTPCONNECTTIMEOUT	15000
    SMTPAUTHREQUIRED	false
    SMTPUSERNAME	
    SMTPPASSWORD	
    COMPRESSIONPACKETSIZE	1024
    COMPRESSEDUPLOAD	false
    CATALOGURL	http://raspberrypi/testsite/acatalog/
    ONLINESTOREFOLDERNAME	acatalog
    CGIBINURL	http://raspberrypi/cgi-bin/
    PATHFROMCGITOCATALOG	/home/pi/www/testsite/acatalog/
    FTPHOST	raspberrypi
    FTPUSERNAME	pi
    FTPPASSWORD	*********
    PATHTOCGIBIN	/usr/lib/cgi-bin/
    USEPASSIVEFTP	true
    FTPPATHFROMCGITOCATALOG
    Note that no SMTP server is set-up so I've just used a dummy entry.

    Upload your site.

    Now you should be able to properly browse your site via http://raspberrypi/testsite
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    #2
    And if there are any Linix / Pi gurus out there, could they look at the last few paragraphs above as I've not been able to get vsftpd to upload files with permissions other than 600.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      while since I configured one by hand but I think local_umask 022 in in vsftpd.conf will give you 755 (777-022=755)
      Steve Wardell
      Operations Director
      __________________________

      Comment


        #4
        Steve: I tried that on the bare-iron build I did and it wouldn't work. Just tried it on another Pi and it worked OK. Must have messed something in the vsftpd.conf while testing (it was very late at night). Copied vsftpd.conf from good Pi to bad and now both work. Have edited the big ReadMe above to include the local_umask 022 tweak.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Can a Mod change the Paspberry typo in the threads name please?
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Originally posted by NormanRouxel View Post
            Can a Mod change the Paspberry typo in the threads name please?
            Done. Looks like you're having fun Norman.

            Comment


              #7
              It is fun. Once the initial install and SSH server is running, you can unplug all peripherals and plonk it out of site with just a LAN connection and power from the nearest spare USB port.

              Then tinker from anywhere on your LAN with the added benefit that you can copy / paste from the pc into the putty command window (click the right mouse button within putty to paste).
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                And here are example network settings for a Pi that's accessible from the Internet.

                Using a dyndns.org name and have told the router to forward incoming traffic on port 80 to port 80 on 192.168.0.141.
                Code:
                HTTPPROXYMODE	0
                HTTPPROXYADDRESS	
                HTTPPROXYPORT	80
                HTTPPROXYUSER	
                HTTPPROXYPASSWORD	
                FTPPROXYMODE	0
                FTPPROXYADDRESS	
                FTPPROXYPORT	21
                FTPPROXYUSER	
                FTPPROXYPASSWORD	
                SCRIPTID	12011
                SCRIPTEXT	.pl
                SMTPHOST	dummy
                WEBSITEURL	http://<my_domain>.dyndns.org/testsite/index.html
                IGNOREPASSIVEERRORS	true
                USERELATIVECGIURLS	false
                PATHTOPERL	/usr/bin/perl -X
                USEENHANCEFTP	true
                FTPBUFFERSIZE	4
                FTPCLIENTTIMEOUT	5000
                FTPRETRYDELAY	3000
                FTPKEEPALIVEINTERVAL	30000
                FTPSILENT	false
                FTPMAXRETRIES	3
                FTPCONNECTTIMEOUT	15000
                SMTPAUTHREQUIRED	false
                SMTPUSERNAME	
                SMTPPASSWORD	
                COMPRESSIONPACKETSIZE	1024
                COMPRESSEDUPLOAD	false
                CATALOGURL	http://<my_domain>.dyndns.org/testsite/acatalog/
                ONLINESTOREFOLDERNAME	acatalog
                CGIBINURL	http://<my_domain>.dyndns.org/cgi-bin/
                PATHFROMCGITOCATALOG	/home/pi/www/testsite/acatalog/
                FTPHOST	raspberrypi
                FTPUSERNAME	pi
                FTPPASSWORD	*************
                PATHTOCGIBIN	/usr/lib/cgi-bin/
                USEPASSIVEFTP	true
                FTPPATHFROMCGITOCATALOG
                Note that the FTP server in the Pi is not exposed to the Internet so uploading / downloading will have to be done from within the local LAN.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment

                Working...
                X