I am new to Rails programming. I did some research, and decided to start with Rails 7, and Ruby 3.1.0.
I am following a simple online tutorial, using the standard Rails 7 stack: Sprockets, no Webpacker, Tailwind (starting to learn it), and MySQL.
I have a local MySQL server setup on my Mac, and i use mysqlworkbench to peer into the local DB.
Locally, I don't need to do anything to get the server started on my development machine. From the command line, I only need to do:
rails s
and a local web server is started on port 3000.
I have an old laptop, that I set up as an Ubuntu 20.04 machine, and is my home network, on port 10.0.0.253. I figured i can use it as a test server, so I can learn how to deploy in the real world. I installed Ruby 3.1, and Mysql on the Ubuntu machine. I also have nginx installed on it, but I don't have it configured to do anything.
On the Ubuntu machine, I can do
rails s
and then from mt Mac, I can go to:
http://10.0.0.253:3000
and I get the rails app.
Of course, when I close the terminal on the Ubuntu machine, the app stops working.
If I don't do rails s on the Ubuntu machine, if I do:
http://10.0.0.253
I get an error (can't find the site you're looking for).
I looked online, and there are a few articles about configuring nginx with Passenger, but no two recipes are the same.
My question is: When I push my code to the Ubuntu server, and I do:
bundle install
rake db:create
rake db:migrate
rake db:seed
What next? to start the server, and I can access it directly at: http://10.0.0.253
Related
My OS: Windows 10
Shell: Ubuntu (from the Microsoft Store)
Rails: 5.0.6
Ruby: 2.4.2
I installed Ruby on Rails using the Ubuntu Shell for Windows. After installing Ruby on Rails, I created a new project (testapp), and I am trying to connect to localhost:3000.
After a lot of searching, checking my /etc/hosts, checking my host file on windows, uninstalling eset, uninstalling XAMPP, Ruby on Rails still refuses to connect to localhost:3000.
I tried to bind it to a different port (multiple times), for example I tried to change it to port 3001, or port 4000, and it still wouldn't work. I tried rails s -b 0.0.0.0, this still doesn't work. I also tried 127.0.0.1, 127.0.0.1:3000, etc.
In the image, I am just showing that I tried rails s to connect to localhost:3000.
Can anybody please help me on why this isn't working? I am confused.
me trying to connect rails to port 3000
Ruby and Rails Version
I've installed Rails 4.2 on a Ubuntu 14.04 VM to act as a development environment. When I start the rails server with rails s the server says it starts and is listening for connections on http://localhost:3000
If I try to access <IP>:3000, no page is displayed and nothing hits the logs of the rails server. If I execute curl localhost:3000 from within the machine, I get the html of my home page.
If I execute rails s -b 0.0.0.0, I can access the server by its IP address.
On my MacBook Pro, running rails s (listening to localhost) allows me to access the rails app via localhost:3000 or <IP>:3000.
Ubuntu 14.04.1
Rails 4.2
http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server
Rails 4.2 release notes say, that now default host for rails server is localhost.
So if you want to access app from another machine, use
rails server -b 0.0.0.0
Probably your Macbook Pro uses older Rails version, with old behavior
I am using rails 2.3.9, rubygems 1.8.24, ruby 1.9.3 and Windows 7 ultimate 64-bit
I just installed nginx as my web server through passenger. Now I want to run nginx as my default server such that when i run ruby script/server, it runs instead of the default WeBrick. Is there any way to do this? Thanks a million.
Nginx doesn't work the way you described. Once it is started, you won't need to run script/server, the rails app will be run at the same time when the Nginx/Apache started.
So, just deploy your rails app following the 'Passenger' manual( in development mode), and you will get your app always running.
so, as conclusion, we can tell that, when deploying a Rails app, Nginx and Apache is in the same group( work together with Passenger), and Mongrel/Webrick/Thin is another group(script/server approach).
You may want to take a look at Foreman.
In my local, I am using werbrick application server for my localhost.
I have Ruby version 1.9.2 .and Rails version 3.1.
How to deploy On live,with Rails Project On Nginx Server?
And What will be the application server (like passenger module with apache) can be used with Nginx server for Rails 3.1 application?
This blog post should give you a good starting point. This one here goes a little deeper in detail. Note: I used these to get nginx running on my local development machine (OSX 10.7) and to host different rails apps locally without using Webrick. Probably there is more to take care of on a live / production system.
I have been using Mongrel successfully with rails 2.* and 3.0* development, with ruby 1.8.7.
I recently started working with Rails 3.1 and ruby 1.9.2. I got my test app running with WEBrick. I don't like WEBrick. If I forget and simply close the WEBrick terminal window instead of going into the window and issuing a Control-C to WEBrick, the server port (3000) stays in use, and I can't run 'rails server' again until I log out everything and get WEBrick cleared out of the port table. Mongrel never had that problem.
I do have a build problem with Mongrel and ruby-1.9.2. I get multiple header files in the build, some referring to ruby-1.9.1 and some ruby-1.9.2. What a mess.
What is the recommended development web server for my config, which is 32-bit Ubuntu Natty with Rails 3.1 and ruby 1.9.2?
Webrick works well for me. The only problem I had is that it did not work well with https secure. The solution was to only run https on staging and production, not on development machine.
I use the dev machine only as the server, and develop on Windows machine with Notepad++. I think it works well, after using a horrible Rails IDE. (I used to use Visual Studio and love it.) Access the web page through local IP and port. It's a cheap, fast easy solution for Windows users.
I am running Ubuntu 11.04, Rails 3.07, Ruby 1.92 with RVM, and PostgreSQL. RVM is supposed to make life easy for Ubuntu users, because Ubuntu uses a different version of Ruby.
To kill the server process running on port 3000: xxxx is the value returned from the first line.
$ lsof | grep 3000
$ kill -9 xxxx
This could easily be combined into one line or an alias killserver or similar.
Thanks for the various port listener kill commands, I will construct something simple to clear the WEBrick's irritating habit, and continue to use it. Chasing a development web server issue is low on my priority list; they should just work.
You can see from my questions that my Linux skills don't go very deep into the kernel.