Tutorial: Run TriliumNext Server in Termux on Android #827
Replies: 3 comments
-
Just awesome. Thank you |
Beta Was this translation helpful? Give feedback.
-
手机搭建trilium服务器本人对下面工具,软件只能简单使用,对代码不了解,下面所有的内容出现错误使用AI deepseek解决,很多地方可能出现问题,欢迎来优化,手机使用vivo Y33s,下面更多是对Nriver 公司的内容补充,大佬就没必要看了,直接看原文章,适合小白 在Android设备上通过Termux部署TriliumNext服务端准备工作1. 安装Termux推荐从以下渠道获取: 2. 配置PRoot环境pkg update && pkg upgrade
pkg install proot-distro
3. 安装Linux发行版建议选择Manjaro(兼容性最佳): proot-distro install manjaro
结果
环境配置4. 进入Linux子系统Manjaroproot-distro login manjaro
5. 在Manjaro即[root@localhost ~]#下安装基础工具pacman -Syu # 更新系统
pacman -S nodejs npm base-devel curl git
6. 配置Node版本管理此处按照原文第六步curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash,国内会出现下面情况
然后又会出现下面情况
TriliumNext部署在[root@localhost ~]#下进行7. 获取源码git clone https://github.com/TriliumNext/Notes trilium
cd trilium 可能出现错误:fatal: unable to access 'https://github.com/TriliumNext/Notes/': Failed to connect to github.com port 443 after 129814 ms: Couldn't connect to server 此错误表示git链接出现错误,国内打不开,更换链接如下面的链接
termux如何删除文件(本人在这里出现了错误需要删除下载,重新下载)
8. 安装项目依赖npm install -g nodemon cross-env # 全局工具
npm install # 项目依赖
npm run switch-server # 切换服务端模式 9. 启动服务TRILIUM_ENV=dev nodemon src/main.ts 出现下面错误缺少tsx,解决方法,下载pnpm,安装tsx
解决方法
注意以上步骤都完成了,运行服务器(9. 启动服务)会出现下面程序崩溃的情况 优先使用 依赖安装失败处理(本文文末或原文章文末)
访问与管理10. 访问服务本机可能绘=会访问失败只出现登录页面,但是没有内容,可以切换设备查看ip,端口8080进入
11. 创建快捷启动脚本新建 #!/bin/bash
source ~/.nvm/nvm.sh
nvm use v20.17.0
cd /root/trilium
TRILIUM_ENV=dev nodemon src/main.ts
设置可执行权限: chmod +x /root/run-trilium.sh
快速启动命令: proot-distro login manjaro -- /root/run-trilium.sh
常见问题处理网络问题解决方案pacman -S proxychains
vim /etc/proxychains.conf # 配置代理地址
proxychains npm install # 通过代理执行
依赖安装失败处理rm -rf node_modules ~/.npm/_cacache # 清除缓存
npm cache clean --force
性能优化建议
注意事项
通过这个优化版教程,用户可以在20分钟内完成全套部署流程。实际测试在骁龙8 Gen2设备上,服务启动时间约15秒,笔记操作响应延迟小于300ms。 |
Beta Was this translation helpful? Give feedback.
-
Hi, it’s Nate again! :)
Exactly one year ago, I wrote a tutorial on how to run the original Trilium on Android. You can check it out here. Today, I'm back with a new guide for TriliumNext. Enjoy!
If you're looking to run TriliumNext on an arm64 pc, you can skip ahead and start directly from Step 5.
Tutorial: Run TriliumNext Server in Termux on Android
1. Install Termux
Download and install Termux from the official website.
2. Install PRoot Distro
Open Termux and install PRoot Distro, a tool for managing Linux distributions.
PRoot isn’t a virtual machine—learn more about it here.
Run the following command:
3. Install a Base System
I recommend using Manjaro. You can list available distributions with
proot-distro list
. To install Manjaro:4. Log in to Manjaro
Log into the newly installed Manjaro distribution:
5. Install Node.js
By default, Termux installs the latest version of Node.js, but it's generally better to use a specific, tested version for stability and compatibility. We’ll use
nvm
(Node Version Manager) to install a fixed version.First, install the necessary packages:
Then, install
nvm
:Install Node.js, here I use
v20.17.0
:6. Get TriliumNext Source Code
Unlike the original Trilium, TriliumNext cannot be installed via a release file and
npm install
. If you try this, you'll encounter an error, which is explained in the discussion here. Instead, you need to clone the source code directly:git clone https://github.com/TriliumNext/Notes trilium cd trilium
7. Install Global Packages
Install the necessary global packages:
8. Install Dependencies
This step can be tricky. You might encounter errors, so be prepared to retry the command or use a proxy. Run the following:
9. Start TriliumNext Server
Launch the TriliumNext server with the following command:
10. Access TriliumNext
http://127.0.0.1:8080
http://your_phone_ip:8080
11. Quick Startup with a Script
To start TriliumNext quickly, create a
.sh
script.Log into Manjaro:
Create the script:
Add the following content:
Save and exit the editor, then make the script executable:
chmod +x /root/run-trilium.sh exit
Now, to start Trilium quickly, run:
Additional Notes
Using a Proxy
If you face internet connectivity issues (e.g., during
curl
,npm install
, orgit clone
), you can use a proxy withproxychains
. Here’s how:Install
proxychains
:Modify the proxy settings:
vim /etc/proxychains.conf # Example proxy: http 127.0.0.1 1080
Use
proxychains
to run commands:Clearing Cache
If
npm install
keeps failing, try clearing the npm cache and node_modules:rm -rf node_modules rm -rf ~/.npm/_cacache
Why is it Slow?
If you find TriliumNext is running slowly, try these solutions:
Beta Was this translation helpful? Give feedback.
All reactions