A lot of people want to try to build their own station to play (for example, blog, self-built network disk, remote download, etc.), but there is no public IP broadband at home, deliberately buy a server appears wasteful. So is there a low cost, high playability, and long-term stability of the program?

In fact, the free Intranet penetration tool (such as network cloud wear) + raspberry PI, you can use the home wide bring to build and run all kinds of fun website procedures, run some of the self-use network service is more suitable. Raspberry PI is cheap, low-power and powerful; The Internet Cloud penetrates your Intranet for free, allowing raspberry PI without a public IP to access the Internet directly…

Since most common broadband networks, such as China Unicom, do not provide public IP addresses, there is no direct access to your home Intranet computer, raspberry PI, NAS or other network devices over the Internet. Therefore, if we want to set up a website at home or company at a low cost, we need to use free Intranet penetration tools such as “network cloud penetration” to quickly enable Intranet devices to be accessed by the external network.

Net cloud can apply for free “Intranet tunnel penetration”, through it can let all people directly from the Internet to access your raspberry PI built in the website, also can achieve remote SSH maintenance management. This way, all we need is a raspberry PI or a spare PC/NAS (tutorials here), and we can have our own “cost-effective web server”.

Preparation before construction of station

Raspberry Pi is a low cost micro computer with small size and excellent performance. Running Linux system, it has rich and stable resources and low power consumption. It is suitable for long-term operation, especially for our “website building server”.

Running a few blogs, PHP programs, or static websites is more than enough with the Raspberry PI 4 configuration. After all, Tencent cloud, Ali cloud those cheap VPS also 1 core 1G, performance is not much stronger, but the annual price is not cheap. Of course, if you have a spare PC or laptop, you can also install Debian, CentOS, Ubuntu and other systems.

As for the choice of Intranet penetration tool, “network cloud penetration” has been introduced before. Its speed is relatively stable. There are both free tunnels that can be used at zero cost, and there are also paid schemes suitable for advanced users with certain requirements. The deployment method is also simple and is a good tool. Plus network cloud wear can bind domain name, do not need to record, others visit, and the real cloud server is basically no difference.

Raspberry PI Intranet penetration + site building tutorial:

The official Raspberry Pi OS is a Debian modified distribution that works just like Ubuntu, Debian, and other Linux machines. We can refer to Linux on this learning, Bird brother Linux private dishes and other tutorials to learn.

There are plenty of “raspberry PI website tutorials” on the Internet, and any search will turn up quite a few. However, depending on the WEB application, the components that need to be installed are different (for example, some are PHP, some are Python or Node.js). Please refer to the specific application deployment instructions. This article mainly introduces the most common LNMP environment installation (Linux + Nginx + MySQL + PHP) as a demonstration to set up the site, can run the most common WordPress, and will also explain in detail how to set up the steps of “Intranet penetration”.

Install NGINX and PHP 7.3:

Let’s start by SSH to raspberry PI on the LAN, and then let’s start with the most common “install Nginx + PHP” WEB server software as an example.

NGINX sudo apt-get install NGINX sudo apt-get install php7.3- FPM php7.3-cli Run the following command to restart the NGINX serviceCopy the code

If the installation is successful, visit http://raspberry PI LAN IP in the browser to access the Nginx test page, as shown in the following figure. If yes, the WEB server provides services properly. By default, the root directory for Nginx is /var/www/html.

Let Nginx support running PHP

Sudo VIM /etc/nginx/sites-available/defaultCopy the code

Contents of the original configuration file:

location / {
	# First attempt to serve request as file, then
	# as directory, then fall back to displaying a 404.
	try_files $uri $uri/ =404;
}
Copy the code

Replace with:

