Solved

How to get a rails app showing up on local server after /puclic/index.html is removed - rough times to get Rails going

Posted on 2009-05-15
16
2,453 Views
Last Modified: 2013-12-05
I did follow this tutorial http://guides.rubyonrails.org/getting_started.html#hello-rails
up to point 4.1 "starting up the web server".
Rails is configured to work with Apache, using Passenger. I set up the httpd.conf file to point to my /blog/public and configured /etc/hosts to use the local server which I called 'railsites' on IP 127.0.0.1. From tutorial when I first start up the mongrel with /script/server and then type http://railsites:3000 the intro site or public/index.html shows up
properly and instantly but when I try http://railsites:3000/home/index to show up the page that should be generated
through the controller (/blog/app/views/home/index.html.erb) it produces only an /h1> on browser screen instead
of the 'Hello, Rails!'

Or, when I continue to step 4.2 and remove the index.html in /public folder, set the routs as described and then directly run application by apache, giving http://railsites/index or http://railsites/home/index or dimply http://railsites
then I get a mesage: "We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly."

Alternatively if I start mongrel and open http://railsites:3000 in the browser then I do not get the
site that I created in index.html.erb but an error message in browser window:
  Routing Error
  No route matches "/" with {:method=>:get}

Anyone experienced enough to tell me what I did wrong here and how to get anything Railslike
to get going on local development server?

And last: Do I generally have a misconception with Rails or is this all a sign that I am wrong with Rails, because
my original fun was in creating web pages, then first used PHP for all the 'backend' functional scripting work, also had a go on ASP.NET but often did run into a hell of complicated and itself repeating code and then learned/listened that Rails is supposed to do all what php is doing in a percentage of time and effort ... but ... since starting with the Rails
on above mentioned tutorial not getting very far with it, really, speaking in terms of development - well still sitting
in the area of setting up Rails so that i see that it is working on my development environment properly . . .
and slowly fun is going down the tubes (I like coding and I like designing but with Rails so far nothing got easier
since I am in a hickhack of administrative tasks before I even can start of doing anything with it) ???  
0
Comment
Question by:xberry
  • 10
  • 6
16 Comments
 
LVL 12

Expert Comment

by:cminear
ID: 24397634
To be fair, you are not following the guide.  There is nothing in there about configuring Apache, so either shut down Apache or revert its configuration so that it isn't trying to work on port 3000.  (Curiously, the guide does not tell the reader to install Mongrel, but then assumes that it is installed when it claims that Mongrel is started.)  I followed the guide on a system which never had Rails on it previously, and got the the expected results (other than the first time it was using Ruby's Webrick web server instead of Mongrel).  I then installed Mongrel and repeated step 4.1 and it still worked as reported.

I'm a little concerned about you modifying the /etc/hosts file.  Again, I would recommend that you revert this file to how it was before adding 'railsites' to it.  (OK, you are supposed to be a Master in Linux Setup, so I would hope that that is not the problem.  Still, things can go very bad if 'localhost' is no longer there or overridden.)

When you say you start Mongrel, are you using 'script/server', called just like that?  If so, what do you see if you go to the same 'localhost' URLs?  

Hopefully, this will get you back on track with the guide.  However, if none of these seem to fix the issue, please include your versions of 'app/views/home/index.html.erb' and 'config/routes.rb'.

(If you are insistent on jumping into getting Rails working with Apache, I'd like to see what changes or additions you made to httpd.conf; also, what version of Apache are you using?  If you read something to help with that configuration, what or where is that documentation?)
0
 
LVL 14

Author Comment

by:xberry
ID: 24402076
Thanks for giving some of your valuable time to me

>>To be fair, you are not following the guide.  There is nothing in there about configuring Apache

True enough, but my thoughts went like: Apache is the common web server amongst hosters and from
my LAMP setup I am used to work with Apache, so I was glad to listen it is possible with Phusion Passenger.

If you know of a complete tutorial that is written for a Suse Linux environment, getting Rails going with Apache, I would be grateful.

>>Still, things can go very bad if 'localhost' is no longer there or overridden
It is not overridden. railsites is just an alias for 127.0.0.1, same as localhost. I did imply this as a solution
for having localhost pointing to everything under /srv/www/htdocs while railsites is simply pointing to
my /home/me/Rails/blog/public folder, for purpose of running, developing Rails.

>>When you say you start Mongrel, are you using 'script/server', called just like that?
Yes, of course, but the messages that I get from console might be helpful for you:

=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-05-16 12:22:03] INFO  WEBrick 1.3.1
[2009-05-16 12:22:03] INFO  ruby 1.8.7 (2008-08-11) [i586-linux]
[2009-05-16 12:22:03] WARN  TCPServer Error: Address already in use - bind(2)
[2009-05-16 12:22:03] INFO  WEBrick::HTTPServer#start: pid=5545 port=3000

