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 sources.list.d
folder:
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 the termux service. Note: After the installation is complete, 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 we enter it in the mobile browser http://localhost:9200
to see the cpolar management interface. You can log in using the account registered on the cpolar official website.
3.Remote access
Open the cpolar management interface in the mobile browser. We click Tunnel Management - Create Tunnel on the left dashboard. Above we saw the port number through local access 4000
, so we need 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 in to the cpolar official website backend , click on the dashboard on the left 预留
, find it 保留二级子域名
, and 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 hexoblog
second-level subdomain named . 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 dashboard on the left 隧道列表
, find the tunnel where you need to configure the second-level subdomain name, and click on the 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 example
hexoblog
)
After modification is completed, click更新
状态
After the tunnel is successfully updated, click - on the dashboard on the left 在线隧道列表
. You can see that the public network address of the tunnel has been updated to a second-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.
Reprinted from cpolar pole cloud article: Can a personal blog be built on a mobile phone? Build your own blog website with Android Termux+Hexo