Running multiple web frameworks on one machine? - ruby-on-rails

I want to start experimenting with all these different web frameworks that are available. I was wondering if they could all run in one machine at the same time?
I know that all my database services can all run at the same time, along with the Javascript frameworks, but what about something like Rails and Java applications? Can those play along with each other? Will Apache handle all of this for me?

Yes, since almost any language framework runs as normal code for the language, simply providing structure for applications you write, they can coexist well with other frameworks for the same or other languages. You can certainly run Rails and a Java framework on the same machine - you could even run Rails on JRuby and a Java application server
It sounds like you're just getting started programming. I would recommend learning some of the basics first. For instance, if you want to learn Ruby, try the Pickaxe book, write some simple scripts, then move on to a ruby web framework like Sinatra or Rails. You'll have a better understanding of the difference between a language and framework, how each is installed and run on your machine, etc.

The easiest way to begin experimenting is to use the development server that is included with the various frameworks and run the server on a different port (not 80). For Rails, this is done via:
ruby script\server
which will start a server on port 3000.
Other frameworks use other approaches. Most tutorials for Ruby and Python frameworks (with which I am most familiar) will include instructions on how to start a development server like this.

I don't see why not. It really depends on how the frameworks are deployed and in what containers. If they use separate containers (e.g. tomcat vs apache) you'll need to make sure that the containers are configured to use different ports since many web containers use 80 or 8080.
If you plan on running them all in the same container (e.g. Apache) then I would think they'd be fine, since each one can be treated as a separate web application and deployed to a different location in your document root.
For the most part, it'll probably be trial and error. I don't know much about how Rails interacts with Java, but I've run Grails and Java applications together easily myself with few problems.

I run Rails, PHP, and Java with one Apache server. Except for what felt like a ton of apache config munging when I set it all up, it's been fine. I'm not much of a sysadmin, so it took me a few days to get everything running right.

PHP, Java and Rails all have environments that let you run independent servers and save complex configuration.
Java you can use Tomcat or Jetty.
Rails comes with Webrick, which is fine for development.
PHP has XAMPP (or MAMP if your on the Mac) gives you a complete stack.

I run Rails and ASP.NET MVC on the same Machine and I just set my local servers to run on different ports. But usually the default setup (e.g. Rails on port 3000) will not conflictwith each other, plus each framework usually has its own way to run (LAMP, Webrick, Montgrel...) so you should be fine.

Related

Which folder should i put into filezilla for ROR?

I have the following directory structure:
Which files must I drag into remote site of Filezilla for this ROR project?
When deploying a ROR project you should must use a VPN server. Have you used git for your project? Try to deploy in heroku first. To test your site and have a good practice when deploying rails.
https://devcenter.heroku.com/articles/getting-started-with-rails4
The answer to the question would be: everything
But most likely, copying everything is not gonna make it run, here is why: Rails applications live in separate processes that have to be specifically maintained. On your dev machine, you do this with bundle exec rails server. This is a key difference to how the apache php module works for php apps: There the php interpreter is embedded within the apache process and therefore shares its life cycle automatically.
If you have control over the server you are deploying to, I recommend to start with the Phusion passenger apache module. It takes care of starting your rails processes as needed. In case you are using ubuntu 14:04, I can't recommend to just apt-get install libapche2-mod-passenger because I had many problems with it.
If the server is maintained by somebody else, I'd ask this someone for a solution.
I hope this helps.

Use Docker rather than native/homebrew on Mac?

