리눅스

[CentOS 7] MediaWiki + VisualEditor 설치하기

나태준 2018. 9. 20. 00:12
반응형
오늘부터 위키로 공부 자료를 정리하기 시작했다. 기념으로 오늘 삽질한 내용을 복붙!

사전 준비

Git 설치

yum -y install git

Node.js 설치

git clone https://github.com/nodejs/node.git
cd node
git checkout v10.10.0
./configure
make
make install

필수 PHP 모듈 설치

yum install php-mbstring php-xml

캐시, 유니코드 지원 PHP 모듈설치 (옵션)

yum install php-apc php-intl

MediaWiki(미디어위키) 설치

wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz tar -xvzf mediawiki-1.31.0.tar.gz cp -r mediawiki-1.31.0 /var/www/html/w 

http://localhost/w/에 접속하여 설치과정을 시작한다. 만약 퍼미션 문제가 나온다면 w 디렉토리에 644이상의 퍼미션을 준다. 설치가 끝나면 LocalSettings.php를 다운받아 /var/www/html/w에 넣어준다.

옵션: 단축형 주소 설정

/etc/httpd/conf/httpd.conf를 열어 아래와 같이 수정한다.

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

/var/www/html/.htaccess[1]에 아래의 5줄을 추가한다. 파일이 없는 경우 생성하면 된다.

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

/var/www/html/w/LocalSettings.php를 아래와 같이 수정한다.

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = "/$1";

httpd.conf를 수정했으므로 데몬을 재시작 해준다.

systemctl start httpd.service

여기까지 끝나면 http://localhost/대문 형태의 단축형 주소을 사용 가능하다.

옵션: 파일 업로드 설정

업로드 용량 확장

/etc/php.ini를 아래와 같이 수정한다.

upload_max_filesize = 10M
post_max_size = 10M

/var/www/html/w/LocalSettings.php를 아래와 같이 수정한다.

# 10MB = 10240 KB = 10485760 B
$wgUploadSizeWarning = 10485760;
$wgMaxUploadSize = 10485760;

파일 확장자 제한

/var/www/html/w/LocalSettings.php를 아래와 같이 수정한다.

허용 확장자를 설정

$wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'pdf');

금지 확장자를 설정 (허용 확장자와 충돌시, 금지 확장자를 우선)

$wgFileBlacklist = array(
  # HTML may contain cookie-stealing JavaScript and web bugs
  'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht',
  # PHP scripts may execute arbitrary code on the server
  'php', 'phtml', 'php3', 'php4', 'php5', 'phps',
  # Other types that may be interpreted by some servers
  'shtml', 'jhtml', 'pl', 'py', 'cgi',
  # May contain harmful executables for Windows victims
  'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' );

확장자 제한 해제

$wgStrictFileExtensions = false;

옵션: VisualEditor(시각 에디터) 설치

VisualEditor는 위키 문법에 익숙하지 않은 사용자를 위한 WYSIWYG 에디터이다. 다만, 설치 방법이 제대로 설명되어 있는 자료를 찾을 수 없어 장기간 헤매는 경우가 많아 여기에 정리해둔다.

VisualEditor 설치

cd /var/www/html/w/extensions git clone -b REL1_31 https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git cd VisualEditor git submodule update --init

Parsoid 설치

cd /var/www/html/w
git clone --recursive 
https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid/deploy
git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid
cd parsoid
npm install
cp config.example.yaml config.yaml

/var/www/html/w/LocalSettings.php를 열어 아래 줄을 추가한다. 도메인만 설정하고 접두사(prefix)는 사용하지 않는다. 도메인을 설정하는데 별칭의 개념이므로 딱히 중요한 의미는 없다.

# End of automatically generated settings.
# Add more configuration options below.
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;

$wgVirtualRestConfig['modules']['parsoid'] = array(
  # URL to the Parsoid instance
  # Use port 8142 if you use the Debian package
  'url' => 'http://127.0.0.1:8000',
  # Parsoid "domain", see below (optional)
  'domain' => 'nadowiki',
  # Parsoid "prefix", see below (optional)
  #'prefix' => 'same_prefix'
);

/var/www/html/w/parsoid/config.yaml를 열어 아래와 같이 수정한다. LocalSettings.php와 같은 도메인을 설정해준다.

        mwApis:
        - # This is the only required parameter,
          # the URL of you MediaWiki API endpoint.
          uri: 'http://127.0.0.1/w/api.php'
          # The "domain" is used for communication with Visual Editor
          # and RESTBase.  It defaults to the hostname portion of
          # the `uri` property above, but you can manually set it
          # to an arbitrary string. It must match the "domain" set
          # in $wgVirtualRestConfig.
          domain: 'nadowiki'  # optional

/etc/sysconfig/iptables에 아래 2줄을 추가하여 7231(restbase)[2], 8000(parsoid)번 포트를 열어준다.

-A INPUT -p tcp -m state --state NEW -m tcp --dport 7231 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8000 -j ACCEPT

npm으로 parsoid 데몬을 시작해준다.

npm start

PM2 설치

매번 Parsoid를 실행해 줄 수는 없기 때문에 PM2를 이용해 데몬화 한다.

npm install -g pm2
cd /var/www/html/w/parsoid
pm2 start npm --name "parsoid" -- start
pm2 save
pm2 startup



반응형
자바스크립트를 활성화시켜주세요!
[활성화]