Parsoid/Developer Setup/ca

Aquesta pàgina descriu la instal·lació de Parsoid des del codi font. Aquest article és principalment útil pels desenvolupadors de Parsoid, però si no hi ha paquets ja preparats de Parsoid pel vostre sistema operatiu, també podríeu trobar-lo útil.

Inici ràpid
Per compatibilitat enrere, i per continuar donant suport no-estàtic configs,  pot ser configurat de la manera següent:

Vegeu per més detalls en el passos "edit config.yaml" I "edit localsettings.js". Vegeu the Gerrit 'getting started' docs per més ajuda amb "git review", el qual és l'únic necessari si teniu previst fer canvis en el codi i retornar-los-us.

Si en les ordres que es mostren més avall no els hi trobeu immediatament un sentit o utilitat, seguiu llegint per unes instruccions més detallades.

Assegureu-vos de tenir un node recent
Abans d'instal·lar Parsoid, hauríeu d'assegurar-vos que teniu una versió recent de node ja instal·lat.

Parsoid requereix el node v4.x o més recent, i en producció ja utilitzem v6.9.1.

Si no teniu un node prou nou instal·lat, seguiu les instruccions a i llavors torneu aquí.

Opció 1. Cloneu el repositori de mediawiki/services/parsoid/deploy
Aquesta és potser la manera més senzilla d'instal·lar Parsoid si només voleu provar-lo una mica i així no heu no heu de tractar d'instal·lar npm.

Aquesta instal·la la versió de Parsoid que està actualment desplegada en producció per a totes les dependències del node. El mateix codi parsoid estarà en el subdirectori src/. Els mòduls npm estaran en el subdirectori node_modules/.

Opció 2. Cloneu el repositori de mediawiki/services/parsoid
Podeu instal·lar el codi Parsoid a qualsevol lloc, no té perquè estar instal·lat o utilitzat com a usuari root.

Comproveu el codi font:

Or if you plan to hack Parsoid, follow the the Gerrit 'getting started' docs and set up  in your new checkout. (Aquest també crearà un remot autenticat anomenat  en el vostre repositori.)

Comproveu la vostra versió de node: tipus  (o   en Debian/Ubuntu) i podeu imprimir   o. (Més recent va bé, també) Vegeu si allò no va bé.

Instal·leu les dependències de JS. Executeu aquesta ordre en el directori Parsoid (que conté ):

Configuració
Si volguéssiu assenyalar el servei de web de Parsoid en el vostre propi wiki, aneu al directori  i editeu el fitxer. Utilitzeu el paràmetre  per assenyalar a la instància/-es de MediaWiki que voleu utilitzar així:

If you would like to point the Parsoid web service to your own wiki using  file in the   file uncomment the   path like this:

and comment,   and   parameters like this:

aneu al directori  i creeu un fitxer   basat en. Use  to point to the MediaWiki instance(s) you want to use like this:

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

Vegeu per més detalls.

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. Note that this test might also fail, in the case your hosting provider has disabled port 8000 for your account.

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  contains configuration similar to '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:

You can also use PM2 to daemonize the server.js application.

Install using npm:

Start server.js through PM2:

The parsoid server is now running and managed by PM2. Save the process list:

Now whenever PM2 starts the parsoid server application will run and be managed by PM2. The final step is to have PM2 automatically start on system boot:

For later Ubuntu releases that use systemd use this as the [platform] rather than 'ubuntu'.

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

Automatically Starting on Mac OS X
On Mac OS X, you can create a plist. This example names the plist as org.mediawiki.parsoid.start.plist and saves it in /Library/LaunchDaemons. Copy the following content to the org.mediawiki.parsoid.start.plist file:

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):

Configuració de 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 directly from the parsoid folder created by 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 bin\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" bin\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\bin\server.js) instead of bin\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.

Windows Server 2008 R2
MediaWiki must be installed, and an extension Visual Editor as well. Install Git. We may be need to add into an environment variable PATH with the path to the program, e.g.:

C:\Git\bin

Parsoid converts wiki-text to HTML. It require Node.js to be installed. Download and install Node.js x86 MSI latest version.

Now install Parsoid. Enter following lines in Git CMD or BASH:

These commands start Parsoid's files downloading in a folder path to which you can see in a CMD windows (from where you start Git console); jump to folder "parsoid"; and installing component. You may need to reboot your PC if the process of execution of last command hangs. After reboot run the last line.

Then, when everything is done well, copy the localsettings.js.example file to localsettings.js and the config.example.yaml file to config.yaml. Edit following line in those files:

It is url of your mediawiki api.php file, e.g.:

You may also to correct the other important for you lines in those files. To start Parsoid input the next command:

This will start parsoid in a local session, when the machine is restarted – it won’t run again. To run it automatically we need, for example, to create a CMD file with the following content:

here  - is your Parsoid folder. Then add to the windows Scheduler a task for starting this CMD file when computer starts, and check the task's parameters at your discretion.

It is written on the basis of Installing MediaWiki on Windows Server 2012 R2 Core with clarity.

Solució de problemes
Si penseu que hi ha alguna cosa que no va bé, llavors vegeu our troubleshooting page.

Vegeu també

 * Parsoid deployment agenda on Wikimedia cluster
 * VisualEditor and Parsoid server installation from Git on Mac OSX (Ujjwal P)