# Avatar 上传问题 (Ubuntu)

**URL:** <https://meta.discourse.org/t/avatar-upload-issue-ubuntu/394901>\
**Category:** Support\
**Tags:** dev-install\
**Created:** [2026年二月1日 18:18 UTC](https://meta.discourse.org/t/avatar-upload-issue-ubuntu/394901 "2026-02-01T18:18:34Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![tom1984](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tom1984/32/528342_2.png) [@tom1984](https://meta.discourse.org/u/tom1984)\
**Post date:** [2026年二月2日 22:01 UTC](https://meta.discourse.org/t/avatar-upload-issue-ubuntu/394901/10 "2026-02-02T22:01:18Z")

</div>

好的……

第一个问题——头像路径是 IP 地址 127.0.0.1，而所有其他 URL 都是 localhost——这会有区别吗？我还是修改了它，方法是进入 rails c（因为似乎命令行启动 discourse 时没有接收到参数（FORCE\_HOST=localhost 等），它们在 rails 中是空白的）。

```ruby
rails c
SiteSetting.force_hostname = "localhost"
SiteSetting.port = 4200
exit

```

然后在我重启站点后，头像路径是 localhost 而不是 IP 地址。但是头像仍然无法工作。

在进行头像导入后，进一步检查日志：

```bash
tail -n 200 log/development.log

```

显示：

```bash
convert: no decode delegate for this image format jpeg:/home/bob/discourse/public/uploads/default/original/1X/92bb0d46e6a4b8a1333505b9d2da59a5ed1721ec.jpeg[0]' @ error/constitute.c/ReadImage/752.\nconvert: no images defined jpeg:/tmp/discourse-thumbnail20260202-4096-qjyo93.jpeg' @ error/deprecate.c/ConvertImageCommand/3368.\n"

```

经过一番挖掘，我发现这是因为我安装了 ImageMagick 但没有先安装 jpeg 委托（delegates）。卸载了 ImageMagick，安装了 jpeg 委托（以及其他）：

```bash
sudo apt install -y libpng-dev libtiff-dev libwebp-dev libheif-dev liblcms2-dev zlib1g-dev libjpeg-turbo8 libjpeg-turbo8-dev

```

然后从源代码重新安装了 ImageMagick：

```bash
./configure \
  --prefix=/usr/local \
  --with-modules \
  --disable-static \
  --with-quantum-depth=16 \
  --with-jpeg=yes \
  --with-png=yes \
  --with-tiff=yes \
  --with-webp=yes \
  --with-heic=yes \
  --with-lcms=yes

make -j"$(nproc)"
sudo make install
sudo ldconfig

```

重启 discourse 服务器后，头像立即就可以工作了 🙂

我对自己过于关注 ip/localhost URL 引用而不是检查基本知识感到恼火……但总而言之，在过去的两天里我学到了很多东西，现在它正在工作 🙂

---

_[View the full topic](https://meta.discourse.org/t/avatar-upload-issue-ubuntu/394901)._