Interesting, it is Webrick, not Mongrel !?

If I run http://localhost:3000 or /localhost/home/index I get the same results as I get with the railsites URL variation,
see above. Of course running http:/localhost without the :3000 call would give me anything that I put under the
/srv/www/htdocs  path.

>> please include your versions of 'app/views/home/index.html.erb' and 'config/routes.rb'.
No problem, but because of extension I attach them as code snippet, see below:

One notice to /config/routes.rb :

I forgot to comment out the line
map.root :controller => "home", which I hat # ed for a test, but when I remove the #
the only change it makes is, that when i start the script/server and call with railsites:3000 or plus any path like
/home or /home/index then I don't get that Routing Error
  No route matches "/" with {:method=>:get} any longer, but instead in any case the
result /h1> is displayed in the browser.
 
httpd.conf ? see below in snippet

Apache 2 version 2.2.10-2.5 installed

Sorry, the documentation for helping how to set up apache for pointing to my Rails folders if localhost is
already pointing to a different path, I cannot find quick now, but i assume the experts coming up here will
give me some guide to do this all properly ;-))





app/views/home/index.html.erb
 

<h1>Hello Rails</h1>
 

--------------------
 

config/routs.rb
 

ActionController::Routing::Routes.draw do |map|

  # The priority is based upon order of creation: first created -> highest priority.
 

  # Sample of regular route:

  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'

  # Keep in mind you can assign values other than :controller and :action
 

  # Sample of named route:

  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'

  # This route can be invoked with purchase_url(:id => product.id)
 

  # Sample resource route (maps HTTP verbs to controller actions automatically):

  #   map.resources :products
 

  # Sample resource route with options:

  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
 

  # Sample resource route with sub-resources:

  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
 

  # Sample resource route with more complex sub-resources

  #   map.resources :products do |products|

  #     products.resources :comments

  #     products.resources :sales, :collection => { :recent => :get }

  #   end
 

  # Sample resource route within a namespace:

  #   map.namespace :admin do |admin|

  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)

  #     admin.resources :products

  #   end
 

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.

  map.root :controller => "home"

  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.

  # Note: These default routes make all actions in every controller accessible via GET requests. You should

  # consider removing the them or commenting them out if you're using named routes and resources.

  map.connect ':controller/:action/:id'

  map.connect ':controller/:action/:id.:format'

end
 

-----------------------------------------------------------------------------------------------------
 

httpd.conf
 

#

# /etc/apache2/httpd.conf 

#

# This is the main Apache server configuration file.  It contains the

# configuration directives that give the server its instructions.

# See <URL:http://httpd.apache.org/docs-2.2/> for detailed information about

# the directives.
 

# Based upon the default apache configuration file that ships with apache,

# which is based upon the NCSA server configuration files originally by Rob

# McCool. This file was knocked together by Peter Poeml <poeml+apache@suse.de>.
 

# If possible, avoid changes to this file. It does mainly contain Include

# statements and global settings that can/should be overridden in the

# configuration of your virtual hosts.
 

# Quickstart guide:

# http://www.opensuse.org/Apache_Howto_Quickstart
 
 

# Overview of include files, chronologically:

#

# httpd.conf

#  | 

#  |-- uid.conf  . . . . . . . . . . . . . .  UserID/GroupID to run under

#  |-- server-tuning.conf  . . . . . . . . .  sizing of the server (how many processes to start, ...)

#  |-- sysconfig.d/loadmodule.conf . . . . .  [*] load these modules

#  |-- listen.conf . . . . . . . . . . . . .  IP adresses / ports to listen on

#  |-- mod_log_config.conf . . . . . . . . .  define logging formats

