Skip to content

Instantly share code, notes, and snippets.

@moschlar
Last active March 25, 2019 05:01
Show Gist options
  • Save moschlar/2b941f75a44fbac69993 to your computer and use it in GitHub Desktop.
Save moschlar/2b941f75a44fbac69993 to your computer and use it in GitHub Desktop.
Build and install ShareLaTeX in Ubuntu 14.04 LTS

Since the official ShareLaTeX documentation is primarily written with Ubuntu 12.04 LTS in mind, I tried to re-build the provided .deb from scratch using Ubuntu 14.04 TLS with the least amount of non-standard or non-packaged software.

Here are all the steps that were required (with sudo since Ubuntu doesn't want you to be root).

First, install lots of packages - note that no additional repositories are required! (Dependencies):

$ sudo apt-get update
$ sudo apt-get install git build-essential curl python-software-properties zlib1g-dev zip unzip
$ sudo apt-get install ruby-dev
$ sudo apt-get install nodejs npm
$ sudo apt-get install redis-server
$ sudo apt-get install mongodb
$ sudo apt-get install aspell
$ sudo apt-get install texlive latexmk

To satisfy grunt, we need to have an executable called node:

$ sudo ln -s `which nodejs` /usr/local/bin/node

Additionally, we need some packages through external package managers:

$ sudo npm install -g grunt-cli
$ sudo gem install fpm

Now there might be a ~/tmp directory owned by root. We need to remove that so we can continue as a normal user:

$ sudo rmdir ~/tmp

Now we can clone the repository and install all additional dependencies (Setting up a Development Environment, make sure to check out the release branch, as per #comment-1346019):

$ git clone -b release https://github.com/sharelatex/sharelatex.git
$ cd sharelatex
$ npm install

Now we can install the actual ShareLaTeX services:

$ grunt install

After that is done, we can run the provided sanity check:

$ grunt check --force
[...]
Running "check:latexmk" task
Checking latexmk is installed... >> FAIL.
>> latexmk version is too old (4.35). Must be 4.39 or greater.
>> This is a not a fatal error, but compiling will not work without latexmk
Warning: latexmk is too old Use --force to continue.
[...]

In my case, it complained about latexmk being too old, but I ignored that for now, compiling simple LaTeX documents seemed to work anyway.

Now you need to apply the patch below to change one of the dpkg dependencies since the package in the official Ubuntu repositories is called just mongodb instead of mongodb-org:

$ wget https://gist.githubusercontent.com/moschlar/2b941f75a44fbac69993/raw/mongodb-dep.patch
$ patch -p1 < mongodb-dep.patch

After that, we create a huge .deb package:

$ grunt build:deb

Then it should be sufficient to run

$ dpkg -i sharelatex_0.0.1_amd64.deb

(Installing on Ubuntu 12.04 from dpkg (.deb)) and your ShareLaTeX should be running on http://localhost:3000.

And finally, as you might guess, if you want to use Nginx as a Reverse Proxy, you don't need no external repository, the packaged version in the Ubuntu repository is recent enough:

$ sudo apt-get install nginx
diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index 6f618a8..345f6cc 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -440,7 +440,7 @@ module.exports = (grunt) ->
command.push(
"--depends", "redis-server > 2.6.12"
- "--depends", "mongodb-org > 2.4.0"
+ "--depends", "mongodb > 2.4.0"
"--depends", "nodejs > 0.10.0"
)
@MartinSchmidt123
Copy link

Nice guide, thanks!
However, I had to add
ln -s /usr/bin/nodejs /usr/bin/node
before running grunt install. Otherwise ubuntu complaints about not finding
/usr/bin/env: node: No such file or directory

@moschlar
Copy link
Author

@PrivateData, thanks, I added it now!
Forgot to include that command from my history!

@bajo
Copy link

bajo commented Nov 27, 2014

@moschlar: Could you maybe update your guide to get the changes in the latest code of sharelatex as with the new socket.io there are a few problems, so that at least for me it does not work well.
As soon as the editor should open the problem stated in issue #226 arises.
Thanks.

@jpallen
Copy link

jpallen commented Nov 28, 2014

These instructions will not work with the latest development version of ShareLaTeX since we've introduced a new service to handle the socket.io/websocket connections. Please use the release version of ShareLaTeX with these instructions instead:

$ git clone -b release https://github.com/sharelatex/sharelatex.git

@moschlar Can you update the gist with this please?

We will be releasing a new release version soon with the latest changes, but we need to wait for it to stabilise first :).

@SMLaursen
Copy link

Thanks! I've made several attempts at getting sharelatex to run in a virtualmachine and this guide finally made it work flawlessly (using the release version).

My setup is as follows :
Linux Mint 17.1 64bit in VirtualBox with GuestAdditions using bridged network adapter setting.
Windows 8.1 64bit as host OS, i use this OS to access the webserver through Chrome.

@84matte84
Copy link

God bless you! 😃

Finally sharelatex is running on my VM....however when I try to sync the account with dropbox in the account properties this error pops up:

Oops, something went wrong with your request, sorry. If this continues, please contact us at support@sharelatex.com

Is this error related to the sharelatex opensource installation or somethig else?

Thank you once again!

@ookki
Copy link

ookki commented Feb 11, 2015

Hello,

Thanks for the explanation.
I tried to generate the grunt build:deb and I get this error:
Invalid package configuration: Cannot package the path './web', does it exist? {:level=>error}

No .deb package is created.

Do you know what I did wrong?

I use a fresh vm with ubuntu 14.04.

@moschlar
Copy link
Author

@ookki did you really run grunt install before that?

@sovelten
Copy link

It was working before, but now, when I run "grunt build:deb", it says

Warning: Task "build:deb" not found. Use --force to continue.

@MarcoMeter
Copy link

Same issue as ericvm. Did anybody find a solution for that already?

Previously the patch didn't work as well:
patch -p1 < mongodb-dep.patch
patching file Gruntfile.coffee
Hunk #1 FAILED at 440.
1 out of 1 hunk FAILED -- saving rejects to file Gruntfile.coffee.rej

@maxbader
Copy link

I like to confirm:
Same problem as MarcoMeter and ericvm, I used a brand new installed VM with Ubuntu a ubuntu-14.04.2-server-amd64.iso. The patch and also the grunt build:deb does not work

$ wget https://gist.githubusercontent.com/moschlar/2b941f75a44fbac69993/raw/mongodb-dep.patch
$ patch -p1 < mongodb-dep.patch

max@s2:~/sharelatex$ patch -p1 < mongodb-dep.patch
patching file Gruntfile.coffee
Hunk #1 FAILED at 440.
1 out of 1 hunk FAILED -- saving rejects to file Gruntfile.coffee.rej

$ grunt build:deb:

max@s2:~/sharelatex$ grunt build:deb
Warning: Task "build:deb" not found. Use --force to continue.

Aborted due to warnings.

@dafrk
Copy link

dafrk commented May 23, 2015

issue above confirmed on ubuntu 14.04.2-server-amd64

@aaronst
Copy link

aaronst commented Oct 10, 2015

Also having the same issue as above. Has anybody found a fix for this yet?

@wngr
Copy link

wngr commented Dec 1, 2015

See overleaf/overleaf#292

After reverting all the changes from the mentioned commit, deb builds and installs fine.

Copy link

ghost commented Jan 3, 2016

I had to install the following package before 'npm install' would run without error:
( The error was 'make: *** [Release/obj.target/kerberos/lib/kerberos.o] Error 1' )

sudo apt-get install libkrb5-dev

The afore mentioned problem with the fix can be solved (as stated by wngr) by reverting the removal of the patch with:

git revert c96d713

After the revert one can procede with patching the file according to the instractions above.

@chriskvik
Copy link

I'm still having issues on 14.04, installed the 2.6 version of mongodb, which is running and operational. I reverted to the c96d713 build, but it complains when I'm trying to dpkg -i with.

$ sudo dpkg -i sharelatex_0.0.1_amd64.deb

Preparing to unpack sharelatex_0.0.1_amd64.deb ...
Unpacking sharelatex (0.0.1) over (0.0.1) ...
dpkg: dependency problems prevent configuration of sharelatex:
sharelatex depends on mongodb (>> 2.4.0); however:
Package mongodb is not installed.

Can anyone assist me with this error? I'm positive mongodb is installed and running.

@henryoswald
Copy link

ShareLaTeX is only being updated via docker now to try and make the process as simple as possible as many things come pre configured.

@aruntraj83
Copy link

By clicking register it shows "Please contact placeholder@example.com to create an account." . What is the admin password to login with 'placeholder@example.com'. How to change administrator account? How to create other normal users?

@gdistasi
Copy link

Can someone provide me with a VM image with sharelatex installed? my email is gdistasi at gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment