![]() |
|
Rock64 Webserver / NAS project - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: ROCK64 (https://forum.pine64.org/forumdisplay.php?fid=85) +--- Forum: Rock64 Hardware and Accessories (https://forum.pine64.org/forumdisplay.php?fid=89) +--- Thread: Rock64 Webserver / NAS project (/showthread.php?tid=5879) |
Rock64 Webserver / NAS project - mikedhoore - 03-21-2018 First, I would like to introduce myself briefly. I am Mike, 26 years old and I’m currently studying at Erasmus University College in Brussels. For a lesson "Trends & Talents" I must develop a project independently that is not given in another lesson. I already started another post before deciding to use this project as my school project ( https://forum.pine64.org/showthread.php?tid=5132 ). The main idea is to build a Linux server with 2 main goals, a web server and a personal NAS(mainly for home use). Web server For now I own a domain name with a web hosting and no SSL. I will install and configure Apache, MariaDB and PHP to run my HTML/PHP website, additional I will install tomcat and java to run my java projects. I will use Let’s encrypt and Certbot to handle the SSL/TLS-certificates to make sure that all the traffic uses the safer HTTPS protocol. NAS Now I own a Netgear Readynas 102 with 2x3TB WD red disks, this to share my files in my home network. My Readynas is synced with a Cloud service through my Laptop. The 2x3TB disk will be connected to the Rock with 2 “USB 3.0 to SATA III HARD DRIVE ADAPTER CABLE/ CONVERTER with UASP” cables connected to a USB 3.0 hub. I will install and configure SAMBA to share the drives in my home network over the Gigabit ethernet port. The drives will be synced to the cloud directly from the Rock (Encrypted or not encrypted, not sure yet) I will use a 4GB version with Debian Stretch Minimal Community Build Image by ayufan. Most of the hardware is already ready and I’m now playing and testing with the software for the last 3 months, step by step I will post the made progress. I will use this board to post my progress and hopefully to receive tips, tricks and feedback from you, the readers, I’ll try to share everything like schematics, scripts and step by step explanation how I installed or configured scripts and/or software. RE: Rock64 Webserver / NAS project - mikedhoore - 03-21-2018 First, I started building the rock64 and all its hardware in a case, I also made a PCB to connect the GPIO pins to additional hardware like a TFT screen, a fan, RGB strips, … (Since there are only 10 images allowed per post I replaced some images by the word Image. I started with making a PVC plate to support the rock64 and other pcb’s. I closed the back openings with a plexiglass plate so that I could screw the extension cord to it. After that I attached the power supply on the bottom plate of the case. With some resistors and transistors I made the RGB led strip to work, with hot glue I made a 45° profile for the RGB strip also have I soldered a cable to the stripes to connect to the self-made PCB. Image Image Build in a 2.4” LCD screen for later on. Making openings in the back plate to attach the extension cords. Image Etching and soldering my own PCB. Image Image Making the power and signal cables myself. Made a plexiglass case to coverup the 220V part. Image Schematics of the PCB Image Download link of the Eagle project : https://mikedhoore.stackstorage.com/s/flyba19r25RlVyX The final result The album to see more photos: https://ibb.co/album/mpWuLa Used hardware ThermalTake Core V1 Case (Amazon.com) PVC and Plexi plates (laying around in my hobby room) 2x 10cm RGB led strip (laying around in my hobby room) Rock64 4GB (Pine64.org) 64GB eMMC (Pine64.org) Serial console (Pine64.org) USB 2.0 male to female extension cable (laying around in my hobby room) Micro SD to eMMC converter (ameridroid.com) Heatsink 20x20x10mm (ebay.com) 50W dual power supply (ebay.com) 2.4” LCD screen (ebay.com) USB 3.0 A to 20 Pin header cable (ebay.com) HDMI extension cable (ebay.com) 2x RJ45 extension cable (ebay.com) Dual USB 2.0 extension cable (ebay.com) USB 3.0 hub (ebay.com) White Nylon spacer M2.5 (ebay.com) White Nylon screw M2.5 (ebay.com) Panel Mount Rocker Switch Fuse Holder Power Socket (ebay.com) 2x 3.5mm power jack for rock64 and usb3.0 hub (laying around in my hobby room) 2x 5.5mm power jack for USB to SATA cable (laying around in my hobby room) 2x USB 3.0 to SATA III CABLE with UASP (Pine64.org) Cables, screws, Heat shrink tubing, … (laying around in my hobby room) Custom made PCB (Made in my school) Used GPIO pins GPIO 1: RGB-strip Red (PWM) (P5+ / pin 10 / GPIO2_B7 / 79) GPIO 2: RGB-strip Green (PWM) (P5+ / pin 12 / GPIO2_C4 / 84) GPIO 3: RGB-strip Blue (PWM) (P5+ / pin 14 / GPIO2_C6 / 86) GPIO 4: FAN (PWM) (P5+ / pin 4 / GPIO2_C2 / 82) GPIO 5: FAN (IN RPM) (P5+ / pin 6 / GPIO2_C3 / 83) GPIO 6: LED Case power (OUT) (P5+ / pin 3 / GPIO2_C1 / 81) GPIO 7: LED Case HDD (OUT) (P5+ / pin 5 / GPIO2_C7 / 87) GPIO 8: Switch Case power (IN) (P5+ / pin 9 / GPIO2_C0 / 80) GPIO 9: Switch Case reset (IN) (P5+ / pin 11 / GPIO2_C5 / 85) GPIO 10: LCD led background (PWM) SPI TXD: LCD SPI RXD: LCD SPI CLK: LCD SPI CSN0: LCD SPI CSN1: LCD UART TX: serial-usb (Pi-2 / pin 8) UART RX: serial-usb (Pi-2 / pin 10) Ethernet RD+ (P5+ / pin 17 ) Ethernet RD- (P5+ / pin 18 ) Ethernet TX+ (P5+ / pin 19 ) Ethernet TX- (P5+ / pin 20 ) 5V (P5+ / pin 2) GND (P5+ / pin 7) 3.3V (P5+ / pin 1) RE: Rock64 Webserver / NAS project - mikedhoore - 03-27-2018 To get started with the rock64 I first did some "Basic" configuration 1) First of all I used etcher to burn the image on the eMMC with a µSD to eMMC converter. etcher : https://www.etcher.io Image : https://github.com/ayufan-rock64/linux-build/releases/latest (i have chosen Stretch minimal) µSD to eMMC : https://ameridroid.com/products/emmc-adapter 2) After that I connected the board to the serial console and opened a terminal with putty Howto connect : https://forum.pine64.org/showthread.php?tid=5029 PuTTY : https://www.putty.org/ 3) Once connected the first thing I did was change the host name HowTo : https://forum.pine64.org/showthread.php?tid=4868&pid=30220#pid30220 Reboot for changes to take effect 4) Then I changed the password for rock64 user and root user For rock64 user : Code: $ passwdCode: $ sudo passwd root5) To make sure I have a fixed IP address I configured following file like this File : /etc/network/interfaces.d/eth0 Code: allow-hotplug eth0Code: $ sudo systemctl disable dhcpcd.service6) At last I updated the rock64 with following command to make sure that all services that are running on the system are the latest version Code: $ sudo apt-get updateSo far for the "Basic" configuration RE: Rock64 Webserver / NAS project - tllim - 04-02-2018 PINE64 moderators and developers meet up at Brussels on first week of February annual for FOSDEM event and looking forward to meet up with you on FOSDEM 2019. Keep up on your good work and beer on me. RE: Rock64 Webserver / NAS project - mikedhoore - 04-03-2018 (04-02-2018, 09:44 PM)tllim Wrote: PINE64 moderators and developers meet up at Brussels on first week of February annual for FOSDEM event and looking forward to meet up with you on FOSDEM 2019. Keep up on your good work and beer on me. Thanks I am already looking forward to it and i will certainly be present
RE: Rock64 Webserver / NAS project - mikedhoore - 04-07-2018 After the “Basic” configuration I got started with my webserver part, 1) First, I started installing Apache Code: $ sudo apt install apache22) Once this was working I installed Maria DB to have a database if needed Code: $ sudo apt install mariadb-serverCode: $ sudo mysql_secure_installationSet root password [Y/n] Answer yes and set password Remove anonymous users? [Y/n] Answer yes Disallow root login remotely? [Y/n] Answer yes Remove test DB an access to it? [Y/n] Answer yes Reload privilege tables now? [Y/n] Answer yes You can check this is working with following commands Code: $ sudo mysql – u root -p3) After that I installed PHP with following command Code: $ sudo apt install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-gd php7.0-opcacheCode: $ sudo systemctl restart apache2Code: $ sudo rm /var/www/html/index.html4) To add some extra security I installed a firewall to block all open ports on the rock Code: $ sudo apt install ufwCode: $ sudo ufw allow 22Code: $ sudo ufw enableCode: $ sudo ufw status verboseUsed resource for 1 to 4 is https://www.cyberciti.biz/faq/how-to-install-linux-apache-mysql-php-lamp-stack-on-debian-9-stretch/ 5) To make access to the database easier I installed phpMyAdmin with following command Code: $ sudo apt install phpMyAdminWeb server to reconfigure? Chose apache2 Config DB for phpMyAdmin with dbconfig-common? Choose Yes Password of the DB admin user Give the root password from MariaDB install MySQL app password for phpMyAdmin Choose a password (this doesn’t need to be same as the root but it can) This completes the installation, then I still had to configure phpMyAdmin to Apache Code: $ sudo nano /etc/apache2/apache2.confCode: $ sudo mysql – u root -pCode: $ sudo /etc/init.d/apache2 restartUsed resource for 5 is https://pimylifeup.com/raspberry-pi-mysql-phpmyadmin/ 6) Most of my projects I write are in Java so I needed to install Java and of course a tomcat server, first of all I started installing Oracle Java on my Rock (at the moment of installing 8u162 was the latest version, u will need to check http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to see what is now the latest version and change the command accordingly ) Code: $ sudo wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-arm64-vfp-hflt.tar.gzCode: $ java -versionCode: $ sudo nano /etc/profile7) After installing Java we need a server to run Java projects, I installed tomcat 8 (at the moment of installing v8.5.28 was the latest version, you will need to check http://www-us.apache.org/dist/tomcat/ to see what is now the latest version and change the command accordingly ) I started with making a low-privilege user to run the tomcat service Code: $ sudo groupadd tomcatCode: $ sudo wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.28/bin/apache-tomcat-8.5.28.tar.gzCode: $ sudo sh /opt/tomcat/bin/startup.shCode: $ sudo nano /etc/systemd/system/tomcat.serviceCode: $ sudo systemctl daemon-reloadCode: $ sudo systemctl start tomcatCode: $ sudo nano /opt/tomcat/conf/tomcat-users.xmlCode: $ sudo nano /opt/tomcat/webapps/manager/META-INF/context.xmlBefore the changes take effected I needed to restart my tomcat server Code: $ sudo systemctl restart tomcatCode: $ sudo ufw allow 8080Used resource for 6 and 7 is https://www.itzgeek.com/how-tos/linux/debian/how-to-install-tomcat-8-5-on-debian-9-ubuntu-16-04-linux-mint-18.html 8) Because I don’t want to let my user surf to mydomain.com:8080 I wanted to link a subdomain to the tomcat server(Java) and my main domain the apache server(html and php), this is done by adding a proxy to mine .conf file in apache Code: $ sudo nano /etc/apache2/sites-available/000-default.confCode: ServerName mikedhoore.beCode: $ sudo a2enmod proxyUsed resource for 8 https://serverfault.com/questions/195611/how-do-i-redirect-subdomains-to-a-different-port-on-the-same-server So now I have a working apache server that can run HTML and PHP on my main domain and a tomcat server that can run Java on a subdomain, both can access my database and I can easy access my database in a web GUI. At last I also will implement HTTPS access, but I’m waiting for CertBot to implement wildcards in Apache. RE: Rock64 Webserver / NAS project - mikedhoore - 04-21-2018 Ones the webserver was up and running I started installing / configuring my NAS part of my Rock64 project. 1) First, I started by installing 1 HDD to the rock64 over USB 3.0 with the USB3.0 to SATA cable from the web shop here. ( https://www.pine64.org/?product=usb-3-0-to-sata-iii-hard-drive-adapter-cable-converter-with-uasp ) To confirm the drive was recognized I used following command Code: $ lsblkTo get more info about the device and the current partitions I used Code: $ sudo fdisk -l /dev/sdaCode: $ sudo fdisk /dev/sdaCode: m --> To show the full menuAfter this I still needed to format the partition and choose a filesystem I have chosen for ext4 Code: $ sudo mkfs.ext4 /dev/sda1Code: $ sudo lsblk -fs2) Before I could use the disk it still needed to be mounted, first I made a folder to mount the disk on Code: $ sudo mkdir /media/hdd0Code: $ sudo mount /dev/sda1 /media/hdd0Code: $ lsblkCode: $ sudo chown -R rock64:rock64 /media/hdd0/Used resource for 1 and 2 https://forum.pine64.org/showthread.php?tid=4925 3) Because I want to use the disk as a NAS I needed to share the folder, since I have mostely windows and android machines in my home network I used SMB First of all I installed SAMAB on the Rock64 Code: $ sudo apt-get install sambaCode: $ sudo smbpasswd -a rock64Code: $ sudo nano /etc/samba/smb.confCode: $ sudo service smbd restartCode: $ sudo ufw allow samba![]() Used resource for 3 https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/ 4) After a few days I decide to add my second disk to the rock and make a software raid, I shutdown the rock and unplugged the first disk, plugged in a usb3.0 hub and connected the previous disk and the second disk to the hub. Once rebooted I noticed my first disk was now under /dev/sdb and the last connected disk was under /dev/sda. So now I wanted to make a RAID1 but I didn’t want to lose my data on the previous disk. First of all I partitioned the newly added disk Code: $ sudo fdisk /dev/sdaCode: m --> To show the full menuCode: $ sudo apt-get install mdadmCode: $ sudo mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sda1 missingCode: $ sudo mkfs.ext4 /dev/md0Code: $ sudo mkdir /media/raidCode: $ sudo mount /dev/md0 /media/raidCode: $ lsblkCode: $ sudo chown -R rock64:rock64 /media/raid/Code: $ sudo cp -a /media/hdd0/ /media/raid/Code: $ sudo fdisk /dev/sdbCode: m --> To show the full menuCode: $ sudo mdadm /dev/md0 --add /dev/sdb1Code: $ watch cat /proc/mdstatThe only thing I needed to extra was change the /etc/samba/smb.conf file Code: $ sudo nano /etc/samba/smb.confCode: $ sudo service smbd restartUsed resource for 4 https://unix.stackexchange.com/questions/281654/convert-a-non-boot-single-hdd-to-raid-1-without-deleting-it 5) The disks I used in my rock64 came from an old Readynas 102, now I had the idea to use this readynas as a backup for my Rock. First I installed sshfs Code: $ sudo apt-get install sshfsCode: $ sudo ssh-keygen -t rsaCode: $ sudo ssh-copy-id -I ~/.ssh/id_rsa.pub root@192.168.178.32Code: $ sudo mkdir /media/backupCode: $ sudo sshfs root@192.168.178.32:/data/Backup /media/backup/Code: $ sudo df -hUsed resource for 5 https://www.cyberciti.biz/faq/how-to-mount-remote-directory-filesystems-with-sshfs-on-linux/ 6) I also wanted an off-site backup in the cloud, since my cloud service only support webdav I needed to configure it as a davfs, first of all I installed davfs2 Code: $ sudo apt-get install davfs2Code: $ sudo dpkg-reconfigure davfs2Code: $ sudo usermod -a -G davfs2 rootCode: $ sudo nano ~/.davfs2/secrets Code: $ sudo chmod 600 /etc/davfs2/secretsCode: $ sudo mkdir /media/stackCode: $ sudo mount -t davfs https://mikedhoore.stackstorage.com/remote.php/webdav/ /media/stackCode: $ sudo df -hUsed resource for 6 https://ajclarkson.co.uk/blog/auto-mount-webdav-raspberry-pi/ and https://wiki.archlinux.org/index.php/Davfs2 7) After a reboot the made mounts from raid, backup and stack disappeared so I needed to save them in /etc/fstab Code: $ sudo nano /etc/fstabCode: $ lsblkCode: $ sudo mount -aUsed resource for 7 https://www.howtogeek.com/howto/38125/htg-explains-what-is-the-linux-fstab-and-how-does-it-work/ 8) Since I only want to back up the files that are changed I used rsync to back up from my rock to my backup server and cloud so I stared by installing rsync. Code: $ sudo apt-get install rsyncCode: $ sudo crontab -eUsed resources for 8 https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/ and https://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/ After all this I now have a working NAS that I can access in my home network over SMB, it also backups on premises and off premises in the cloud. RE: Rock64 Webserver / NAS project - mikedhoore - 04-21-2018 I also written some scripts for the GPIO pins first off all I wrote a script to initialize all the pins that I have connected Code: #!/bin/shTo test all these pins I also wrote a script Code: #!/bin/bashAt last I wrote a script to power my fan in function of the temperature Code: #!/bin/bashRE: Rock64 Webserver / NAS project - tazthecat - 07-19-2018 @ mikedhoore - How stable has this setup been for you? Especially around the x2 hdd's on your USB 3.0 hub? |