Raspcherry Pi3 As a Server

Brief


Preparation

  • The Raspbian OS has been installed on device.
  • The device connects to internet correctly.
  • The OS has been updated to the newest.

Docker Installation

  1. Install docker
    $ curl -sSL get.docker.com | sh
  2. Use docker as a non-root user
    $ sudo usermod -aG docker username
  3. Set docker to auto-start
    $ sudo systemctl enable docker
  • Run docker without reboot
    $ sudo systemctl start docker

Reference: Get Started with Docker 1.12 on Raspberry Pi


Nginx & PHP Installation with Docker

  1. Create Dockerfile for Nginx and PHP7 installation.
    Since Raspbian Jessie only supports PHP5, so using docker to install PHP7 is my selection. I can select FROM armv7/armhf-ubuntu to build the image.

  2. Build Docker image.
    $ docker build -t imageName .

  3. Use the image to create environment.
    $ docker run -d -p port1:22 ... -v $(pwd):/mountDir --name containerName imageName


Mysql Installation

Raspbian Jessie contains MySQL:
$ sudo apt-get install mysql-server


JDK Installation

Raspbian Jessie contains oracle-java8-jdk, so use the following command to install it:
$ sudo apt-get install oracle-java8-jdk


Pyenv Installation

  1. Preparation – install dependencies.
    $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm

  2. Install Pyenv

    • Checkout the pyenv to your directory ($HOME/.pyenv is recommended.)
      $ git clone git://github.com/yyuu/pyenv.git .pyenv
    • Define environment variable PYENV_ROOT to point to the path where pyenv repo is cloned and add $PYENV_ROOT/bin to your $PATH for access to the pyenv command-line utility.
      $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
      $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    • Add pyenv init command to shell to enable shims and autocompletion.
      $ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
    • Restart your shell so the path changes take effect.
      $ exec $SHELL

Reference: office website

Or, I can use installer to install it automatically:
$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

  1. Install updating plugins
    If we cannot use pyenv update to update pyenv, I can install update plugins:
    $ git clone git://github.com/yyuu/pyenv-update.git ~/.pyenv/plugins/pyenv-update
    Then pyenv update command is enabled.

  2. List all supported python versions
    $ pyenv install --list

  3. Install the selected one
    $ pyenv install 3.6.0


Minio Installation

Minio could be used to build private cloud storage.

  1. Download minio from its office website.
    $ wget -c https://dl.minio.io/server/minio/release/linux-arm6vl/minio
    $ chmod +x minio
  2. Run the following command to start server:
    $ ./minio server ./storage

Gitbucket Installation

I use gitbucket to build Git server.

  1. Download gitbucket.war from its office website.
  2. Use following command to run it:
    $ java -jar ./gitbucket.war --port=port --gitbucket.home=./repo

MiniDLNA Installation

Don’t use the MiniDLNA contained with Raspbian. It doesn’t support “rmvb”. I need to install it manually.

  1. Mounting your external drive
    • Make the mount directory
      $ mkdir -p /mnt/ext
    • Get UUID of the external drive
      $ sudo lsblk
      /dev/sda1: UUID="4F1A-6384" TYPE="vfat"
    • Update the /etc/fatab by appending the following line:
      UUID=4F1A-6384 /mnt/ext vfat defaults,iocharset=utf8,umask=0000 0 0
  2. Install dependencies
    $ sudo apt-get install autopoint debhelper dh-autoreconf gcc libavutil-dev libavcodec-dev libavformat-dev libjpeg-dev libsqlite3-dev libexif-dev libid3tag0-dev libogg-dev libvorbis-dev libflac-dev
  3. Download the latest miniDLNA source
    $ wget http://sourceforge.net/projects/minidlna/files/latest/download?source=files -O minidlna.tar.gz
  4. Unpack miniDLNA
    $ tar -xvf minidlna*.tar.gz
  5. Enter the source code directory and install miniDLNA
    $ ./configure && sudo make && sudo make install
  6. Copy the default configuration file to /etc
    $ sudo cp minidlna.conf /etc/
  7. Copy the startup daemon script to autostart miniDLNA on boot
    $ sudo cp linux/minidlna.init.d.script /etc/init.d/minidlna
    $ sudo chmod +x /etc/init.d/minidlna
    $ sudo update-rc.d minidlna defaults
  8. Update config file
    $ sudo vim /etc/minidlna.conf

    media_dir=A,/mnt/ext/Music
    media_dir=P,/mnt/ext/Pictures
    media_dir=V,/mnt/ext/Videos
    friendly_name=Raspberry Pi
    inotify=yes
  9. Start serive.
    $ sudo service minidlna start

Reference: Install Latest ReadyMedia miniDLNA Raspberry Pi, Using your Raspberry Pi as a DLNA/UPnP media server


Nodejs Installation

By adding the NodeSource repository, I will also be able to receive updates rather than just installing a standalone (.deb) file version of Node that cannot be updated easily. (NodeSource provides Node.js binaries for these newer ARMv7+ architectures.)

  1. Confirm the CPU info
    $ uname -m
  2. Add NodeSource into source.list
    $ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
  3. Update the source and install nodejs
    $ sudo apt install nodejs

Reference: Beginner’s Guide to Installing Node.js on a Raspberry Pi


VeraCrypt Installation

  1. Get installation file from office website
    $ wget -c https://launchpad.net/veracrypt/trunk/1.19/+download/veracrypt-1.19-raspbian-setup.tar.bz2
  2. Install the software
    $ tar xvf veracrypt-1.19-raspbian-setup.tar.bz2
    $ chmod +x veracrypt-1.19-setup-console-armv7
    $ ./veracrypt-1.19-setup-console-armv7
  3. Install the dependency file
    $ sudo apt install libwxgtk3.0-0
  4. Mount the volume
    $ veracrypt -tc /pathofyourimage
    (-tc: Enable TrueCrypt mode. Should be put first to avoid issues)
  5. Umount volume
    $ veracrypt -d

Reference: Veracrypt in Raspberry Pi

Advertisements

One thought on “Raspcherry Pi3 As a Server

  1. […] gitbook是基于Node.js的命令行工具。首先第一件事就是需要安装node,各个平台的安装方法不同,可以参看官网的指导。我的平台是树莓派3,安装可以参考以前的文章(要是想用最新版的node8,可以将setup_7.x替换成setup_8.x)。nodejs安装完成后,就可以安装gitbook啦: […]

评论已关闭。