Parsoid/Developer Setup

This page describes installation of Parsoid from source. This is primarily useful for developers of Parsoid, but if there are not prebuilt packages of Parsoid for your operating system, you might also find this useful.

Quick start
See ../Setup for more details on the "edit localsettings.js" step. See the Gerrit 'getting started' docs for more help with "git review", which is only necessary if you plan to contribute code changes back to us.

If the above commands don't immediately make sense to you, keep reading for more detailed instructions.

Ensure you have a recent node
Before you install Parsoid, you should ensure that you've got a recent version of node installed.

Parsoid requires node 0.8, but we really recommend 0.10 or higher, and we run 0.10 in production.

If you do not have new-enough node installed, follow the instructions at ../Installing Node and then come back here.

Option 1. Clone the mediawiki/services/parsoid/deploy repository
This is perhaps the simplest way to install Parsoid if you just want to play around for a bit and not have to deal with npm install. This installs the version of Parsoid that is currently deployed in production alongwith all the node dependencies. The parsoid code itself will be in the src/ subdirectory. The npm modules will be in the node_modules/ subdirectory.

Option 2. Clone the mediawiki/services/parsoid repository
You can install the Parsoid code anywhere, it doesn't have to be installed or run as the root user.

Checkout the sources:

Or if you plan to hack Parsoid, follow the the Gerrit 'getting started' docs and set up  in your new checkout. (This will also create an authenticated remote named  in your repository.)

Check your version of node: type  (or   on Debian/Ubuntu)  and it should print   or. (Higher is fine, too.) See ../Installing Node if that's not right.

Install the JS dependencies. Run this command in the Parsoid directory (containing package.json):

Configuration
If you would like to point the Parsoid web service to your own wiki, go to the  directory and create a   file based on. Use  to point to the MediaWiki instance(s) you want to use like this:

Currently Parsoid supports public wikis, and private wikis using cookie forwarding. (See bug 67313 for some more hints on getting this working.)

You can then access pages of your wiki in Parsoid with the relative URL '/yoursite.com/v3/page/html/&lt;page-title&gt;/'

See ../Setup for more details.

Run the server
You should be able to start the Parsoid web service from the parsoid directory using:

and on ubuntu 14.04 type this in /parsoid  directory.

This will start the Parsoid HTTP service, its default in localsettings.js is to listen on port 8000. To test it, point your browser to http://localhost:8000/. If you configured Parsoid correctly, you should be able to parse pages via.

Two environment variables are available to control binding to a specific interface and/or port:

export INTERFACE=127.0.0.1 export PORT=8142 nodejs bin/server.js

Starting the Parsoid service automatically
There are many ways to start services automatically, consult your server's operating system documentation.

On Ubuntu and other operating systems using Upstart, one approach is where /etc/init/parsoid.conf contains configuration similar to MediaWiki-Vagrant's :

On recent versions of Fedora and other operating systems using systemd, use a parsoid.service unit file similar to the following template (modify the file paths as appropriate): The optional  directive above can specify the path to a file similar to the following template:

See bug 53723 for packaging plans that should make the general installation easier.

Gentoo Linux, Funtoo Linux
As an init.d file, supposing that node is installed in its default location and parsoid installed system-wide (npm install -g) A better idea would be to run Parsoid without root permissions. Let's create unprivileged system account: And our init.d script would change accordingly (assuming default locations, system-wide installation):

Windows setup
As of April 2015, the html5 package has only an optional dependency on jsdom, and so installing contextify should no longer be necessary.

Parsoid has a nested dependency on a Node.js module called Contextify (parsoid → html5 → jsdom → contextify). Furthermore, Contextify itself has dependencies on external tools: Python and the "Visual C++" compiler.

Install prerequisite software
Before you can install Parsoid on Windows you will need to install the following software packages:

http://git-scm.com/download/win You will need to add the Git bin\ directory to the System Variable PATH. If you have installed Git in c:\Git, then go to Control Panel→System→Advanced system settings→Environment Variables...→PATH→Edit... and add ;c:\Git\bin to the end of the current Variable value. http://www.visualstudio.com/downloads/download-visual-studio-vs (Visual Studio 2013 Express works too) Visual C++ with service pack is a rather large download, with several hundred MB. http://www.python.org/ As for Git, you will need to add the Python directory to the System Variable PATH. If you have a default installation of Python27, then go to Control Panel→System→Advanced system settings→Environment Variables...→PATH→Edit... and add ;c:\Python27 to the end of the current Variable value:. If you have Python33 installed on the machine, make sure Python27 is ahead in the path variable of the path which points to the Python33 binary. I.e. C:\Windows\System32;C:\Python27;C:\Python33 rather than C:\Windows\System32;C:\Python33;C:\Python27 http://nodejs.org/download/ As of August 2014 is still important for the compilation of Contextify to install the x86 edition of Node.js, even on x64 systems! (TODO: move node installation instructions for Windows to ../Installing Node.)
 * 1) Install Git for Windows (pick Run Git from the Windows command prompt)
 * 1) Install Visual C++ 2010 Express (you can uncheck the SQL part)
 * 1) Install Python27 (not Python33)
 * 1) Install Node.js x86 edition

Install Parsoid
If installing contextify succeeded you can now install Parsoid in Windows. These steps are the same as the installation of Parsoid on Linux: git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid cd parsoid ..\npm install

If ..\npm install fails due to npm being an unknown command, try to add the nodesjs\ folder to the PATH, as explained earlier in the Install prerequisite software section, and run npm install (without ..\) directly from the parsoid folder created byt the git clone command.

If the installation fails again, you may try to disable your router firewall.

When the installation is complete, configure parsoid and run (server.js might be located in the folder bin\ and not in api\ in newer versions of Parsoid): node api\server.js

To run parsoid in the background, create a cmd file in the parsoid directory called parsoid.bat. Setup a scheduled task to run the task on startup. Alternatively several "run batch file as a service" commands exist on the internet. @echo off "%ProgramFiles(x86)%\nodejs\node.exe" api\server.js When using the cmd file as scheduled task it might be required to use the full path to the server.js file (e.g. C:\www\parsoid\api\server.js) instead of api\server.js.

Git will fail to download if you have a corporate proxy to go through, so you need to do the following first; git config --global -e This will launch an editor now press i once in insert mode type; [http] proxy = http://proxy.company.com:8080 Now finally press ESC and then type :wq and press enter to save changes. Proxy is now enabled.

Troubleshooting
If things are still not working, then see our troubleshooting page.