location / { index index.html index.htm index.php; } location ~\.php${fastcgi_pass Unix :/run/ PHP /php7.3-fpm.sock; # fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }Copy the code

Restart the NGINX service for PHP to take effect:

Sudo service NGINX restartCopy the code

Install MYSQL (MariaDB) database

MariaDB is an open source copy of MYSQL acquired by Oracle. It is completely free and basically compatible with all MYSQL programs.

Sudo apt-get install mariadb-server-10.0Copy the code

Change the password of MYSQL database:

Mysql > execute mysqlCopy the code

Enter the following mysql commands to change the password of user root:

use mysql; update user set plugin='mysql_native_password' where user='root'; UPDATE user SET password= password (' you want to SET password ') WHERE user='root'; flush privileges; exit; Service MYSQL restartCopy the code

The LNMP environment (Nginx + MariaDB + PHP) is now installed! With LNMP, you can upload PHP applications such as WordPress or various PHP applications to raspberry PI.

Configuring Intranet penetration for Raspberry PI tutorial

If you have your website set up, then the next step is to configure Intranet Penetration to make your raspberry PI accessible to the Internet.

1. Obtain the free Intranet tunnel and configure the tunnel

Go to ** “net cloud official website” ** register an account → get a free tunnel, then jump to the console click tunnel management, configure tunnel information; Set the penetration protocol to Http(s). The internal port is the port number of the nginx you installed. The default is 80. This port number is changed in the configuration file.

2. Get the tunnel “token”

After confirming, the console will generate a “token”, which is equivalent to the communication password when the Intranet penetrates, and you can copy it down and save it temporarily.

3. Install the cloud penetrating client

It was previously introduced that netcloud can be installed on Windows, Linux, Mac and even CdNAS, as well as raspberry PI. The Raspberry PI uses an ARM processor, so download the Linux ARM version. If you are using a PC, then it is time to switch to the x64 client of the corresponding architecture.

Execute on raspberry PI:

# use wget command to download network cloud wear client wget - O/home/PI/http://xiaomy.net/download/linux/wyc_linux_arm # set executable permissions sudo chmod a + RWX /home/ PI/wyc_linux_arm-token XXXX /home/ PI/wyc_linux_arm-token XXXXCopy the code

If the token is correct, the netcloud client will log in and connect, and output the following message after success:

Then you can get the public network url, you can go to this url in the browser, directly open the raspberry PI configuration of the default site.

4, Raspberry PI set the network cloud through the client boot

If you want the raspberry PI to restart and automatically enable netcloud Penetration again, you’ll also need to configure the application to boot itself. We’ll start by adding the startup code to the rc.local file:

Sudo vim /etc/rc.localCopy the code

Locate the line “exit 0” in the rc.local file and add the following command code before it:

Nohup /home/pi/wyC_linux_arm-token = your token & # this line must be preceded by exit 0. Be sure not to omit the Spaces and ampersands after "token"Copy the code

When configured this way, your Intranet penetration will automatically start whenever the Raspberry PI restarts. And the sites deployed on raspberry PI can be accessed directly from the Internet.

Configure Intranet penetration to implement SSH remote connection to Raspberry PI

In addition to the website being accessible, if you need to remotely manage raspberry PI over SSH from the Internet (such as updating, installing programs, executing Linux commands, maintaining websites, etc.), you can also add an Intranet tunnel to SSH.

Similarly, open a tunnel first, the operation method is the same as before, but this time configure the penetration protocol to be changed to TCP, the internal port is the raspberry PI SSHD port, the default is 22, the port number can be changed through the configuration file, keep the same.

After confirmation, the following information is generated to record the extranet port, domain name and token:

As before, use this command on raspberry PI to start the netcloud piercing client. Using the password you just recorded, this time an extranet address with a port is generated.

/home/pi/wyC_linux_ARM-token Specifies your SSH tunnel tokenCopy the code

The command output shows whether the nCLOUD client is successfully connected. If there are no problems, then modify the rc.local file as follows, to enable the boot of both tunnels.

# SSH through: nohup /home/pi/wyC_linux_ARM-token = your website tunnel token & # SSH through: Nohup /home/pi/wyC_linux_arm-token = your SSH tunnel token & # Note that it must precede exit 0Copy the code

Then, from another computer on the Internet, use Putty or any terminal application to connect to raspberry PI on your Intranet by using the following command:

SSH -p External port pi@ domain nameCopy the code

In this way, through the two tunnels opened by the network cloud, the website can be accessed from the external network and the RASPberry PI can be remotely managed by SSH. In other words, you can now access your raspberry PI directly from anywhere you go online.

Conclusion:

Whether you’re just going to build a website for fun, learn Linux, or build a really useful personal web service, you can do it “at a low cost” with raspberry PI/Idle PC + Netcloud Tunnel!

Using Intranet penetration and home ordinary broadband to build their own server, playability and flexibility are very high, long-term operation is actually very stable, can solve the problems of many scenarios. At the very least, it’s useful for most people to have a WordPress blog or private disk, so if you’re interested, try it out.