#  |-- sysconfig.d/global.conf . . . . . . .  [*] server-wide general settings

#  |-- mod_status.conf . . . . . . . . . . .  restrict access to mod_status (server monitoring)

#  |-- mod_info.conf . . . . . . . . . . . .  restrict access to mod_info

#  |-- mod_usertrack.conf  . . . . . . . . .  defaults for cookie-based user tracking

#  |-- mod_autoindex-defaults.conf . . . . .  defaults for displaying of server-generated directory listings

#  |-- mod_mime-defaults.conf  . . . . . . .  defaults for mod_mime configuration

#  |-- errors.conf . . . . . . . . . . . . .  customize error responses

#  |-- ssl-global.conf . . . . . . . . . . .  SSL conf that applies to default server _and all_ virtual hosts

#  |

#  |-- default-server.conf . . . . . . . . .  set up the default server that replies to non-virtual-host requests

#  |    |--mod_userdir.conf  . . . . . . . .  enable UserDir (if mod_userdir is loaded)

#  |    `--conf.d/apache2-manual?conf  . . .  add the docs ('?' = if installed)

#  |

#  |-- sysconfig.d/include.conf  . . . . . .  [*] your include files 

#  |                                             (for each file to be included here, put its name 

#  |                                              into APACHE_INCLUDE_* in /etc/sysconfig/apache2)

#  |

#  `-- vhosts.d/ . . . . . . . . . . . . . .  for each virtual host, place one file here

#       `-- *.conf . . . . . . . . . . . . .     (*.conf is automatically included)

#

#

# Files marked [*] are created from sysconfig upon server restart: instead of

# these files, you edit /etc/sysconfig/apache2
 
 
 

#  Filesystem layout:

#

# /etc/apache2/

#  |-- charset.conv  . . . . . . . . . . . .  for mod_auth_ldap

#  |-- conf.d/

#  |   |-- apache2-manual.conf . . . . . . .  conf that comes with apache2-doc

#  |   |-- mod_php4.conf . . . . . . . . . .  (example) conf that comes with apache2-mod_php4

#  |   `-- ... . . . . . . . . . . . . . . .  other configuration added by packages

#  |-- default-server.conf

#  |-- errors.conf

#  |-- httpd.conf  . . . . . . . . . . . . .  top level configuration file

#  |-- listen.conf

#  |-- magic

#  |-- mime.types -> ../mime.types

#  |-- mod_autoindex-defaults.conf

#  |-- mod_info.conf

#  |-- mod_log_config.conf

#  |-- mod_mime-defaults.conf

#  |-- mod_perl-startup.pl

#  |-- mod_status.conf

#  |-- mod_userdir.conf

#  |-- mod_usertrack.conf

#  |-- server-tuning.conf

#  |-- ssl-global.conf

#  |-- ssl.crl/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificate Revocation Lists (CRL)

#  |-- ssl.crt/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificates

#  |-- ssl.csr/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificate Signing Requests

#  |-- ssl.key/  . . . . . . . . . . . . . .  PEM-encoded RSA Private Keys

#  |-- ssl.prm/  . . . . . . . . . . . . . .  public DSA Parameter Files

#  |-- sysconfig.d/  . . . . . . . . . . . .  files that are created from /etc/sysconfig/apache2

#  |   |-- global.conf

#  |   |-- include.conf

#  |   `-- loadmodule.conf

#  |-- uid.conf

#  `-- vhosts.d/ . . . . . . . . . . . . . .  put your virtual host configuration (*.conf) here

#      |-- vhost-ssl.template

#      `-- vhost.template
 
 
 

### Global Environment ######################################################

#

# The directives in this section affect the overall operation of Apache,

# such as the number of concurrent requests.
 

# run under this user/group id

Include /etc/apache2/uid.conf
 

# - how many server processes to start (server pool regulation)

# - usage of KeepAlive

Include /etc/apache2/server-tuning.conf
 

# ErrorLog: The location of the error log file.

# If you do not specify an ErrorLog directive within a <VirtualHost>

# container, error messages relating to that virtual host will be

# logged here.  If you *do* define an error logfile for a <VirtualHost>

# container, that host's errors will be logged there and not here.

ErrorLog /var/log/apache2/error_log
 

