Article directory
Preface
Hexo is a fast, simple and efficient blogging framework written in Nodejs. Hexo uses Markdown to parse articles and generate static web pages with beautiful themes in a few seconds.
The following describes how to install a personal hexo blog in Termux and combine it with the cpolar tool to achieve remote access.
1. Install Hexo
Hexo is written in Nodejs, so if you want to install it, install node.js first. Termux is also encapsulated. You can install it with one line of commands:
pkg install nodejs
After installation, use the npm command to install hexo:
npm install hexo-cli -g
After the installation is complete, check the version information to verify whether the installation was successful:
hexo -v
Manually create a hexo directory:
mkdir hexo
Enter directory
cd hexo
Initialize the Hexo environment
hexo init
After initialization, static files are generated:
hexo g
Start hexo
hexo s
After starting, we can see the accessed address and port number
We open the browser and enter the access link above to see hexo
The above startup method is to start hexo in the foreground interface, which is not very convenient for us to do other operations, so we change to background startup, first use the Ctrl+C
key to stop hexo,
Then we use nohup to start in the background. After starting, we can press the PID:
nohup hexo s &
The way to close is also very simple, use the kill command:
kill -9 PID
Above we have installed the hexo blog, now we will install cpolar
2.Install cpolar
Create a foldersources.list.d
:
mkdir -p $PREFIX/etc/apt/sources.list.d
Add cpolar to download source files
echo "deb [trusted=yes] http://termux.cpolar.com termux extras" >> $PREFIX/etc/apt/sources.list.d/cpolar.list
Update repository
pkg update
Install cpolar
pkg install cpolar
Install termux service, note: After the installation is completed, remember to close and restart termux for it to take effect!!
pkg install termux-services
After restarting termux, then start cpolar
sv up cpolar
Set up auto-start at power on
sv-enable cpolar
This is to stop the cpolar service
sv down cpolar
cpolar.yml main configuration file path location
$PREFIX/etc/cpolar/cpolar.yml
Then enterhttp://localhost:9200
in the mobile browser to see the cpolar management interface, usecpolar official website You can log in with your registered account
3.Remote access
Open the cpolar management interface on the mobile browser. We click Tunnel Management - Create Tunnel on the left dashboard. Above we see through local access that the port number is4000
, so we need to To create an http tunnel pointing to port 4000:
- Tunnel name: Customizable, be careful not to repeat it
- Protocol: http
- Local address: 4000
- Domain name type: Choose a random domain name
- Region: Select China VIP
Click创建
After the creation is successful, open the online tunnel list and you can see the address for public network access. There are two access methods, one is http and the other is https.
Then we use one of the http methods to access it in the browser, and we can see our Hexo blog interface, so that the remote access is configured.
4. Fixed public network address
The above creation is a free random address that changes within 24 hours. In order to facilitate long-term and stable connections, we can fix the access address, which is called a fixed second-level subdomain name in cpolar. Of course, you can also configure and use your own domain name for access.
You need to upgrade to the basic package or above to support the configuration of second-level subdomain names.
Log incpolar official website backend, click 预留
on the left dashboard, find < a i=4>, reserve a second-level subdomain name for the http tunnel. 保留二级子域名
- Region: Select server region
- Name: Fill in the second-level subdomain name you want to reserve (can be customized)
- Description: Notes, which can be customized
This example reserves a second-level subdomain namedhexoblog
. After the subdomain name is successfully reserved, we copy the subdomain name and then configure it into the tunnel.
Log in to the cpolar web ui management interface, click on the left dashboard 隧道管理
——隧道列表
, find the tunnel that needs to be configured with a second-level subdomain name, and click Right编辑
Modify the tunnel information and configure the second-level subdomain name into the tunnel:
- Domain Type: Select instead
二级子域名
- Sub Domain: Fill in the second-level subdomain name we just reserved (in this case
hexoblog
)
After modification is completed, click更新
After the tunnel is updated successfully, click 状态
——在线隧道列表
on the left dashboard. You can see that the public network address of the tunnel has been updated to 2 level subdomain name.
Then we use one of the http methods to access the browser, and we can see our Hexo blog interface. In this way, a fixed remote access to the hexo blog is configured [cpolar.cn has been filed, so no filing is required].
We only need to keep the tunnel online, and public network users can access the blog website on the mobile phone termux through this public network address.