---
slug: "VisualEditorを有効にしたMediaWikiをインストールする"
title: "Install MediaWiki with Visual Editor Enabled"
description: "\n\nI was thinking of creating an internal information sharing service using a Wiki. However, considering that non-developers would also be using it, I thought it would be best to have one with a WYSIWYG editor."
url: "https://www.ytyng.com/en/blog/VisualEditorを有効にしたMediaWikiをインストールする"
publish_date: "2013-08-03T01:29:49Z"
created: "2013-08-03T01:29:49Z"
updated: "2026-02-27T11:07:36.989Z"
categories: ["Linux"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/e1b054ef4d824fe7ad1b3888c4756fa5.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Install MediaWiki with Visual Editor Enabled

<div class="document">

<p>I was thinking of creating an internal information sharing service using a Wiki. However, considering that non-developers would also be using it, I thought it would be best to have one with a WYSIWYG editor.</p>
<p>When taking work notes, I often save screenshots in Evernote, and I believe that kind of user experience is the best.</p>
<p>WordPress is quite close to what I need, but I wanted something even closer to a Wiki. After some research, I found that MediaWiki's recently introduced (as of July 2003) VisualEditor plugin seemed like a good fit, so I decided to install it.</p>

<div class="section" id="id1">
<h3>1. Results</h3>
<p>I thought it would be difficult to place it within authenticated pages on the internet, so I gave up on that.</p>
<ul class="simple">
<li>MediaWiki requires PHP 5.3.2 or higher.</li>
<li>To run the Parsoid server needed for VisualEditor, Node.js 0.8 is required. It does not work with 0.10 (unchecked, according to the official website).</li>
</ul>
</div>

<div class="section" id="id2">
<h3>2. Installation Method</h3>

<div class="section" id="mediawiki">
<h4>2-1. Installing MediaWiki</h4>
<p>As of July 31, 2013, you can download version 1.21.1 from the official MediaWiki site <a class="reference external" href="http://www.mediawiki.org/wiki/Download">http://www.mediawiki.org/wiki/Download</a>, but VisualEditor does not work with this version. Therefore, I cloned the latest 1.22 alpha from the Git repository.</p>
<p>Let's install it in a directory named "mediawiki" within the web public directory.</p>
<pre class="literal-block">$ git clone --depth 1 https://gerrit.wikimedia.org/r/p/mediawiki/core.git mediawiki</pre>
<p>Since no extensions are included, I added those that I might use, including VisualEditor and Parsoid. You can write and execute a shell script for this.</p>
<pre class="literal-block">cd mediawiki/extensions/

git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/VisualEditor.git
git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/Parsoid.git
git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/SyntaxHighlight_GeSHi.git
git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/PdfHandler.git
git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/Gadgets.git
git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/WikiEditor.git
git clone --depth 1 https://git.wikimedia.org/git/mediawiki/extensions/InputBox.git</pre>
<p>Access <a class="reference external" href="http://xxxx/mediawiki/">http://xxxx/mediawiki/</a>, follow the installer steps, and make sure you can see the top page. During the process, check all the boxes for the extensions you want to use.</p>
<img alt="/media/photo/20130803-mediawiki/2013-07-31_14.06.02.png" src="/media/photo/20130803-mediawiki/2013-07-31_14.06.02.png"/>
<p>Log in to MediaWiki, check "Enable VisualEditor" in the personal settings, and when you display the page again, a "Edit Source" tab appears next to the "Edit" tab. This means VisualEditor is enabled.</p>
<img alt="/media/photo/20130803-mediawiki/2013-07-31_14.07.36.png" src="/media/photo/20130803-mediawiki/2013-07-31_14.07.36.png"/>
<img alt="/media/photo/20130803-mediawiki/2013-07-31_14.08.01.png" src="/media/photo/20130803-mediawiki/2013-07-31_14.08.01.png"/>
<p>However, since the Parsoid service is not running, an error will be displayed when you press the edit button.</p>
</div>

<div class="section" id="node-js-0-8">
<h4>2-2. Installing Node.js 0.8</h4>
<p>2-2-a. For mac + homebrew</p>
<p>The latest version of Node.js in homebrew is 0.10x, which is too new. We need to install the older 0.8 version.</p>
<pre class="literal-block">$ brew versions nodejs
0.8.22   git checkout 3c4a714 /usr/local/Library/Formula/node.rb

$ cd /usr/local/Library/Formula
$ git checkout 3c4a714 /usr/local/Library/Formula/node.rb
$ brew install nodejs

$ node -v
v0.8.22</pre>
<p>It's installed.</p>

<p>2-2-b. For CentOS 5.9</p>
<p>We will compile from source.</p>
<p>Install build tools with</p>
<pre class="literal-block">$ sudo yum groupinstall 'Development Tools'</pre>
<p>You will need python2.6 for make, but CentOS 5.x comes with python2.4 by default. So, we need to install python2.6 first.</p>
<pre class="literal-block">$ sudo yum install python26</pre>
<p>Switch the default python to python2.6. I wasn't sure how to do it with yum, so I renamed the binary files.</p>
<pre class="literal-block">$ which python
/usr/bin/python
$ cd /usr/bin
$ sudo rm python # The same binary as python2.4, so remove it
$ sudo ln -s python26 python
$ python
Python 2.6.8 (unknown, Nov  7 2012, 14:47:45)</pre>
<pre class="literal-block">$ cd working_directory
$ curl -O http://nodejs.org/dist/v0.8.25/node-v0.8.25.tar.gz
$ tar -zxvf node-v0.8.25.tar.gz
$ cd node-v0.8.25
$ ./configure
$ make
$ sudo make install</pre>
<p>(After the work, revert the symbolic link to avoid breaking yum: sudo rm python; sudo ln -s python2.4 python)</p>
</div>

<div class="section" id="parsoid">
<h4>2-3. Starting the Parsoid Service</h4>
<p>Edit the configuration file to include the MediaWiki URL (〜/mediawiki/)</p>
<pre class="literal-block">$ cd web_public_directory/mediawiki/extensions/Parsoid/js/api/
$ cp localsettings.js.example localsettings.js
$ vim localsettings.js</pre>
<p>Edit it like this:</p>
<pre class="literal-block">//parsoidConfig.setInterwiki( 'localhost', 'http://localhost/w/api.php' );
parsoidConfig.setInterwiki( 'localhost', 'http://localhost/mediawiki/api.php' );</pre>
<pre class="literal-block">$ cd some_directory/mediawiki/extensions/Parsoid/js
$ npm install
$ node api/server.js</pre>
<p>By default, it listens on port 8000.</p>
<p>The port number can be set with the environment variable process.env.VCAP_APP_PORT || 8000.</p>
<p>Verify it works by accessing http://localhost:8000/ with a browser or curl.</p>
<img alt="/media/photo/20130803-mediawiki/2013-07-31_14.12.24.png" src="/media/photo/20130803-mediawiki/2013-07-31_14.12.24.png"/>
<p>(By the way, I prefer 127.0.0.1 over localhost)</p>
<p>There is a provisional script for starting Parsoid in extensions/Parsoid/js/api/runserver.sh, but</p>
<pre class="literal-block"># kill a running server (crude version..)
killall -9 node</pre>
<p>This is a bit scary.</p>
<p>If the Parsoid server is running, VisualEditor will be usable.</p>
</div>
</div>

<div class="section" id="id3">
<h3>3. Issues</h3>
<p>The mechanism involves HTTP access from the browser to the Wiki server's :8000 via JavaScript, and the Parsoid service on the Wiki server makes HTTP access to localhost.</p>
<p>This is fine for public servers, but if you're using authentication (like BASIC authentication), it gets a bit tricky.</p>
<ul class="simple">
<li>What kind of authentication should be applied to :8000 listening on the server?</li>
<li>Can Parsoid avoid authentication when accessing localhost on port 80?</li>
</ul>
<p>Due to these security concerns, I passed on using it for this purpose.</p>
<p>However, it's very convenient, so I recommend it for public Wikis or internal server machines where security is not a concern.</p>
<p>One possible approach could be enabling VisualEditor on local or internal servers and not enabling it on authenticated internet servers, while sharing (synchronizing) the database content in some way.</p>
</div>

<div class="section" id="mediawikiurl">
<h3>Appendix 1: Displaying External Images in MediaWiki</h3>
<div class="section" id="localsettings-php">
<h4>LocalSettings.php</h4>
<pre class="literal-block">$wgAllowExternalImages = true;</pre>
</div>
</div>

<div class="section" id="url-index-php">
<h3>Appendix 2: Removing index.php from URLs</h3>
<p>By default, URLs are in the form <a class="reference external" href="http://127.0.0.1/mediawiki/index.php">http://127.0.0.1/mediawiki/index.php</a>/Main_Page. Change it to <a class="reference external" href="http://127.0.0.1/mediawiki/wiki">http://127.0.0.1/mediawiki/wiki</a>/Main_Page.</p>
<div class="section" id="id4">
<h4>LocalSettings.php</h4>
<pre class="literal-block">$wgArticlePath = "$wgScriptPath/wiki/$1";</pre>
</div>
<div class="section" id="htaccess">
<h4>.htaccess</h4>
<pre class="literal-block">RewriteEngine on
RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA]</pre>
<p>By the way, if MediaWiki is installed in mediawiki/, it's not difficult to change the article page to <a class="reference external" href="http://127.0.0.1/wiki">http://127.0.0.1/wiki</a>/Main_Page, but it's quite difficult to change it to <a class="reference external" href="http://127.0.0.1/mediawiki">http://127.0.0.1/mediawiki</a>/Main_Page.</p>
</div>
</div>
</div>