# generated from APACHE_MODULES in /etc/sysconfig/apache2

Include /etc/apache2/sysconfig.d/loadmodule.conf
 

# IP addresses / ports to listen on

Include /etc/apache2/listen.conf
 

# predefined logging formats

Include /etc/apache2/mod_log_config.conf
 

# generated from global settings in /etc/sysconfig/apache2

Include /etc/apache2/sysconfig.d/global.conf
 

# optional mod_status, mod_info

Include /etc/apache2/mod_status.conf

Include /etc/apache2/mod_info.conf
 

# optional cookie-based user tracking

# read the documentation before using it!!

Include /etc/apache2/mod_usertrack.conf
 

# configuration of server-generated directory listings

Include /etc/apache2/mod_autoindex-defaults.conf
 

# associate MIME types with filename extensions

TypesConfig /etc/apache2/mime.types

DefaultType text/plain

Include /etc/apache2/mod_mime-defaults.conf
 

# set up (customizable) error responses

Include /etc/apache2/errors.conf
 

# global (server-wide) SSL configuration, that is not specific to 

# any virtual host

Include /etc/apache2/ssl-global.conf
 

# forbid access to the entire filesystem by default

<Directory />

    Options None

    AllowOverride None

    Order deny,allow

    Deny from all

</Directory>
 

# use .htaccess files for overriding,

AccessFileName .htaccess

# and never show them

<Files ~ "^\.ht">

    Order allow,deny

    Deny from all

</Files>
 

# List of resources to look for when the client requests a directory

DirectoryIndex index.html index.html.var
 

### 'Main' server configuration #############################################

#

# The directives in this section set up the values used by the 'main'

# server, which responds to any requests that aren't handled by a

# <VirtualHost> definition.  These values also provide defaults for

# any <VirtualHost> containers you may define later in the file.

#

# All of these directives may appear inside <VirtualHost> containers,

# in which case these default settings will be overridden for the

# virtual host being defined.

#

Include /etc/apache2/default-server.conf
 
 

# Another way to include your own files

#

# The file below is generated from /etc/sysconfig/apache2,

# include arbitrary files as named in APACHE_CONF_INCLUDE_FILES and

# APACHE_CONF_INCLUDE_DIRS

Include /etc/apache2/sysconfig.d/include.conf
 
 

### Virtual server configuration ############################################

#

# VirtualHost: If you want to maintain multiple domains/hostnames on your

# machine you can setup VirtualHost containers for them. Most configurations

# use only name-based virtual hosts so the server doesn't need to worry about

# IP addresses. This is indicated by the asterisks in the directives below.

#

# Please see the documentation at

# <URL:http://httpd.apache.org/docs-2.2/vhosts/>

# for further details before you try to setup virtual hosts.

#

# You may use the command line option '-S' to verify your virtual host

# configuration.

#

