开发者

How to run Scala files on a web server

This could be either an incredibly easy or horrifically complicated 开发者_如何学编程question; but I've started writing code in Scala, and want to run said code on a web server.

There's a few questions that I need answering really, and I apologise for my complete lack of knowledge on the subject, web servers scare me (I'm a PHP developer so all I need to do there is upload to any linux apache server):

  • How to save and upload files (I know how to use ftp software, do I need to do anything from Eclipse?)
  • What to do to my server to run the files (at the moment I just have a linux apache server from fasthosts, is that enough?)

Any other advice would be so greatly appreciated; and the less jargon the better - the whole thing blags me a little.

UPDATE: To put the sort of work I'm doing into context, I'm making a rather large, social-media style site that'll have a very large amount of small, regular posts/updates. Also thanks for the answers so far!

Seems like i need to do all of the following:

  • Learn Scala (I can write in PHP and Java so should be okay)
  • Install Apache tomcat on my server somehow
  • Install Lift (and then either Maven or the SBT)
  • Upload the whole thing?

What do I do about databases?! I need something really serious, with MySQL be okay? Urgh this goes on and on...


Here are the most important points. I'm afraid you will not get this done without lots of reading, but at least you'll know where to start.

  • You need your own servlet container, e.g. Jetty or Tomcat. Those can be used as stand alone servers or together with apache.
  • You need to package your web application as a .war file. That is basically a zip file with all the classes and some meta information. Then you upload the .war file to the server.
  • You should have a look at a web framework for scala, such as Lift.
  • It also helps to be on good terms with one of the major build tools, sbt or maven.


You are better off using a framework - like Lift as the other answer suggest or...

Play framework has scala support as well - http://scala.playframework.org/

You can look at Play framework "Preparing for Production" page - http://www.playframework.org/documentation/1.0.2.1/guide11

It is not going to be like with PHP where you can just ftp and host.


Lift is a whole web development framework around Scala - might want to try their Getting Started page, or just poke around their docs in general.

But in general, you'll be using any of the java-based web application serving solutions, e.g. Jetty, Tomcat.


You have not said what exactly you want to do with Scala on the web. In addition to the Lift and Play frameworks there are some interesting alternatives like Unfiltered:

  • http://unfiltered.databinder.net/Unfiltered.html
  • https://github.com/n8han/Unfiltered

It is also easy to start without any kind of framework by directly writing Servlets: Here is a interesting example that uses Jetty, websocktes and the Scala interpreter to create a web based Scala REPL:

  • https://github.com/TiarkRompf/replhtml

Also the excellent Akka framework has a http module:

  • http://akka.io/docs/akka/1.1.2/scala/http.html

Scalate - http://scalate.fusesource.org/


To start with Scala without too much to read, you may give G-WAN v3.9 (that's the September beta, the release is expected in October) a try.

G-WAN runs Scala source code files without configuration (you just copy a file and call it) and it lets you run other languages the same way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