Article directory
1 Introduction
As an important branch of the Linux system, the Ubuntu system not only has the lightweight, high scalability and long-term stable operation of the Linux system, but also has a friendly graphical interface like Windows, so it can be used as a good choice for familiar server systems. For the author, the biggest use of the ubuntu system is that it can revitalize the old computer at home, let the computer that has been relegated to the second line be matched with the cpolar intranet penetration software to become a private server, and build various favorites website. Today, the author will introduce to you how to use cpolar intranet penetration + Z-blog to build a private blog website.
2. Website construction
Z-blog is a well-known personal blog site. Its small size and numerous extensions make Z-blog highly playable, and it has also become the first choice for many private bloggers to build their personal blogs. Of course, the Z-blog website built on a personal computer is difficult to be accessed by public Internet visitors, but through the internal network penetration data tunnel built by cpolar, the personal computer can be transformed into a private server. My personal blog site can naturally be visited by everyone. Now, let's get started.
2.1. Web page download and installation
Since the operation of Z-blog requires multiple supporting programs, such as Apache or Nginx, PHP, SQL, etc., in order to facilitate the software management of these web pages, the author uses the pagoda panel to build the website operating environment, so as to avoid running the required software on these web pages Trouble to set up separately.
Usually, an official software will have its own official website, where we can find the software download, installation guide and other information, and Z-blog is no exception. However, the pagoda panel provides one-click deployment and installation methods for many mainstream and commonly used websites, which saves us a lot of trouble. In fact, the one-click deployment function of the pagoda panel is also carried out according to the normal website deployment steps (download the website source code, and install the website body under the website support program), and only include some simple steps in the automatic operation directory.
After visiting the official website of Z-blog, we can see that Z-blog supports multiple versions of php, and also supports a variety of database software, which means that we need to install Apache, MySQL, and PHP on the pagoda panel first (the so-called LAMP, if Nginx, MySQL, PHP is installed under Linux, it is called LNMP).
软件商店
We can also find the button on the left side of the homepage of the pagoda panel (you can enter the local address in the browser: the output port number of the pagoda panel), and click to enter the software store page. On this page, we can find commonly used website operation support programs, including Nginx, Apache, MySQL, PHP, phpMyadmin, Tomcat, Docker manager, Redis, etc. We find the required software and click "Install" on the right side of the software entry to install it on the ubuntu system.
In order to ensure the compatibility of the Z-blog website, the author chooses PHP7.2 to install. If some websites specify the PHP version, just select the corresponding PHP version to install.
After completing the installation of Apache, MySQL, and PHP, we can click 已安装
the button at the top of the software store page to view the installed software. At the same time, you can also switch the version of each software here.
Then, click 数据库
the button on the left side of the main interface of the pagoda panel to enter the database setting page. Here we set up a database for Z-blog, and the setting content is mainly the database name and password.
After the database setting is complete, we click "Software Store" on the left side of the main interface of the pagoda panel. After entering the software store, find 一键部署
the button at the top of the page, enter the website page that can be deployed with one click, select Z-blog
an item from it, and click the button on the right side of the item 一键部署
.
Then enter the basic setting window of the website, where we can specify the basic information of the website, which includes:
- Output port number - in the "domain name" field, set it in the form of "domain name to be set: port to be used";
- Root directory – This field can be changed or not, but the content of this root directory will be linked with the "domain name" field. To prevent confusion, I still change it to zblog
- Database – fill in the database information we set before;
- PHP Version – Some websites may require the use of a specific version of PHP, we can modify it in the PHP version field (provided that the corresponding version of PHP software has been installed)
After completing these settings, you can click the "Submit" button at the bottom of the window to formally create the zblog website.
After the website is created (in a split second), the pagoda panel will pop up the address of the created website, as well as the zblog background login user name and password.
2.2. Web page testing
Finally, we enter in the local browser localhost:81
(that is, the local port 81), and try to access the newly established zblog website.
But the strange thing is that the zblog website feedbacks that the database information is wrong (the database information is stored in the c_option.php file in the zb_users folder), so we follow the website prompts and click the "Website" button on the left side of the pagoda panel to open the root directory of zblog. Find the c_option.php file under the zb_users folder in the root directory.
Once you've located c_option.php
the file, double-click it to open it for editing. In the editor window of the c_option.php file, ZC_MYSQL_XXXXXXX
an entry for the format can be found. Here we can see that , ZC_MYSQL_USERNAME
, ZC_MYSQL_PASSWORD
and ZC_MYSQL_NAME
the three items are all wrong.
Therefore, we replace the existing content with the database name, user name and password of the zblog database set before, and then click the "Save" button in the upper left corner of the editing window to save the modified content in the c_option.php file.
At this time, when we visit the zblog webpage again, we can see that the zblog webpage can be displayed normally.
2.3.cpolar installation and registration
After completing the deployment of the web page, you can switch to the installation of cpolar. If you want to install cpolar on the ubuntu system, you can use a simple one-click installation script to install it. As long as you enter the following command on the ubuntu command line interface, the installation program can be executed automatically (it should be noted that some ubuntu versions may not have the curl tool installed, so it is best to execute the command to install the curl tool first) sudo aptinstall curl
.
cpolar address: https://www.cpolar.com/
Cpolar one-click installation script:
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
After the cpolar installation is complete, you can enter the command to start cpolar.
systemctl start cpolar
At this time, the ubuntu system will jump out of the authentication box for starting the service, and we can enter the password of the ubuntu system.
Of course, instead of using the systemctl level command, we can enter and cpolar version
query the version number of the local cpolar. As long as the version information can be displayed, it means that the cpolar installation is complete.
In order to ensure that cpolar can run on the ubuntu system for a long time, so as to ensure the stable existence of the data tunnel, it is best to add cpolar to the ubuntu boot-up list. As long as you enter the command on the command line interface of ubuntu to add cpolar to the self-start list.
sudo systemctl status cpolar
In order to ensure the data security of each user and create a separate data tunnel for each customer, cpolar uses user passwords and token codes for user authentication, so we need to register users before using cpolar. The registration process is very simple, just click "User Registration" in the upper right corner of the cpolar homepage, fill in the necessary information on the registration page, and the registration can be completed.
After completing the cpolar user registration, we can use each user's unique token code to activate the cpolar client. As long as you log in on the cpolar official website, you can 验证
find the user's unique token code on the page (or "connect your account" window).
Copy and paste this token code to the ubuntu command line interface, and the cpolar client will write this token code into the local cpolar.yml file (token code activation only needs to be done once), as the identification of the user data tunnel information. The specific command format is cpolar authtoken 用户唯一的token码
.
3. Local web publishing
At this point, we have installed the webpage on the local device, and also installed the cpolar intranet penetration program. Next, we can use cpolar to create a safe and efficient data tunnel for the local webpage, so that our local webpage can be accessed on the public Internet. access to.
3.1.Cpolar temporary data tunnel
In order to meet the temporary web page testing function required by some customers, cpolar can directly create a temporary data tunnel on the cpolar client (reset the public Internet address every 24 hours). 隧道管理
To create a temporary data tunnel, we directly log in to the cpolar client on the local device (input localhost:9200 in the browser address bar), and click the button under the item on the main interface of the cpolar client to enter the tunnel creation setting page 创建隧道
.
On the "Create Tunnel" page, we need to set several information, including:
隧道名称
– It can be regarded as the tunnel information annotation of the cpolar client, as long as it is convenient for us to distinguish;协议
– The website is a web program, so choose the http protocol;本地地址
– The local address is the output port number of the local website, here according to our settings, fill in 81;域名类型
– Here we can distinguish whether the data tunnel is for temporary use or for long-term existence. Since we are only conducting a temporary test first, we choose a "random domain name" (the second-level subdomain name and custom domain name are long-term stable tunnels, and public Internet addresses need to be reserved in the cpolar cloud).地区
– That is, the location of the server, we can fill in the nearest location according to the actual use;
After completing these settings, you can click at the bottom of the page 创建按钮
to establish a temporary data tunnel. After the temporary data tunnel is created, the cpolar client will automatically jump to the page 隧道管理
under the item 隧道列表
, where we can see all the local data tunnels of cpolar (whether temporary or long-term). We can also manage the data tunnel here, including opening, closing or deleting this tunnel, or click the "Edit" button to modify the information of this data tunnel.
And the temporary public Internet address we created to connect to the local website can be found 状态
under 在线隧道列表
.
Paste the public Internet address shown here into the browser address bar to access the local web page.
However, the data tunnel at this time is only a temporary data tunnel and resets every 24 hours. After the data tunnel is reset, the public Internet address generated by cpolar will change. If you plan to visit this webpage again, you need to use the newly generated address.
3.2. Cpolar stable tunnel (cloud setting)
If we want to set up a long-term stable data tunnel for the local website, we need to upgrade cpolar to the VIP version first.
After Cpolar is upgraded to the paid version, you can log in to the official website of cpolar, and find the 预留
button on the left side of the user's main page, click to enter the reserved page of data tunnel of cpolar, and generate a public Internet address (or the entrance of the data tunnel) here. . At this time, this address is not connected to the local software output port, so it can be regarded as a blank data tunnel.
On the reservation page, we can reserve data tunnels using multiple protocols, here we select 保留二级子域名
fields.
In the field of "Reserve the second-level subdomain name", several simple information settings need to be made:
地区
(The area where the server is located, just choose the nearest one)二级域名
(will eventually appear in the generated public Internet address as one of the identifiers of the network address)描述
(It can be regarded as the description of this data tunnel, which can be distinguished from other tunnels).
After completing these settings, you can click 保留
the button on the right to keep this data tunnel.
Of course, if this data tunnel is no longer intended to be used, you can click the "x" on the right to delete it easily, saving valuable tunnel quota.
3.3. Cpolar stable tunnel (local setting)
After completing the setting of the cpolar cloud and keeping the blank data tunnel, we return to the local cpolar client and connect the blank data tunnel generated by the cloud with the local test page.
Open and log in the cpolar client on the local device (you can enter localhost:9200 in the browser to access directly, or click the shortcut of the cpolar client in the start menu).
隧道管理
Click the button on the left side of the main interface of the client 隧道列表
to enter the page of the local tunnel, and then click 编辑
the button corresponding to the tunnel.
On 编辑
the page of the local tunnel (the same as the page of creating a local temporary tunnel), we only need to 域名类型
modify it to connect the public Internet address reserved by the cpolar cloud with the zblog data tunnel created by the local cpolar.
We have already reserved the data tunnel of the second-level subdomain name in the cpolar cloud, so change the previous 随机域名
selection to 二级子域名
(if the reserved domain name is a custom domain name, check the custom domain name), and Sub Domain
fill in the next column 预留的二级子域名
, here we Fill in "zblogtest".
After completing the change of "domain name type", you can click 更新
the button at the bottom of the page to connect the blank data tunnel on the cpolar cloud with the local zblog website, and generate a zblog website address that can exist stably for a long time.
4. Public network access test
At this time, when we enter 在线隧道列表
the page again, we will find that the public Internet address of the local zblog has changed. We paste the new public Internet address of the local zblog website into the browser, and then we can use the stable data tunnel to access the local zblog website.
5 Conclusion
So far, we have successfully built a private zblog website on the local ubuntu system, and penetrated the data tunnel through the intranet created by cpolar, so that Internet visitors can easily access our website. Although there were small twists and turns in the middle, it was resolved smoothly. Using the same idea, we can also build other types of websites locally, and then publish them to the public Internet through the data tunnel created by cpolar, upgrading our personal computers into private servers, bringing more to our life and work convenient.