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

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 2명의 중간 판 6개는 보이지 않습니다)
14번째 줄: 14번째 줄:
===PCRE 8.10 이상===
===PCRE 8.10 이상===
{{참고|PCRE 버전 확인}}
{{참고|PCRE 버전 확인}}
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# php -i | grep PCRE
[root@zetawiki ~]# php -i | grep PCRE
PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 8.32 2012-11-30
PCRE Library Version => 8.32 2012-11-30
</source>
</syntaxhighlight>
:→ PCRE의 버전이 8.32이므로 OK
:→ PCRE의 버전이 8.32이므로 OK


===Lua 버전 5.1 이상===
===Lua 버전 5.1 이상===
{{참고|Lua 버전 확인}}
{{참고|Lua 버전 확인}}
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# lua -v
[root@zetawiki ~]# lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
</source>
</syntaxhighlight>
:→ Lua 버전이 5.1.4이므로 OK
:→ Lua 버전이 5.1.4이므로 OK


===Lua 퍼미션 확인===
===Lua 퍼미션 확인===
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# which lua
[root@zetawiki ~]# which lua
/usr/bin/lua
/usr/bin/lua
[root@jmnote ~]# ll /usr/bin/lua
[root@zetawiki ~]# ll /usr/bin/lua
-rwxr-xr-x 1 root root 12552 Oct  7  2010 /usr/bin/lua
-rwxr-xr-x 1 root root 12552 Oct  7  2010 /usr/bin/lua
</source>
</syntaxhighlight>
:→ 모든 리눅스계정에 대해 실행가능. OK
:→ 모든 리눅스계정에 대해 실행가능. OK


==Scribunto 설치==
==Scribunto 설치==
*[[미디어위키 extensions 폴더]]로 이동하여 git으로 설치
*[[미디어위키 extensions 폴더]]로 이동하여 git으로 설치
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote w]# cd extensions/
[root@zetawiki ~]# cd /var/www/html/w/extensions/
[root@jmnote extensions]# git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
[root@zetawiki extensions]# git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
Cloning into 'Scribunto'...
Initialized empty Git repository in /var/www/html/w/extensions/Scribunto/.git/
remote: Counting objects: 700, done
remote: Counting objects: 1468, done
remote: Finding sources: 100% (498/498)
remote: Finding sources: 100% (251/251)
remote: Getting sizes: 100% (183/183)
remote: Getting sizes: 100% (44/44)
remote: Compressing objects: 100% (421212/421212)
remote: Compressing objects: 100% (99219/99219)
remote: Total 3582 (delta 230), reused 3466 (delta 225)
remote: Total 5233 (delta 134), reused 5200 (delta 127)
Receiving objects: 100% (3582/3582), 2.56 MiB | 641 KiB/s, done.
Receiving objects: 100% (5233/5233), 2.83 MiB | 889 KiB/s, done.
Resolving deltas: 100% (1864/1864), done.
Resolving deltas: 100% (2885/2885), done.
</source>
</syntaxhighlight>


==미디어위키 설정 변경==
==미디어위키 설정 변경==
*[[LocalSettings.php]] 하단에 아래 내용 추가
*[[LocalSettings.php]] 하단에 아래 내용 추가
<source lang='php'>
<syntaxhighlight lang='php'>
require_once "$IP/extensions/Scribunto/Scribunto.php";
require_once "$IP/extensions/Scribunto/Scribunto.php";
$wgScribuntoDefaultEngine = 'luastandalone';
$wgScribuntoDefaultEngine = 'luastandalone';
</source>
</syntaxhighlight>


==확인==
==확인==
66번째 줄: 66번째 줄:
==테스트==
==테스트==
*[[모듈:Bananas]]를 아래 내용으로 생성
*[[모듈:Bananas]]를 아래 내용으로 생성
<source lang='lua'>
<syntaxhighlight lang='lua'>
-- 헬로 월드!
-- 헬로 월드!
local p = {}
local p = {}
75번째 줄: 75번째 줄:
   
   
return p
return p
</source>
</syntaxhighlight>
*아무 문서에서 아래 내용 기입하고 미리보기
*아무 문서에서 아래 내용 기입하고 미리보기
<source lang='text'>
<syntaxhighlight lang='text'>
{{#invoke:bananas|hello}}
{{#invoke:bananas|hello}}
</source>
</syntaxhighlight>
:→ Bananas 모듈의 hello 함수를 호출
:→ Bananas 모듈의 hello 함수를 호출
*그러면 결과가 다음과 같이 나와야 한다.
*그러면 결과가 다음과 같이 나와야 한다.
<source lang='text'>
<syntaxhighlight lang='text'>
Hello, world!
Hello, world!
</source>
</syntaxhighlight>


==주석==
==주석==
<references/>
<references/>


==참고 자료==
==참고==
*https://www.mediawiki.org/wiki/Extension:Scribunto
*https://www.mediawiki.org/wiki/Extension:Scribunto


[[분류: 미디어위키 확장기능]]
[[분류: 미디어위키 확장기능]]

2020년 11월 2일 (월) 02:59 기준 최신판

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@zetawiki ~]# 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@zetawiki ~]# lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
→ Lua 버전이 5.1.4이므로 OK

2.4 Lua 퍼미션 확인[ | ]

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

3 Scribunto 설치[ | ]

[root@zetawiki ~]# cd /var/www/html/w/extensions/
[root@zetawiki extensions]# git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
Initialized empty Git repository in /var/www/html/w/extensions/Scribunto/.git/
remote: Counting objects: 1468, done
remote: Finding sources: 100% (251/251)
remote: Getting sizes: 100% (44/44)
remote: Compressing objects: 100% (99219/99219)
remote: Total 5233 (delta 134), reused 5200 (delta 127)
Receiving objects: 100% (5233/5233), 2.83 MiB | 889 KiB/s, done.
Resolving deltas: 100% (2885/2885), done.

4 미디어위키 설정 변경[ | ]

require_once "$IP/extensions/Scribunto/Scribunto.php";
$wgScribuntoDefaultEngine = 'luastandalone';

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 }}