在Windows电脑上部属Overleaf社区版

前置要求:

  • HyperV(如果使用的是家庭版Windows系统的话需要手动安装,其他版本的只需要在“启用或关闭Windows功能”里启用即可)

  • WSL(Windows Subsystem for Linux,安装完成后需要在“启用或关闭Windows功能”里启用)

  • Docker Desktop

  • Docker-compose

(这两个的安装可以在网上很容易的找到教程。Docker的镜像基本都不能用了,这就是不在Nas上配置的原因。因为弄了一晚上搞不定群晖Nas上的科学上网决定退而求其次现在Windows电脑上配置,以后再转到服务器上)


一开始我先参考Github上的官方教程界面使用overleaf-toolkit,在bin/up一步老是会报错找不到docker-compose,遂放弃,后来找到一篇教程https://zhuanlan.zhihu.com/p/656444021,结合Github里的issue修改了docker-compose.yml文件里的内容,最终成功配置。


首先在Windows中的某个文件夹里创建文件docker-compose.yml,在里面写入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
version: '2.2'
services:
sharelatex:
restart: always
# Server Pro users:
# image: quay.io/sharelatex/sharelatex-pro
image: sharelatex/sharelatex
container_name: sharelatex
depends_on:
mongo:
condition: service_healthy
redis:
condition: service_started
ports:
- 80:80
stop_grace_period: 60s
volumes:
- ~/sharelatex_data:/var/lib/overleaf
########################################################################
#### Server Pro: Uncomment the following line to mount the docker ####
#### socket, required for Sibling Containers to work ####
########################################################################
# - /var/run/docker.sock:/var/run/docker.sock
environment:

OVERLEAF_APP_NAME: Overleaf Community Edition

OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex

# Same property, unfortunately with different names in
# different locations
OVERLEAF_REDIS_HOST: redis
REDIS_HOST: redis

ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file'

# Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS: 'true'

# Disables email confirmation requirement
EMAIL_CONFIRMATION_DISABLED: 'true'

## Set for SSL via nginx-proxy
#VIRTUAL_HOST: 103.112.212.22

# OVERLEAF_SITE_URL: http://overleaf.example.com
# OVERLEAF_NAV_TITLE: Overleaf Community Edition
# OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
# OVERLEAF_ADMIN_EMAIL: support@it.com

# OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
# OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'

# OVERLEAF_EMAIL_FROM_ADDRESS: "hello@example.com"

# OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
# OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:

# OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
# OVERLEAF_EMAIL_SMTP_PORT: 587
# OVERLEAF_EMAIL_SMTP_SECURE: false
# OVERLEAF_EMAIL_SMTP_USER:
# OVERLEAF_EMAIL_SMTP_PASS:
# OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
# OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
# OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
# OVERLEAF_EMAIL_SMTP_LOGGER: true
# OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"

# ENABLE_CRON_RESOURCE_DELETION: true

################
## Server Pro ##
################

## Sandboxed Compiles: https://github.com/overleaf/overleaf/wiki/Server-Pro:-Sandboxed-Compiles
SANDBOXED_COMPILES: 'true'
SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
### Bind-mount source for /var/lib/overleaf/data/compiles inside the container.
SANDBOXED_COMPILES_HOST_DIR: '/home/user/sharelatex_data/data/compiles'

## Works with test LDAP server shown at bottom of docker compose
# OVERLEAF_LDAP_URL: 'ldap://ldap:389'
# OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
# OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
# OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
# OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
# OVERLEAF_LDAP_EMAIL_ATT: 'mail'
# OVERLEAF_LDAP_NAME_ATT: 'cn'
# OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
# OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'

# OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
# OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'


# OVERLEAF_PROXY_LEARN: "true"

mongo:
image: mongo:6.0
command: ["--replSet", "overleaf", "--bind_ip_all", "--port", "27017"]
container_name: mongo
ports:
- 27017:27017
healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'overleaf',members:[{_id:0,host:'{你的ip地址}}:27017'}]}) }" | mongosh --port 27017 --quiet
retries: 10
interval: 5s
timeout: 10s
redis:
restart: always
image: redis:6.2
container_name: redis
volumes:
- ~/redis_data:/data

# ldap:
# restart: always
# image: rroemhild/test-openldap
# container_name: ldap

# See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
# and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
# settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
# but the example here can be used if you'd prefer to run everything with docker-compose

# nginx-proxy:
# image: jwilder/nginx-proxy
# container_name: nginx-proxy
# ports:
# - "80:80"
# - "443:443"
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock:ro
# - /home/overleaf/tmp:/etc/nginx/certs

请更改“{你的ip地址}”里的内容。

右键选择“在终端中打开”,运行“docker-compose up”,等待下载完成(三个包分别是mongo、redis和sharelatex,此处需要科学上网)。

下载完成后进入mongo的docker,找到文件/etc/mongod.conf.orig,修改bindIp为你自己的ip(这里如果只需要在自己电脑上使用的话不需要改,但是上方yml配置文件使用127.0.0.1的话好像会报错,不知道什么问题)。

重启docker,在浏览器里输入{你的ip地址/launchpad},就可以看到overleaf的界面了。第一个注册的账号将会是管理员账号,可以通过管理员账号添加用户。


XeLatex修复

根据官方项目的issue里提到的信息,XeLatex的包有缺损导致无法运行,需要手动安装。


在Windows电脑上部属Overleaf社区版
http://example.com/2025/02/18/Overleafforwindows/
作者
Neptons_02
发布于
2025年2月18日
许可协议