Raspberry Pi build using a remote Web server

Description: Based on Raspberry Pi 3B create personal Web server for remote full tutorial is mainly a collection of individual post content, not original but proven to ensure its effective date on the system environment.

System Configuration: Raspberry Pi 3B + Raspbian + MySQL5.7 + Tomcat 9 + Nginx + public IP.

Tools: Win32DiskImager, FileZilla (FTP client), Navicat for MySQL, VNC Viewer, etc.


I. Introduction Raspberry Pi

Raspberry Pi Raspberry Pi Foundation is to learn computer programming education designed a miniature computer, can carry a variety of Linux operating system and Windows IoT. As ARM-based Raspberry Pi micro-computer motherboards, with a complete peripheral interfaces, in addition, there is a wealth of programmable GPIO pins, powerful, easy to play, easy to operate.

Second, the installation Raspbian

Search Raspbian enter the official website Download page:

Download Raspbian Buster with desktop and unpack IMG file system image:

Open Win32DiskImager select IMG file and select SD card device, click the Write:

Written after the completion of SD card into the Raspberry Pi, the display is connected, wait for the system to start.

Third, the system configuration chapter

After the system is turned into the desktop, completing some preferences, the following settings before you are prompted to restart:

Enable SSH and VNC (remote desktop):

You can restart the raspberry pie.

 

If there is no display provides operation, the Raspberry Pi is connected to the router with a network cable, open the Windows command prompt or use Xshell such as SSH client, enter ssh pi @ Raspberry Pi IP (landing router can see):

ssh pi@192.168.43.132

You can also enable VNC using the following method:

Input sudo raspi-config

Keyboard keys to move the highlight up and down the transport Interfacing Options:

Select P3 VNC Enable Enable function VNC

Restart raspberry pie.

VNC Viewer is installed on the computer, in the text box enter the Raspberry Pi IP:

Enter your user name and password Enter:

 

Successful connection:

FTP file transfer

Open Filezilla New Connection, select SFTP protocol, enter a user name and password:

Successful connection:

Fourth, the software installation chapter

1. apt source configuration

Replace the apt and apt-get's source repository

sudo nano /etc/apt/sources.list

Delete the existing content, then copy and paste:

deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main non-free contrib 
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ stretch main non-free contrib

Keyboard Ctrl + X, Y, Enter

 

Replace the Raspberry Pi Foundation maintenance software source:

sudo nano /etc/apt/sources.list.d/raspi.list

All trekking commented first #, then copy and paste

deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui

deb-src http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui

Ctrl + X,Y,Enter

2. the Java environment

Installation is simple: sudo apt install openjdk-8-jdk

 

OCD installation: enter oracle official website to download (seemingly still registered)

Network disk share the link: https: //pan.baidu.com/s/1Rzg0xOMXVpZbcq889jMyTQ
extraction code: 1jd0

Select the appropriate version:

Use Filezilla to download the file onto the specified directory:

 

#-Extracting file
 tar .-Zxf the JDK-8u221-Linux-ARM32-VFP-hflt tar .gz 
# Move the file to opt directory (personal habits) 
sudo  mv . Jdk1 8 .0_221 / / opt / 
# environment variable configuration: 
sudo Nano / etc / Profile 
# add at the end of the document the following information 
JAVA_HOME = / opt / jdk1. 8 .0_221 
Export the PATH = $ JAVA_HOME / bin: $ the PATH 
Export the CLASSPATH =:. $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / Tools .jar

Ctrl + X,Y,Enter

source / etc / profile and then enter the following information java -version see installation was successful:

 

3. Tomcat

Simple installation: sudo apt install tomcat8 -y

Open the way: tomcat start

 

OCD installation: Tomcat into the latest version of the official website to download

 

# Same with FTP spread raspberry pie, unpack:
 tar zxf the Apache-tomcat- 9.0 . 22 . Tar .gz 
# opt to move to the directory: 
sudo  mv the Apache-tomcat- 9.0 . 22 / opt / 
# change permissions so that access without limitation: 
the sudo  the chmod -R & lt 777 / opt / Apache-tomcat- 9.0 . 22 is / 
# open Tomcat service: 
the bash / opt / Apache-tomcat- 9.0 . 22 is . / bin / Startup SH

In the browser, type http: // Raspberry Pi IP: 8080 can see the Tomcat service is turned on.

4. MySQL

4.1 Installing MySQL:

Installation is simple: sudo apt install mysql-server -y

It may not succeed, depending on the error in the following figure:

 

Ultimate installation: Go to the debian package mysql mysql site and the entire package on which it depends to download and install one by one: https://packages.debian.org/sid/mysql-server-5.7 ,

 

Download total of nine packages:

I can download pack good:

Link: https: //pan.baidu.com/s/1ZMBWovALd-SZZMvfmCjyRw
extraction code: 72h5

Include a download method wherein package:

Select the appropriate architecture, Raspbian based armhf

Select to start the download mirror sites, of course, China is Asia's fastest:

 

Use dpkg installation package management command, enter the following command sequence:

sudo dpkg -i libaio1_0.3.112-3_armhf.deb
sudo dpkg -i libevent-core-2.1-6_2.1.8-stable-4_armhf.deb
sudo dpkg -i libevent-extra-2.1-6_2.1.8-stable-4_armhf.deb
sudo dpkg -i libmecab2_0.996-6_armhf.deb
sudo dpkg -i mysql-client-core-5.7_5.7.26-1_armhf.deb
sudo dpkg -i mysql-common_5.8+1.0.5_all.deb
sudo dpkg -i mysql-client-5.7_5.7.26-1_armhf.deb
sudo dpkg -i mysql-server-core-5.7_5.7.26-1_armhf.deb
sudo dpkg -i mysql-server-5.7_5.7.26-1_armhf.deb

Sudo mysql enter the following information after all pack installation is complete, the installation was successful:

Configure MySQL 4.2

After installing the latest MySQL5.7 not prompted to change the password, then the password is unknown, reset in the following ways:

1. Open the MySQL configuration file:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

As shown in FIG added:

skip-grant-tables

And comments:

bind-address = 127.0.0.1 (open remote connection)

Ctrl + X,Y,Enter

2. Enter mysql -u root -p do not lose the password directly enter, enter in MySQL:

use mysql;
update user set authentication_string=password("123456") where user="root";

Password has been changed, enter

select user,plugin from user;

如果信息与红框一样则依旧无法登陆,再进行如下步骤:

update user set authentication_string=password("123456"),plugin='mysql_native_password' where user='root';
grant all privileges on *.* to root@`%` identified by '123456';
flush privileges;

Ctrl + D 退出

 

重启mysql服务:

sudo service mysql restart

电脑上打开Navicat for MySQL,进行远程连接测试:

5. Nginx

Installation is as follows:

sudo apt install nginx –y

Nginx reverse proxy using Tomcat.

Nginx proxy using multiple servers to achieve load balancing.

Engage in a long time has been a problem, figure out even more, but a Tomcat with a reverse proxy does not make sense.

V. Network Configuration chapter

(Transparent transmission network, anytime, anywhere access, real remote server)

No school, not take the router, and then configure the school more.

Six other

1.vim installation error:

 

Solution:

sudo apt autoremove vim-common

sudo apt install vim

2.JavaWeb project deployment

Right Web project in Eclipse, a desktop computer to export the war package

 

Upload via FTP to the Raspberry Pi Tomcat web application directory, Tomcat will be running automatically extract:

Login Browser Test:

 

3. have time to write how to carry Windows IoT established home environment monitoring system, and transmit the data to the cloud .

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159808.htm