SELinux and Parosid
To run the VisualEditor and Parsoid on a CentOS7-Server, you need to do the following.
The requirement is a working MediaWiki (min. V1.25.x) setup. (Crate a LAMP setup on CentOS 7, RHEL 7, Fedora 22, or Scientific Linux 7)
1) Become root:
- CODE: SELECT ALL
su -
Enter the root password
2) install node.js, npm, vim, Git and the SELinux policy python utilities:
- CODE: SELECT ALL
yum install nodejs npm vim-enhanced git policycoreutils-python
Confirm with "y" if asked
4) make sure you are at roots home directory:
- CODE: SELECT ALL
cd ~
5) Download the latest Parsoid form the Git:
- CODE: SELECT ALL
git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid
6) Copy the Paroid to /opt:
- CODE: SELECT ALL
cp -rv ~/parsoid /opt/
7) Go to /opt/parsoid/
- CODE: SELECT ALL
cd /opt/parsoid/
8)Install Parsoid in node.js:
- CODE: SELECT ALL
npm install
9) Create the file /opt/parsoid/api/localsettings.js :
- CODE: SELECT ALL
vim /opt/parsoid/api/localsettings.js
10) press the "Insert" key and copy the following settings:
- CODE: SELECT ALL
‘use strict‘;
exports.setup = function(parsoidConfig) {
parsoidConfig.setMwApi(‘yourwiki‘, { uri: ‘http://base-url-of-your-wiki.com/api.php‘ });
};
Change the yourwiki to a identifier that is unique for your Wiki. You‘ll need this key later.
Change base-url-of-your-wiki.com to the base url that the users use in the browser.
Press "ESC" followed by ":wq!" and "Enter" to save and close vim.
11) Go to /opt/
- CODE: SELECT ALL
cd ..
12) Set file system rights:
- CODE: SELECT ALL
chown -Rv root:root parsoid
...
chmod -Rv u+rw,g+r,o+r parsoid
...
May check with: ls -l
13) Set SELinux labels on filesystem:
- CODE: SELECT ALL
chcon -Rv --type=system_u:object_r:usr_t:s0 parsoid
May check with: ls -Z
14) Open port 8000 in the firewall:
- CODE: SELECT ALL
firewall-cmd --permanent --zone=public --add-port=8000/tcp
firewall-cmd --reload
May check with: firewall-cmd --list-all | grep " ports"
15)Allow Apache to use port 8000:
- CODE: SELECT ALL
semanage port -m -t http_port_t -p tcp 8000
May check with: semanage port -l | grep http_port_t
16) Allow Apace use the network to contact Parsoid:
- CODE: SELECT ALL
setsebool httpd_can_network_connect 0
My check with: getsebool httpd_can_network_connect (should be "off")
17) create a systemd-daemon for Parsoid:
- CODE: SELECT ALL
vi /etc/systemd/system/parsoid.service
18) press the "Insert" key and copy the following settings:
- CODE: SELECT ALL
[Unit]
Description=Mediawiki Parsoid web service on node.js
Documentation=http://www.mediawiki.org/wiki/Parsoid
Wants=local-fs.target network.target
After=local-fs.target network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/parsoid
# EnvironmentFile=-/etc/parsoid/parsoid.env
ExecStart=/usr/bin/node /opt/parsoid/api/server.js
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog
Press "ESC" followed by ":wq!" and "Enter" to save and close vim.
19) Start the Parsoid-daemon:
- CODE: SELECT ALL
systemctl start parsoid.service
If the is no error message, everything should be OK.
20) Test, if Parsoid is working: Go to a users computer and open in a browser http://base-url-of-your-wiki.com:8000/_wikitext/. (Replace base-url-of-your-wiki.com to the base url that the users use in the browser.)
You should now be able to enter some Wiki-code in the form and Parsoid should render in to a correct HTML-page after a click on "Send data".
21) make sure you are at roots home directory:
- CODE: SELECT ALL
cd ~
22) Download the VisualEditor:
- CODE: SELECT ALL
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git
23) Download the UniversalLanguageSelector:
- CODE: SELECT ALL
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UniversalLanguageSelector.git
24) Copy the VisualEditor to the extensions directory of your MediaWiki:
- CODE: SELECT ALL
cp -rV VisualEditor /var/www/your-mediawiki-installation/extensions/
Replace Media /var/www/your-mediawiki-installation with the real path.
25) Copy the UniversalLanguageSelector to the extensions directory of your MediaWiki:
- CODE: SELECT ALL
cp -rV UniversalLanguageSelector /var/www/your-mediawiki-installation/extensions/
Replace Media /var/www/your-mediawiki-installation with the real path.
26) Edit the Settings of your MediaWiki:
- CODE: SELECT ALL
vim /var/www/your-mediawiki-installation/LocalSettings.php
Replace Media /var/www/your-mediawiki-installation with the real path.
27) Go to the end of the file and enter:
- CODE: SELECT ALL
# UniversalLanguageSelector
require_once "$IP/extensions/UniversalLanguageSelector/UniversalLanguageSelector.php";
#VisualEditor
require_once "$IP/extensions/VisualEditor/VisualEditor.php";
// Enable by default for everybody
$wgDefaultUserOptions[‘visualeditor-enable‘] = 1;
// Don‘t allow users to disable it
#$wgHiddenPrefs[] = ‘visualeditor-enable‘;
// OPTIONAL: Enable VisualEditor‘s experimental code features
#$wgDefaultUserOptions[‘visualeditor-enable-experimental‘] = 1;
// URL to the Parsoid instance
// MUST NOT end in a slash due to Parsoid bug
// Use port 8142 if you use the Debian package
$wgVisualEditorParsoidURL = ‘http://base-url-of-your-wiki.com:8000‘;
// Interwiki prefix to pass to the Parsoid instance
// Parsoid will be called as $url/$prefix/$pagename
$wgVisualEditorParsoidPrefix = ‘yourwiki‘;
# Namespces for VE
$wgVisualEditorNamespaces = array_merge(
$wgContentNamespaces,
array( * )
);
# Timeout for HTTP requests to Parsoid in seconds
$wgVisualEditorParsoidTimeout = 200;
Change the yourwiki to a identifier that is unique for your Wiki. You must use the same identification the in step 9!
Change base-url-of-your-wiki.com to the base url that the users use in the browser.
Press "ESC" followed by ":wq!" and "Enter" to save and close vim.
28) Enable the Parsoid-daemon to start on boot time:
- CODE: SELECT ALL
systemctl enable parsoid.service
Should answer with:" ln -s ‘/etc/systemd/system/parsoid.service‘ ‘/etc/systemd/system/multi-user.target.wants/parsoid.service‘"
That‘s it!
It should work on CentOS 7, RHEL 7, Fedora 22, or Scientific Linux 7...
装了几天的wiki VisualEditor 插件没成功,百度谷歌找了很多资料都没搞定,无意中发现了这篇帖子,觉得很不错,虽然还是没成功,但是人家按这方法成功了,可能是我自己的问题。 由于文章来之不易,必须收藏下。