ubuntu搭建nginx+scala+play 2.0運行環境 學scala有段時間了,最近用scala做了個社區:<a href="http://www.cn-scala.com" title="http://www.cn-scala.com"></a>,開始買了個記憶體512的vps,但是編譯都不通過,jvm提示無法為對象分配空間,囧,升級到1G,經過3個小時的奮戰,終於配置成功了,順便也記錄下。 <strong>1、安裝nginx,mysql</strong>編譯什麼的網上一大堆,就不細說了,大家可以google下。<strong>2、安裝JDK</strong><em>注意:ubuntu使用者請務必將OpenJDK替換成sunJDK</em> <em>[ubuntu使用者]</em>01sudo add-apt-repository ppa:ferramroberto/java02#如果上面命令提示:command not found,就輸入如下命令:sudo apt-get install python-software-properties03 www.2cto.com 04sudo apt-get update05sudo apt-get install sun-java6-jre sun-java6-plugin06sudo apt-get install sun-java6-jdk07 08update-alternatives --config java09#選擇jdk,輸入上面命令後會有3個選項,選擇第2個選項10 Selection Path Priority Status11------------------------------------------------------------12* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode13 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode14 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode <em>[非ubuntu使用者]</em>http://www.oracle.com/technetwork/java/javase/downloads/index.html解壓後我把檔案移動到了/usr/local/下
修改/etc/profile檔案1export JAVA_HOME=/usr/local/jdk1.7.0_052 www.2cto.com export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar3export PATH=$PATH:$JAVA_HOME/bin <strong>3、下載playframework檔案</strong>[cc lang="c"]http://www.playframework.org/[/cc] 3.1、安裝scala,只運行play2.0的話是可以不用安裝的。1http://www.scala-lang.org/ #下載debin包,如果安裝的openjdk的話可能出現缺少 janic2 www.2cto.com dpkg -i scala-2.9.2.deb 3.2、安裝sbt https://github.com/harrah/xsbt/wiki/Getting-Started-Setup 我是安裝ubuntu的方法安裝的,記得別忘了下載,不然會提示找不到sbt包 http://apt.typesafe.com/repo-deb-build-0002.deb1dpkg -i repo-deb-build-0002.deb2 apt-get update3 apt-get install sbt 安裝過程中可能需要點時間,完成後測試進入scala目錄測試 sbt 4、啟動play2.0項目 1play2start -Dhttp.port=9000 5、nginx設定代理01 www.2cto.com server02 {03 listen 80;04 server_name *.cn-scala.com cn-scala.com;05 06 location /static {07 root /static/public;08 }09 location / {10 proxy_pass http://127.0.0.1:9000;11 proxy_set_header Host $host;12 proxy_set_header X-Real-IP $remote_addr;13 }14 } 作者 冰雨心