ubuntu下搭建nginx+scala+play 2.0运行环境的方法介绍

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提示无法为对象分配空间,?澹??兜?G,经过3个小时的奋战,终于配置成功了,顺便也记录下。
<strong>1、安装nginx,mysql</strong>
编译什么的网上一大堆,就不细说了,大家可以google下。
<strong>2、安装JDK</strong>
<em>注意:ubuntu用户请务必将OpenJDK替换成sunJDK</em>
<em>[ubuntu用户]</em>
01
sudo add-apt-repository ppa:ferramroberto/java
02
#如果上面命令提示:command not found,就输入如下命令:sudo apt-get install python-software-properties
03
04
sudo apt-get update
05
sudo apt-get install sun-java6-jre sun-java6-plugin
06
sudo apt-get install sun-java6-jdk
07
08
update-alternatives --config java
09
#选择jdk,输入上面命令后会有3个选项,选择第2个选项
10
Selection Path Priority Status
11
------------------------------------------------------------
12
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
13
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
14
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文件
1
export JAVA_HOME=/usr/local/jdk1.7.0_05
2
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
3
export PATH=$PATH:$JAVA_HOME/bin
<strong>3、下载playframework文件</strong>
[cc lang="c"]
http://www.playframework.org/
[/cc]
3.1、安装scala,只运行play2.0的话是可以不用安装的。
1
http://www.scala-lang.org/ #下载debin包,如果安装的openjdk的话可能出现缺少 janic
2
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.deb
1
dpkg -i repo-deb-build-0002.deb
2
apt-get update
3
apt-get install sbt
安装过程中可能需要点时间,完成后测试进入scala目录测试
sbt
4、启动play2.0项目
1
play
2
start -Dhttp.port=9000
5、nginx设置代理
01
server
02
{
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
}

(0)

相关推荐