VisualEditor/Installation on a shared host

From MediaWiki.org
Jump to: navigation, search

VisualEditor requires a Parsoid service (using the Parsoid/Developer Setup here). Parsoid requires also Node.js running in the background at all times. Most shared-hosting companies don't provide this. If you cannot move your wiki to a dedicated hosting solution such as a VPS, then a workaround is to install Parsoid on a cloud platform which supports Node.js, such as Heroku.com. Be aware that this is not an official hack.

  1. Install Extension:VisualEditor on your wiki as per usual (you can download it from here)
  2. Sign up with Heroku.com
  3. In the a language choice section select node.js
  4. Install the Heroku Command Line Interface as well as any dependencies (i.e node.js and npm).
  5. The first thing you should do when you installed Git is to set your user name and email address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating. So set your name and email with the following commands:
    git config --global user.name "John Doe"
    git config --global user.email johndoe@example.com
    
  6. Download Parsoid using this command:
    git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid.git
    
  7. After successfully downloading, go to Parsoid location on your disk (for example here "C:\parsoid").
  8. In Parsoid folder change the file .gitignore (this file is located between "tools" folder and ".gitreview" file in Parsoid root folder). Here you need to remove the line config.yaml (11 line).
  9. Now you also need to change the file config.example.yaml. Open it and change uri (line 37) The "uri" is the URL to your API (normally this is in the root-folder and called api.php). Change this option according your wiki (for example http://wiki.mysite.com/api.php or http://mysite.com/w/api.php or something like that. For mediawiki.org it is https://www.mediawiki.org/w/api.php):
    uri: 'http://wiki.mysite.com/api.php' or uri: 'http://wiki.mysite.com/api.php'
    
  10. Once you applied the changes save the file as config.yaml
  11. Now, login to your heroku account by typing:
    heroku login
    
    Then sign in to your heroku account using your email address and password.
  12. To create a new app type in console:
    heroku create
    
  13. Then open your app on Heroku.
  14. In "Settings" tab edit the "Config Variables" and add the following parameters:
    KEY: NODE_ENV  VALUE: production
    KEY: Buildpack VALUE: nodejs
  15. Then from inside the parsoid folder ("C:\parsoid\") add all files to your git repository:
    git init
    
    git add .
    
    git commit
    
  16. You'll see git editor. You can get out of it by typing the command :q. After this you are shown the message "Aborting commit due to empty commit message". Don't worry this is normal.
  17. Next, add your Heroku app as a Git remote:
    heroku git:remote -a appname
    
    git commit -m "Initial commit"
    
    git push heroku master
    
    Now you should get a positive response.
  18. Before you run your app set Heroku to run it with one dyno:
    heroku ps:scale web=1
    
  19. To test your installation open your app: URL is http://APPNAME.herokuapp.com
  20. You should see a HTML-Page titled "Welcome to the Parsoid web service". which shows that Parsoid is working.
  21. Now it's time to change your LocalSettings.php:
    wfLoadExtension( 'VisualEditor' );
    
    //Enable VisualEditor by default for everybody
    $wgDefaultUserOptions['visualeditor-enable'] = 1; 
    
    // Optional: Set VisualEditor as the default for anonymous users
    // otherwise they will have to switch to VE
    // $wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";
    
    // Don't allow users to disable it
    $wgHiddenPrefs[] = 'visualeditor-enable';
    
    // OPTIONAL: Enable VisualEditor's experimental code features
    #$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;
    
    // Parsoid configuration
    $wgVirtualRestConfig['modules']['parsoid'] = array(
    // URL to the Parsoid instance
    // Use port 8142 if you use the Debian package
    // url must not end in a slash, otherwise it might give a 404 error
    'url' => 'APPNAME.herokuapp.com',
    // Parsoid "domain", see below (optional)
    'domain' => 'localhost',
    // Parsoid "prefix", see below (optional)
    'prefix' => 'your wiki prefix',
    //If you run a private wiki then you have to set the following variable to true:
    'forwardCookies' => true
    );
    

Example Parsoid in Heroku[edit]

http://parsoidonheroku.herokuapp.com

External resources[edit]

Getting Started with Node.js over Heroku Manual