首页 智能家居

告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器

分类:智能家居
字数: (8477)
阅读: (9348)
内容摘要:告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器,

在使用 Markdown 进行写作时,我们常常需要在不同设备之间同步文件,或者需要一个随时可用的在线编辑器。Dillinger 是一个优秀的开源 Markdown 编辑器,本文将介绍如何在华为 openEuler 服务器上部署 Dillinger,打造属于你自己的在线 Markdown 编辑利器。我们将深入探讨安装过程,解决潜在问题,并提供一些实用的配置建议,让你拥有一个高效、便捷的写作环境。

准备工作

首先,确保你拥有一台运行 openEuler 的服务器,并具备 root 权限。 推荐使用华为云服务器 ECS,openEuler 作为其支持的操作系统,可以获得更好的兼容性和性能。

其次,你需要安装以下软件:

  • Node.js 和 npm:Dillinger 基于 Node.js 构建,需要 Node.js 环境才能运行。
  • Git:用于从 GitHub 克隆 Dillinger 仓库。

安装 Node.js 和 npm

openEuler 默认的 yum 源可能不是最新的 Node.js 版本,建议使用 nvm (Node Version Manager) 安装。

告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

# 激活 nvm
. ~/.nvm/nvm.sh

# 安装 Node.js (推荐安装 LTS 版本)
nvm install --lts

# 检查 Node.js 和 npm 版本
node -v
npm -v

安装 Git

yum install git -y

git --version

部署 Dillinger

克隆 Dillinger 仓库

git clone https://github.com/joemccann/dillinger.git
cd dillinger

安装依赖

npm install

如果 npm 安装速度过慢,可以使用国内镜像,例如淘宝镜像:

npm config set registry https://registry.npmmirror.com

配置 Dillinger

Dillinger 默认使用 3000 端口,你可以修改 server.js 文件来更改端口。

// server.js
var port = process.env.PORT || 3000; // 修改为你想使用的端口

运行 Dillinger

npm start

现在,你应该可以通过 http://your_server_ip:3000 访问 Dillinger 了。

告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器

使用 Nginx 反向代理

为了更好的安全性和性能,建议使用 Nginx 作为反向代理。 这样可以将 Dillinger 绑定到 80 或 443 端口,并配置 SSL 证书。

安装 Nginx

yum install nginx -y

systemctl start nginx
systemctl enable nginx

配置 Nginx

修改 Nginx 配置文件 /etc/nginx/nginx.conf 或在 /etc/nginx/conf.d/ 目录下创建一个新的配置文件,例如 dillinger.conf

# dillinger.conf
server {
    listen 80; # 监听 80 端口
    server_name your_domain.com; # 修改为你的域名或服务器 IP

    location / {
        proxy_pass http://localhost:3000; # 反向代理到 Dillinger
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

配置完成后,重启 Nginx:

告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器
systemctl restart nginx

配置 SSL (可选)

如果需要使用 HTTPS,可以使用 Let's Encrypt 免费 SSL 证书。可以使用 Certbot 工具自动配置。

yum install certbot python3-certbot-nginx -y

certbot --nginx -d your_domain.com # 替换为你的域名

Certbot 会自动修改 Nginx 配置文件,并配置 SSL 证书。

开机自启动

为了确保 Dillinger 在服务器重启后自动启动,可以使用 systemd 管理。

告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器

创建 systemd 服务文件

/etc/systemd/system/ 目录下创建一个新的服务文件,例如 dillinger.service

# dillinger.service
[Unit]
Description=Dillinger Markdown Editor
After=network.target

[Service]
User=root # 使用 root 用户运行
WorkingDirectory=/root/dillinger # Dillinger 目录
ExecStart=/usr/bin/npm start # 启动命令
Restart=on-failure # 失败后重启

[Install]
WantedBy=multi-user.target

启用服务

systemctl enable dillinger.service
systemctl start dillinger.service
systemctl status dillinger.service # 检查服务状态

常见问题与解决方案

  • npm 安装依赖失败:检查 Node.js 和 npm 版本是否正确,尝试使用国内镜像加速,或者使用 npm cache clean --force 清理缓存后重试。
  • Dillinger 无法访问:检查防火墙设置,确保 3000 端口或 Nginx 监听的端口已开放。 可以使用 firewall-cmd 命令配置防火墙规则。
  • Nginx 反向代理配置错误:检查 Nginx 配置文件是否正确,特别是 proxy_pass 指令的目标地址是否正确。

总结

通过以上步骤,你就可以在 openEuler 上成功部署 Dillinger,拥有一个属于你自己的在线 Markdown 编辑器。你可以随时随地访问你的编辑器,享受便捷的写作体验。同时,结合 Nginx 反向代理和 SSL 证书,可以提升 Dillinger 的安全性和性能。在服务器上部署应用时,务必关注服务器的资源占用情况,例如 CPU 使用率,内存占用等。可以使用 top 命令或者 htop 命令进行监控。如果服务器资源不足,可以考虑升级服务器配置,或者优化应用代码。

告别本地IDE:在openEuler上搭建Dillinger在线Markdown编辑器

转载请注明出处: 键盘上的咸鱼

本文的链接地址: http://m.acea2.store/blog/699932.SHTML

本文最后 发布于2026-04-20 14:03:55,已经过了7天没有更新,若内容或图片 失效,请留言反馈

()
您可能对以下文章感兴趣
评论
  • 月亮不营业 1 天前
    按照教程一步步操作,成功部署了!感谢分享!
  • 芝麻糊 1 天前
    写的很详细,赞一个! openEuler 近几年发展挺快的,生态越来越完善了。
  • i人日记 9 小时前
    写的很详细,赞一个! openEuler 近几年发展挺快的,生态越来越完善了。
  • 煎饼果子 6 天前
    请问一下,如果不使用 Nginx 反向代理,直接暴露 3000 端口会有什么安全风险吗?