I currently have a LAMP stack installed on my mac running through Homebrew, which, to be honest hardly ever get's used.
Lately I have been working a lot with AngularJS and service based apps, so generally run the sites through a gulp / nodeJS based webserver.
I am totally frontend orientated, so very rarely do I play with backend related technologies other than the odd Drupal site and mysql.
I am interested to learn more NodeJS, perhaps even some Ruby, purely to understand programming more - not really for it to become my new job description.
So reading up on NodeJS a bit last night I read a lot about Docker, and installed it the toolkit and gui this morning. It looks pretty neat!
My question is: Would it work better for me to just run everything I need through Docker? For example, I can just install the mysql container, and turn it on when I need a db, and just spin up a drupal instance when I need one and connect it to my db instance?
I understand that running Docker on Mac is slower as it doesn't have the native Linux kernel and runs through a VM - but considering my needs from it, this should be okay?
I love the idea of just deploying containers, so will probably want to install Docker on my hosting environment too (VM in the cloud).
Follow up question: 90% of the sites I work on are AngularJS based frontends that speak to APIs that our backend guys build separately. Would it be overkill to have a Docker for each of those sites, or would I rather just run them all in one, or just bypass docker entirely for that (as I mentioned, I normally just load them up from within my Gulp's webserver)
Thanks a lot. I realise this is a n00b asking questions about big technology, but I'm trying to wrap my head around it and hopefully grow a bit in the process.
The interest in deploying Docker container is reproducibility.
You can easily reproduce:
either a complex development environment requiring the installation of numerous libraries (that you don't want to pollute directly your host)
or an execution environment, for a given tool to run (like a web server)
If you are not likely to repeat a setup (for dev or exec), a docker container would bring little value.
But if you want to keep track of the exact specification of an environment (through its Dockerfile) and will deploy it not just on your workstation, but in other places as well, then docker is certainly a good option to consider.

deploy rails choices

After I finished reading Agile Web Development with Rails, I Have developed my own website.
Now I am trying to deploy my project on linux system I rent, but I know nothing about how to deploy rails.Which server should I user? How to connect to mysql database?
As a java developer, I know I can use tomcat as my server which can convert http request to my own object and use jdbc to connect to my mysql database.
Now I want to know what is the main stream environment rails deployed?
I have heard of Lighttpd and FCGI. Can I use them in the product environment?
thanks
Is your linux system a full VPS (you have complete control?) If not, check your hosting company to see what options are available to you. If so, check to see if they have guides for setting up Rails. A lot (Slicehost, Linode, etc.) do.
Failing that... I would recommend either Apache (or Nginx) with Passenger.
https://www.phusionpassenger.com/
It's pretty straight forward.
As for actually deploying, look into Capistrano (or Vlad). These are a little bit more complicated, but they make life so much easier in the long run.

How do I setup multiple rails applications for development?

For the site I am currently working on we have 2 Rails 3.2 projects. One project is basically an API, and the other is a web front end. In order to develop on the web front end I need to have the API project running. I've tried using the foreman and subcontractor gems to manage this but it doesn't seem to work. Both projects run the Thin application server and have their own RVM gemsets. We also run Nginx in production.
How would you go about managing this setup for development? I want there to be 1 command to fire up everything, similar to how Foreman works.
Requirements:
RVM Support
Thin for development
One command I can run from the API application to start both applications
Cannot using Pow (it always seems to get hung up and is incredibly slow)
Setup should work for other developers with minimal setup (easily scriptable)
Works on OSX
Thanks!
tmuxinator allows you to easily configure a tmux session that can be launched with a single command containing any number of windows (tabs) and executes commands in each window (like starting a server). Just configure it to load the appropriate gemset for the appropriate rails server.
https://github.com/aziz/tmuxinator
another, very cool alternative to the tools you've mentioned is Invoker.
it's worth checking out, as it allows to run multiple processes at once (as well as terminate them), like foreman does and it offers .dev domain which mimics pow behavior.

How to install Ruby script on server?

I apologize in advance for the fairly simple question.
I am familiar with PHP, but am trying to install this Ruby script on my server for the first time. It's an open source script that I've forked from github, but unfortunately does not have any instructions. I have Ruby on Rails, and MongoDB installed already.
Does anyone know what the beginner steps are to get started? Should I upload everything via FTP to the public directory, or is there something else to this?
Most Rails projects are much better served by having a proper deployment strategy. Typically this involves making your own repository, easily done by forking that existing application, and cloning that on to your server using git. To make changes in the future, do your work on a development copy, push that into the repository, and pull down the changes on the server.
Unlike PHP where many parts of the application can function independently, Rails applications tend to be far more integrated and uploading it piece by piece is not going to work in the long run.
Rails applications can run stand-alone using the provided rails server tool but this is really only intended for light-duty testing or development work. A more permanent solution is to use something like Passenger to do the hosting for you.
Passenger will take care of launching your application when calls are made to the site you've configured in Apache or nginx, depending on which you end up using. Passenger is popular because it's quite easy to get running.
There are other approaches like unicorn if you're feeling more adventurous.
When you make changes to your Rails application in production mode you will have to create a tmp/restart.txt file in the main application directory to tell your web server to restart the process. This is not a requirement in development mode.
Due to the relative complexity of this process once you include all the various steps, you will probably want to use a deployment automation tool like capistrano.

Resources