Include /etc/apache2/vhosts.d/*.conf
 

#<VirtualHost *:80>

#    ServerName blogdev 

#    DocumentRoot /home/klaus/Rails/blog/public

#</VirtualHost>
 

# Note: instead of adding your own configuration here, consider 

#       adding it in your own file (/etc/apache2/httpd.conf.local)

#       putting its name into APACHE_CONF_INCLUDE_FILES in 

#       /etc/sysconfig/apache2 -- this will make system updates 

#       easier :) 
 
 

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so

PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.2

PassengerRuby /usr/bin/ruby
 

<Directory /home/klaus/Rails>

  Order Deny,Allow

  Allow from all

</Directory>
 

NameVirtualHost 127.0.0.1
 

<VirtualHost 127.0.0.1>

   DocumentRoot /home/klaus/Rails/blog/public

   ServerName railsites

</VirtualHost>
 

<VirtualHost 127.0.0.1>

   DocumentRoot /srv/www/htdocs

   ServerName localhost

</VirtualHost>
 

-------------------------------------------------------------------------------------------------------

Open in new window

0
 
LVL 12

Expert Comment

by:cminear
ID: 24412543
You have two competing problems right now: trying to get through the tutorial to learn more about Rails; and getting Rails running on Apache + Passenger.

As you may gather, the point of the guide you are working with is to give the reader an example of how Rails works, and how easy it is to develop with it.  Plus, there are so many options for production deployment that it is just simpler to focus on the built-in web server solution.  Furthermore, while there is some benefit for testing against a deployment configuration, much of development is easier if you are just running the Webrick server (or Mongrel) in situ for development testing.  It is fast enough for development work, and server restarts (needed for changes to database/model objects) will likely be easier and quicker.

However, I'm a little concerned about this line from starting up Webrick.  
  [2009-05-16 12:22:03] WARN  TCPServer Error: Address already in use - bind(2)
This would suggest that some other service is already listening on port 3000.  Make sure all 'script/server' processes are stopped, and do 'netstat -ant'.  Is port 3000 still present in the output?  If so, that is not going to help in troubleshooting.  Is Apache stopped?  Was it configured to listen on port 3000?  (Apparently this installation of Apache --- SUSE specific? --- pushes the listen configuration into 'listen.conf'.)  If you can't figure out what is listening on port 3000, then start Webrick on a different port and try the tutorial again.
   script/server --port 3001

Now, assuming that gets the tutorial back on track, let's go back to the Apache2/Passenger deployment.  First, I would suggest commenting out the second VirtualHost section, the one for 'localhost'.  Let's first get the Rails app working before we worry about trying to get Rails to share Apache.  And with the second VirtualHost gone, we probably don't need the 'NameVirtualHost' definition either.  Next, I don't see anything in the Passenger docs about defining the Directory section for the Rails directory, so comment that as well.  Double-check that there are no 'conf' files in /etc/apache2/vhosts.d, which may be conflicting with yours.  (Or just comment the 'Include /etc/apache2/vhostd.d/*.conf' line.)  If none of these help get the Rails app working with Apache2/Passenger, start looking at the error logs, and send everything that's new.
0
 
LVL 14

Author Comment

by:xberry
ID: 24444892
Thanks again for your efforts so far.

>> You have two competing problems right now: trying to get through the tutorial to learn more about Rails; and getting Rails running on Apache + Passenger.

True enough.

>> while there is some benefit for testing against a deployment configuration, much of development is easier if you are just running the Webrick server (or Mongrel) in situ for development testing.

Well, it is my 'life-experience' exactly that turned out often enough as a problem: getting a 'site' to deploy in the production environment, so that it is running there as well as in the development environment has often enough been the crucial point, so I am really concerned about that and like to make sure that I develop with eyesight to the final release environment and best keep conditions local and 'live' as homogeneous as possible.

>> do 'netstat -ant'
>> Is port 3000 still present in the output?
no, it isn't.

>> Apparently this installation of Apache --- SUSE specific? --- pushes the listen configuration into 'listen.conf'.
The installation of Apache is not Suse-specific, it is deliberately done by myself to have a LAMP environment available for
site testing and developing.

>> script/server --port 3001
same warning as before:

[2009-05-16 12:22:03] WARN  TCPServer Error: Address already in use - bind(2)
[2009-05-16 12:22:03] INFO  WEBrick::HTTPServer#start: pid=6912 port=3001

Same result after I shut down apache server.

0
 
LVL 12

Expert Comment

by:cminear
ID: 24446247
OK, this is not making sense.  But here are a few more items to try.

I don't think you've said specifically, so try 'script/server' as root.  (If you do not have root permission on this system, it may make the other checks harder.)  Do you get the same 'bind' error?  If not, then apparently your configuration is even restricting additional ports from access by an unprivileged user.  Then you either do development with the server started as root, or this becomes a Linux issue of how to loosen the policy.

If the 'bind' error still occurs, the last comment comes into play.  Is there some security policy (SELinux or firewall) preventing ports 3000 and 3001 from being used?
0
 
LVL 14

Author Comment

by:xberry
ID: 24446712
Its my own workstation, so I can do with it what I like ;-))

Anyway, either with root permission or 'normal' user, i get the same warnings/messages

if timeframe allows then I'll venture a bit deeper into my system and check the security issues
that you put into question.
0
 
LVL 14

Author Comment

by:xberry
ID: 24461409
Hmm, tried a couple of things now:
Disabled firewall, checked all security settings in YAST, wherever I thought something
suspicous could be, but no change.

Any idea where to look for possible problems?
0
 
LVL 12

Expert Comment

by:cminear
ID: 24474025
At this point, I'm leaning to falling back to the very beginning.  Undo the addition of 'railsite' to the hosts file, rename the 'blog' directory, and just start over.  Or if you have access to another system, start fresh on that one.

That said, there are two other items that I'd investigate to see if it makes a difference.  First, I don't think you ever said which database you configured Rails to use.  Rails should not be starting it, so you should have it running, but try it both ways and see what, if anything, changes.  (That is, have the database running and run 'script/server'; then have the database not running, and run 'script/server'.)  Of course, if you are using SQLite, there is no "start the database" step.

Second, have you tried viewing the pages at all, even though it seems to claim an issue with binding to the port?  I possibly have been focussing too much on that warning, which may be just a warning and not an error (even though 'TCPServer Error' is in the output).  Going back through our discussion, I don't see that you've reported what you see when Apache is down and thus not in the picture.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 14

Author Comment

by:xberry
ID: 24475004
>> At this point, I'm leaning to falling back to the very beginning.

Hmm, I am even thinking of removing anything related to Rails and start to install that again.

>> First, I don't think you ever said which database you configured Rails to use.

Not directly, but since I mentioned that my web-hoster is on LAMP
Linux, Apache, MySQL, PHP) and my familiar development is on LAMP, it
would not be too far to guess that I try to run Rails with MySQL, no? . ;-))
By the way, since I wanted to have my Rails-created MySQL database accessible through
Phpadmin as local user, I had to edit the database config file, too, else I would have
to access my database as root every time, which is very uncomfortable.
#Anyway, why should the way I config database and relevant files affect
the way I want to view the index.html.erb file?

>> Second, have you tried viewing the pages at all ?

You mean view with a browser? Of course I did, see above. Maybe you mean
anything else here, please specify.

>> I don't see that you've reported what you see when Apache is down
Yes I did, see one of my comments. Also in latest testings I did shut down Apache as
an alternative, but neither does this change the TCPServer Error nor the result-view in the browser.

Sorry, if I seem harsh or impatient about Rails in some places, I don't really wan't to proof that
it is better or worse than any other ways of development. It simply is different, but not so sure
about the tutorial. Actually my interest for Rails came from indicators, especially from '37 signals'
that Rails is a better and less code intensive aproach to web solutions and then ... I felt very positive
about Ruby language itself and the beauty and ideas behind it (though I've hardly done anything in Ruby).
Somehow the positive feelings I have with Ruby don't want to 'jump' over to Rails. I did work in C++
and did something in VBScript. In any language I can start pretty quick achieving at least a
reasonable 'Hello World' quick, even when I did work with ASP.NET I could get something on screen quick,
but when it comes to Rails it has no resemblence to anything I know.

The only tutorial, which I found which covers setting up Rails with LAM (Linux, Apache MYSQL), basically a LARM
I found here: http://railsforum.com/viewtopic.php?id=29596
Didn't get very far with that one though, since it is written for Ubuntu and any time I try to transfer steps to
SUSE it would fail to do so since it wouldn't give me the files which are obviously Ubuntu specific.
You know about a tutorial for Suse with Rails ?

I am quite prepared to forget completely about Apache and MySQL for sake of trying Rails - it is only, if I'd ever
to advance and find fun with Rails and want to deploy anything in a real production environment, where would I go
and what would I have to do?  What is the standard webserver and database combo for Rails that can be
successfully and foolprooven used in development as well as in production environment ?    
0
 
LVL 12

Expert Comment

by:cminear
ID: 24475358
>>>> First, I don't think you ever said which database you configured Rails to use.

>>Not directly, but since I mentioned that my web-hoster is on LAMP
>>Linux, Apache, MySQL, PHP) and my familiar development is on LAMP, it
>>would not be too far to guess that I try to run Rails with MySQL, no? . ;-))
>>By the way, since I wanted to have my Rails-created MySQL database accessible through
>>Phpadmin as local user, I had to edit the database config file, too, else I would have
>>to access my database as root every time, which is very uncomfortable.

Yep, that would have been a reasonable assumption, and I just forgot that.

>>#Anyway, why should the way I config database and relevant files affect
>>the way I want to view the index.html.erb file?

When Rails starts up, it establishes a connection to the database, even if there is no need for that database connection.  So if it is using MySQL or PostgreSQL via TCP, then it would need to establish that connection in order to effectively work.  Now, this should be a client connection, so I would not expect an error regarding an address already in use.  I'm grasping at straws, here.

>>>> Second, have you tried viewing the pages at all ?

>>You mean view with a browser? Of course I did, see above. Maybe you mean
>>anything else here, please specify.

>>>> I don't see that you've reported what you see when Apache is down
>>Yes I did, see one of my comments. Also in latest testings I did shut down Apache as
>>an alternative, but neither does this change the TCPServer Error nor the result-view in the browser.

Yes, I meant with a browser.  When you were saying "I'm seeing the same thing", I realized I wasn't sure whether you were referring to the TCPServer error only, or also the inability to view the page.  I just wanted to be sure.

The thing that is absolutely frustrating is why it would have a problem binding to port 3000 if 'netstat -ant' does not show any other service posting a listen on port 3000.  Hence my questions about security and database settings.

Here are two more things to try:
1. As root and with Apache not running, try 'script/server --port=80'.  If it's a security setting that was missed or a missing service, this should at least show that the Rails part is OK.  (If this works, or not, double-check the file ownerships and change any that are 'root' to your username before going back to working as yourself.)
2. As a different alternative, try 'script/server --binding=127.0.0.1' (or your actual network address).

Also, I don't think I ever asked how ruby and rubygems (which provides the 'gem' command) where installed on this system.  Did you compile and install from source yourself, use Ruby-provided binary install, or a SUSE-installed ruby?  (Again, I'm not sure how this would make a difference based on what you've seen previously, but it's worth asking.)
0
 
LVL 14

Author Comment

by:xberry
ID: 24480537
>> Here are two more things to try:
>> 1. As root and with Apache not running, try 'script/server --port=80'.

Result:
# script/server --port=80
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:80
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-05-27 09:03:46] INFO  WEBrick 1.3.1
[2009-05-27 09:03:46] INFO  ruby 1.8.7 (2008-08-11) [i586-linux]
[2009-05-27 09:03:46] WARN  TCPServer Error: Address already in use - bind(2)
[2009-05-27 09:03:46] INFO  WEBrick::HTTPServer#start: pid=4982 port=80

>> 2. As a different alternative, try 'script/server --binding=127.0.0.1' (or your actual network address).
# script/server --binding=127.0.0.1
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://127.0.0.1:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-05-27 09:07:42] INFO  WEBrick 1.3.1
[2009-05-27 09:07:42] INFO  ruby 1.8.7 (2008-08-11) [i586-linux]
[2009-05-27 09:07:42] WARN  TCPServer Error: Address already in use - bind(2)
[2009-05-27 09:07:42] INFO  WEBrick::HTTPServer#start: pid=4992 port=3000

--- Now we should scream --- arrrrggg

Interesting though that with # script/server --binding=127.0.0.1
it automatically starts  port :3000 - default setting ?

Only for your interest:
>> The thing that is absolutely frustrating is why it would have a problem binding to port 3000
>>if 'netstat -ant'netstat -ant does not show any other service posting a listen on port 3000:

~> netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 :::111                  :::*                    LISTEN
tcp        0      0 :::22                   :::*                    LISTEN
tcp        0      0 ::1:631                 :::*                    LISTEN

???
Sorry, but if it goes into network administration I am clueless with most things that
demand higher knowledge than some real basics (My Linux setup master I achieved
mainly with real setup-related things such as partitioning, boot problems, Linux-hardware issues,
for the networking side of Linux there is a topic area of its own ;-)) You think it would be a good
idea to get some additional help from experts there ???

0
 
LVL 14

Author Comment

by:xberry
ID: 24496582
>> Also, I don't think I ever asked how ruby and rubygems (which provides the 'gem' command) where installed on this >> system.

I installed them with the Suse YAST package installer
0
 
LVL 12

Accepted Solution

by:
cminear earned 500 total points
ID: 24497688
OK, I think one of three things is going on:
 1. You are hitting some bug in the version of SUSE you're running.
 2. You have seriously torqued your system and it needs to be reinstalled.
 3. We just are not communicating.

I installed openSUSE 11.1, as an approximation of your system.  In addition to the default selections, I also installed Web and LAMP Server, and Ruby devel.  (Possibly some other selections, but hopefully they do not matter.)  After the system rebooted, I eventually also installed the 'ruby-mysql' package.  Here is the list of ruby and mysql RPMs installed on this system.
rubygems-1.3.1-1.3
ruby-mysql-2.7.4-1.136
ruby-devel-1.8.7.p72-5.3
libqt4-sql-mysql-4.4.3-4.7
libmysqlclient15-5.0.67-12.11
mysql-client-5.0.67-12.11
mysql-5.0.67-12.11
php5-mysql-5.2.6-49.11
libmysqlclient_r15-5.0.67-12.11

(Let us know which version of SUSE you are using.)

I also ran 'mysql_install_db' and 'mysqld_safe &' as root.  (That first command may have been a mistake, as I had to go change the ownership of some directories under /var/lib/mysql after that in order to get mysql running.)

I installed rails using 'gem install rails' as root.

I then was able to proceed with the guide you indicated in your original question.  It is important to note that I am seeing the exact same warning from the 'script/server' output that we've been fighting with, but web pages still come up in the browser as the guide shows; 'home/index' displays "Hello, Rails!".  I added 'railsites' to /etc/hosts and it still works as expected.  I even installed passenger --- 'gem install passenger' followed by 'passenger-install-apache2-module' (although I did not modify the Apache config file and start Apache) --- and the Webrick server still produced the expected results.

Note that I did see the 'Routing Error' that you reported.  However, I either went to 'home/index' and came back, or reloaded the page, but it started working very quickly.  I even moved the 'blog' directory out of the way and restarted the guide steps and didn't hit it again.  (It made me wonder about a browser cache.)  One item that helped this is restarting the Webrick server (which is not mentioned in the guide, but should be).

I'll let you decide whether you want to try to revert all the changes you've made to try to get back to a near-fresh install, or just reinstall and start new.  But that would be my suggestion now.
0
 
LVL 14

Author Comment

by:xberry
ID: 24497781
I just tried to sstart a new rails app from scratch, following the tutorial and simply using the
sqlite3 database. Only trouble is, this generating other problems: Because i have no sqlite3 installed
I tried

# gem install sqlite3-ruby

which did result in:

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb install sqlite3-ruby
checking for fdatasync() in -lrt... yes
checking for sqlite3.h... no

make
make: *** No rule to make target `ruby.h', needed by `sqlite3_api_wrap.o'.  Stop.

Somehow I can't get rid of this feeling that something basic is wrong in my installation of
Ruby or RoR ? So what would be the best method to start EVERYTHING from scratch, making sure
that really no rails parts would be missing afterwards?
0
 
LVL 14

Author Comment

by:xberry
ID: 24497965
>> I'll let you decide whether you want to try to revert all the changes you've made to try to get back to a near-fresh
>> install, or just reinstall and start new.  But that would be my suggestion now.

Hmm, i seriously refrain from installing my Suse 11.1 all over again, since I'd had to do lots of (no Rails related) configurations to do all over again.

What I could try is to revert anything Rails related, ie. remove any Ruby and Rails related files from system, maybe even
anything mysql and then follow YOUR tiny rails installation 'tutorial' above in combination with the 'getting started' Rails tutorial.

From your list of what's going on I mostly agree to your
point 2) You have seriously torqued your system and it needs to be reinstalled.

I have the feeling that I have torqued something in relation to Ruby and Rails at the very beginning. A confusion of
privileges and a mix of installation procedures if I remember correctly. Anyway,
as mentioned above, I plan to revert anything ruby and rails-related and get in anything fresh
according to your list AND most important I intend to run a real good and precise log for the 'what
and how to of my fresh Ruby and RoR installation' - some piece of successful action from
my mastering critical linux installations time ;-))
0
 
LVL 14

Author Closing Comment

by:xberry
ID: 31586608
Thanks very much. I throw out anything ruby and rails related from my system and did install necessary files from scrath, following your list.
Not it is running as expected. Whatever spoilt the fun is gone. I think the problem was that I had two concurring versions of rails installed on my system, one installed over yast, because I noticed that rubygem-rails files were installed, one installed via gem install. Now I only did install rails via gem, at the console and all working fine. Thanks for your patience and excellent troubleshooting.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now