"미디어위키 Scribunto 설치"의 두 판 사이의 차이

84번째 줄: 84번째 줄:
:→ Bananas 모듈의 hello 함수를 호출
:→ Bananas 모듈의 hello 함수를 호출
*그러면 결과가 다음과 같이 나와야 한다.
*그러면 결과가 다음과 같이 나와야 한다.
:Hello, world!
<source lang='text'>
Hello, world!
</source>


==주석==
==주석==

2014년 8월 10일 (일) 23:17 판

1 개요

미디어위키 Scribunto 설치
미디어위키 확장기능 Scribunto 설치
  • 모듈:XXXX 형식으로 Lua 언어를 사용가능하도록 하는 미디어위키 확장기능
  • 1) Lua를 설치해도 되고, 2) LuaSandbox를 설치해도 된다.[1]
여기서는 Lua를 설치하는 방법으로 할 것이다.[2]

2 요구조건 확인

2.1 미디어위키 1.20 이상

  • 자신의 미디어위키 웹사이트에서 Special:Version 가기
  • 미디어위키 버전이 1.20 이상인 확인

2.2 PCRE 8.10 이상

[root@jmnote ~]# php -i | grep PCRE
PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 8.32 2012-11-30
→ PCRE의 버전이 8.32이므로 OK

2.3 Lua 버전 5.1 이상

[root@jmnote ~]# lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
→ Lua 버전이 5.1.4이므로 OK

2.4 Lua 퍼미션 확인

[root@jmnote ~]# which lua
/usr/bin/lua
[root@jmnote ~]# ll /usr/bin/lua
-rwxr-xr-x 1 root root 12552 Oct  7  2010 /usr/bin/lua
→ 모든 리눅스계정에 대해 실행가능. OK

3 Scribunto 설치

[root@jmnote w]# cd extensions/
[root@jmnote extensions]# git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
Cloning into 'Scribunto'...
remote: Counting objects: 700, done
remote: Finding sources: 100% (498/498)
remote: Getting sizes: 100% (183/183)
remote: Compressing objects: 100% (421212/421212)
remote: Total 3582 (delta 230), reused 3466 (delta 225)
Receiving objects: 100% (3582/3582), 2.56 MiB | 641 KiB/s, done.
Resolving deltas: 100% (1864/1864), done.

4 미디어위키 설정 변경

require_once "$IP/extensions/Scribunto/Scribunto.php";
$wgScribuntoDefaultEngine = 'luastandalone';
$wgScribuntoEngineConf['luastandalone']['errorFile'] = '/var/log/luastandalone_error.log';
//$wgScribuntoUseGeSHi = true;

5 확인

  • 자신의 미디어위키 웹사이트에서 Special:Version 가기
  • "설치된 확장 기능" 목록 중 Scribunto 있는지 확인

6 테스트

-- 헬로 월드!
local p = {}
 
function p.hello()
    return "Hello, world!"
end
 
return p
  • 아무 문서에서 아래 내용 기입하고 미리보기
{{#invoke:bananas|hello}}
→ Bananas 모듈의 hello 함수를 호출
  • 그러면 결과가 다음과 같이 나와야 한다.
Hello, world!

7 주석

  1. Lua는 리눅스 쉘에서 직접 실행되는 방식이고 LuaSandbox는 PHP 확장기능으로서 실행되는 방식이다.
  2. LuaSandbox가 더 빠르다고는 하는데, 어차피 Lua는 문서 저장시에만 실행되므로 별로 부담되는 것은 아니다. 즉, 미디어위키 문서로 저장되고 나면, 읽을 때는 Lua가 구동되지 않는다. 또한 LuaSandbox는 컴파일 설치가 필요하다...

8 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}