Make sure to run this tutorial on an Instance running the Docker InstantApp image or make sure Docker is installed on the Instance, as Overleaf requires Docker.
Installing Overleaf Community Edition
- media
- Overleaf
- ubuntu
Overleaf is a collaborative writing and publishing system that uses LaTeX, a typesetting software that allows for the creation of structured, professional documents online.
It is particularly favored by academics and professionals for producing scientific documents, research papers, theses, and presentations due to its precise formatting and styling capabilities. Overleaf also supports real-time collaboration between multiple authors.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
- An Instance running on the Docker image or with Docker installed
- Installed
git
on your Instance For optimal performance, we recommend running this tutorial on an Instance with more than 30 GB of storage.
Installing Overleaf community edition
- Connect to your Instance using SSH:
ssh root@<YOUR-INSTANCE-IP>
- Use
git
to download the Overleaf code repository:git clone https://github.com/overleaf/toolkit.git /opt/overleaf-toolkit - Enter the Overleaf
overleaf-toolkit
directory.cd /opt/overleaf-toolkit - Run the following command to copy the configuration files:
./bin/init
- Download and start the Overleaf container and its requirements:
./bin/upTip
- If a web server is already running on port 80, be sure to stop it before executing the above command.
- Downloading and configuring the application for the first start may take some time.
- Stop the application by pressing
CTRL+C
. - Open the file
./config/overleaf.rc
in a text editor and edit theNGINX_HTTP_PORT=80
line. Set the value toNGINX_HTTP_PORT=8877
, then save the file and exit the editor.
Configuring a systemd script
Once Overleaf runs correctly, you can create a systemd daemon service.
- Create and open the
/etc/systemd/system/overleaf.service
file in a text editor of your choice and paste the following content into it:[Unit]Description=Overleaf Community Edition[Service]User=rootWorkingDirectory=/opt/overleaf-toolkitExecStart=/opt/overleaf-toolkit/bin/upRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.target[Unit]Description=Overleaf Community Edition[Service]User=rootWorkingDirectory=/opt/overleaf-toolkitExecStart=/opt/overleaf-toolkit/bin/upRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.target - Save the file and exit the text editor.
- Reload systemd by running the following command:
systemctl daemon-reload
- Enable the
overleaf.service
to be started on reboot:systemctl enable overleaf.service - Start the Overleaf service:
systemctl start overleaf.service
- Check the status of the Overleaf service:
systemctl status overleaf.service
Installing LaTeX packages
The LaTeX packages can now be installed, using TeX Live.
- Run the following command to launch the Texlive manager update:
docker exec Overleaf Community Edition tlmgr update --self
- Run the following command to launch the full
texlive
installation:docker exec Overleaf Community Edition tlmgr install scheme-fullNoteThe installation of
texlive
may take a while.
Configuring Nginx
This tutorial uses NGINX with Let’s Encrypt and CertBot as an SSL-enabled reverse proxy to secure the connection between the client and our server.
-
Install Certbot on the server:
apt install python3-certbot-nginx -
Generate the certificate, by running the following command:
sudo certbot --nginx certonlySSL certificates issued by Let’s Encrypt are valid for 90 days. Certbot comes with the option to automatically renew the certificate.
-
Configure a cron job that launches Certbot daily to check the status of the certificate. Open the crontab by typing:
crontab -e -
Add the following line which will stop Nginx, renew the certificate, and restart the web server daily at 4:30 in the morning:
30 4 * * * /opt/letsencrypt/certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start" -
Edit the
/etc/nginx/sites-enabled/default
file so that it looks like the example below. This allows you to configure Nginx in a way that will serve our Overleaf Community Edition site as the default site:server {listen 80;listen [::]:80;server_name my.overleave-instance.tld;location / {return 301 https://$server_name$request_uri;}}server {listen [::]:443 ssl ipv6only=on;listen 443 ssl;server_name my.overleave-instance.tld;ssl_certificate /etc/letsencrypt/live/my.overleave-instance.tld/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/my.overleave-instance.tld/privkey.pem;include /etc/letsencrypt/options-ssl-nginx.conf;ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;proxy_set_header X-Forwarded-For $remote_addr;add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";server_tokens off;add_header X-Frame-Options SAMEORIGIN;add_header X-Content-Type-Options nosniff;client_max_body_size 50M;location / {proxy_pass http://localhost:8877;proxy_set_header X-Forwarded-Proto $scheme;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_read_timeout 3m;proxy_send_timeout 3m;access_log /var/log/nginx/Overleaf Community Edition.access.log;error_log /var/log/nginx/Overleaf Community Edition.error.log;}} -
Restart Nginx with the following command:
service nginx restartYou can now reach your Overleaf installation at
https://<YOUR-INSTANCE-IP>/launchpad
. Open a web browser and navigate to this page to set up your instance’s administrator credentials, log in, and you can start drafting your documents, and invite collaborators to work with you.