Raspberry Pi quickly builds a web server locally and publishes public network access

Raspberry Pi quickly builds a web server locally and publishes public network access

With the development of science and technology, the electronic industry is also making continuous progress, and the electronic equipment around us is also evolving towards miniaturization and multi-function. Computers, which used to be bulky, are gradually shrinking in size. As a full-featured hardware device, Raspberry Pi has much smaller power consumption and volume than traditional desktop computers, and is not inferior to desktop computers in most functions. Therefore, it has been developed into a variety of application scenarios. As a personal web server is One of the most widely used scenarios. Today, we will give you a brief introduction on how to quickly publish web pages on the Raspberry Pi.

Due to the hardware limitations of the Raspberry Pi itself, it is difficult to run a larger Windows system smoothly, and instead use a dedicated Raspberry Pi system. Therefore, when we build web pages on the Raspberry Pi, we basically use the command line to operate . However, as long as you follow our introduction, you can easily build a web page on the Raspberry Pi (for details on building a web page on the Raspberry Pi, please refer to the series " Publishing a Raspberry Pi Web Page Using cpolar "). Just like on a computer, building a webpage on the Raspberry Pi also needs to build the environment required for the webpage to run, that is, install apache2, cpolar and other webpage operating environments and intranet penetration software.

The first is to install apache2, we can enter in the Raspberry Pi command line interface

sudo apt-get install apache2 -y
sudo service apache2 restart

img

img

After installing apache2, we enter the local address (localhost) in the Raspberry Pi browser, and we can see the apache2 instruction interface.

img

Although this interface is useless, it can prove that apache2 has been installed successfully. Then we download an open source website content and install it on the Raspberry Pi, the command line is

cd /var/www/html/
sudo rm *
sudo wget https://www.cpolar.com/static/downloads/meditation-app-master.tar.gz
sudo tar xzf meditation-app-master.tar.gz
sudo mv meditation-app-master/* .
sudo rm -rf meditation-app-master meditation-app-master.tar.gz

img

After the command is executed, we visit localhost again, and we can find that the webpage has changed to the content of the webpage we downloaded.

img

Then we install cpolar, and establish a data tunnel, command behavior

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

(Foreign users can use the short link command curl -sL https://git.io/cpolar | sudo bash) to install cpolar directly.

It should be noted that the data tunnel established by cpolar has extremely high confidentiality and must correspond to a single user one by one, so the data tunnel must be established for a registered user of cpolar.

img

After the cpolar installation is complete, we enter localhost:9200 in the Raspberry Pi browser, open the cpolar web-UI interface, enter our account name and password, enter the main interface of the cpolar program, and enter the "Tunnel Management" item On the "Create Tunnel" page, establish a corresponding data tunnel for the local web page.

img

img

Finally, we enter the "Online Tunnel List" page under the "Status" item on the left side of the cpolar main interface, find the public network address generated by cpolar for the local web page, and try to access it. If the address can correctly point to the webpage on the local Raspberry Pi, it means that the webpage on the intranet Raspberry Pi has been successfully published on the public Internet, and everyone can also access the content we published from the public Internet through this address .

img

At this point in the operation, we have successfully published the webpage on the Raspberry Pi to the public Internet through the data tunnel established by cpolar through a few simple steps, making it a member of the colorful network world (if you want To get the detailed content of cpolar publishing simple web pages on Raspberry Pi, you can read the series of articles " Using cpolar to publish Raspberry Pi web pages "). Publishing web pages on Raspberry Pi is only one aspect of cpolar's powerful functions. If you have any questions about the use of cpolar, please contact us, and we will provide you with assistance within our capabilities. Of course, you are also welcome to join the VIP official group of cpolar to explore the unlimited potential of cpolar together.

Reprinted from the cpolar pole cloud article: Raspberry Pi quickly builds a web server locally and publishes public network access

Guess you like

Origin blog.csdn.net/2301_78420308/article/details/131958903