iT邦幫忙

0

請問Linux下該怎麼安裝grails?

我用 root 登入主機
先裝了 git
#mkdir -p ~/workspace
#cd ~/workspace
#su -c 'yum install git-core'

再用 git去下載grails
#git clone git://github.com/grails/grails-core.git

可是
http://www.grails.org/Installation
上面寫說要設 GRAILS_HOME 與 PATH 環境變數? 怎麼設啊?
我用 SET GRAILS_HOME=~/workspace/grails-core
怎麼還是沒效?
用SET去看環境變數, 就是看不到GRAILS_HOME這個

那到底grails該怎麼安裝?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

7
bizpro
iT邦大師 1 級 ‧ 2012-12-20 18:41:11
最佳解答

在RedHat系列的Linux, 環境變數的設定
(1)系統層次:在/etc/profile, ~/.profile, ~/.bash_login, /etc/profile.d/*.sh等處,
就直接編輯/etc/profile檔:
GRAILS_HOME=~/workspace/grails-core
export GRAILS_HOME
PATH=$GRAILS_HOME/bin:$PATH
export PATH
(2)程序層次:直接在安裝grails時用export設定:
$ export PATH=<GRAILS BIN>:$PATH
$ export GRAILS_HOME=<GRAILS HOME>
修改grails的啟動指令將上兩個指令加進去.

也需設定JAVA_HOME, CATALINA_HOME及其PATH的.

看更多先前的回應...收起先前的回應...
player iT邦大師 1 級 ‧ 2012-12-20 19:05:28 檢舉

改過 /etc/profile 之後
會自動生效?
還是要重新開機?

player iT邦大師 1 級 ‧ 2012-12-20 19:13:19 檢舉

./gradlew install
跑了約10分鐘
跑到
BUILD FAILED
這到底是我還有漏掉什麼步驟嗎?

bizpro iT邦大師 1 級 ‧ 2012-12-20 20:46:37 檢舉

請用這指令使修改生效:
$ source /etc/profile

bizpro iT邦大師 1 級 ‧ 2012-12-20 21:06:48 檢舉

我剛按照官網的步驟裝了一下, 沒有任何問題的:
....
:install

BUILD SUCCESSFUL

Total time: 8 mins 35.211 secs

bizpro iT邦大師 1 級 ‧ 2012-12-20 21:19:16 檢舉

我按照官網的hellowolrd執行也正常:
$ grails
| Enter a script name to run. Use TAB for completion:
grails> create-controller hello
| Created file grails-app/controllers/helloworld/HelloController.groovy
| Created file grails-app/views/hello
| Created file test/unit/helloworld/HelloControllerTests.groovy
grails> exit
| Goodbye

bizpro iT邦大師 1 級 ‧ 2012-12-20 21:20:13 檢舉

修改:
$ nano grails-app/controllers/helloworld/HelloController.groovy
改為:
$ cat grails-app/controllers/helloworld/HelloController.groovy
package helloworld

class HelloController {

def index() {
render "Hello World!"
}
}

bizpro iT邦大師 1 級 ‧ 2012-12-20 21:22:10 檢舉

然後執行:
$ grails
| Enter a script name to run. Use TAB for completion:
grails> run-app
| Server running. Browse to http://localhost:8080/helloworld
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
| Enter a script name to run. Use TAB for completion:
就可以運作了:
http://192.168.1.102:8080/helloworld/hello/index
當然看到的是
Hello World!

bizpro iT邦大師 1 級 ‧ 2012-12-20 21:23:39 檢舉

Grails, Play!, 和RoR看來都很像. 而RoR也有JVM版的. 所以Java平台的發展越來越好了.

player iT邦大師 1 級 ‧ 2012-12-20 21:34:08 檢舉

可是我裝到快腦死了
也分不清楚問題出在那裡
#./gradlew install
跑起來最後是這樣

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grails-bootstrap:compileGroovy'.

Forked groovyc returned error code: 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

bizpro iT邦大師 1 級 ‧ 2012-12-20 21:40:59 檢舉

player提到:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

請試試:
$ ./gradlew install --stacktrace
看看少了什麼?

$ ./gradlew install --debug
來檢查log

player iT邦大師 1 級 ‧ 2013-01-04 15:25:36 檢舉

雖然我最後還是裝不起來
不過還是謝了你的回答
工作的難度一下子跳太高
也許該做好最壞的打算了

我要發表回答

立即登入回答