Mac OS X 또는Ubuntu 등의 리뉵스에 Grails 2.1.1 을 설치하는 방법을 알아본다

Grais 를 설치하기 위해서는 JDK(Java Development Kit) 6.0 이상이 ㅁㄴ저 설치되어 있으면 충분하다. (Groovy는 설치되어 있지 않아도 된다.)

Grails 홈페이지는 http://grails.org 이다. 현재 최신 릴리즈는 Grails 2.1.1 이다. gails-2.1.1.zip 파일을 다운받아서 압축 해제한 다음 적당한 곳으로 옮긴다.

$ unzip grails-2.1.1.zip

$ sudo mv grails=2.1.1 /usr/local/grails-2.1.1

한경변수 GRAILS_HOME, JAVA_HOME, PATH 를 잡아 준다.

$ sudo vi /etc/profile

하여 다음 세 줄을 추가한다.

JAVA_HOME=................' export JAVA_HOME

GAILS_HOME=/usr/local/grails-2.1.1; export GRAILS_HOME

PATH=$GRAILS_HOME/bin:$JAVA_HOME/bin:$PATH; export PATH


변경된 환경변수의 값을 현재의 ㅌ미널 셀에 적요이킨다.

$ source /etc/profile


홈 폴더(~) 밑에 test 폴더를 만들고 또 그 밑에 테스트르 위한 grails 폴더를 만든 후 ~/test/grails 폴더로 간다.


$ mkdir ~/test
$ mkdir ~/test/grals
$ cd ~/test/grails


~/test/grails 폴더에서 helloworld 애플리케이션 생성한다.

$ grails create-app helloworld
 

* grails 애플리케이션 실행하기

~/test/grails 폴더의 서브폴더 helloworld 러 가서 Grails 애플리케이션을 실행시킨다.

$ cd helloworld

$ grails run-app


 웹브라우저로 http://localhost:8080/helloworld 를 방문한다.



 

* 첫번 째 컨트롤러 만들기

$ grails create-controller hello

[grails-app/contollers/helloworld/HelloController.groovy 파일의 내용]

package helloworld

class HelloController {

    def index() { }

    def world() {
        render "Hello, world! <br />\n${new Date()}<br />\n"
        render "안녕하세요? GRails 2.1.1<br />\n"
    }
}

 

$ grails run-app

웹브라우저로 http://localhost:8080/helloworld/hello/world 를 방문한다.


 

 

 

Posted by Scripter
,