Forum: Rails-ES Problemón instalando ruby on rails

Posted by Miguel Angel Calleja Lázaro (Guest)
on 2007-10-03 19:26
(Received via mailing list)
Hola lista, voy a abrir un nuevo post para exponer mi problema, perdonad 
las molestias

Estoy teniendo muchos problemas con el hosting para hacer correr ruby on 
rails. Sobre Linux, apache 2, mysql, me han instalado ruby, rubygems y 
rails 1.2.3, me han instalado fastcgi, svn.

No hay manera de arrancar una simple aplicación como un "hola mundo", un 
controlador y una vista que saque el texto, tan simple como ésto para 
probar.

Si el .htaccess está como cgi me saca (no genera ningún log para ver errores):


    Application error

Rails application failed to start properly

y si está como fcgi me saca el dispatch y no parsea nada:

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Al poner la url me saca ésto:

#!/usr/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for 
debugging)
# and the number of requests to process before running garbage 
collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off).  A reasonable number of 
requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
#   # Default log path, normal GC behavior.
#   RailsFCGIHandler.process!
#
#   # Default log path, 50 requests between GC.
#   RailsFCGIHandler.process! nil, 50
#
#   # Custom log path, normal GC behavior.
#   RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'

RailsFCGIHandler.process!

Estoy completamente perdido porque no se por qué no corre rails con un 
ejemplo tan sencillo como éste, algo han montado mal los del hosting y no 
se cómo solucionarlo. No funciona ni con cgi y el fastcgi no parece 
encontrarlo o no se qué pasa.
Me podeis ayudar por favor? Gracias
Posted by Rafael García (rafa)
on 2007-10-03 23:47
Attachment: rgo.vcf (242 Bytes)
(Received via mailing list)
Miguel Angel Calleja Lázaro escribió:
>
> RewriteRule ^$ index.html [QSA]
> # and the number of requests to process before running garbage collection.
> #   RailsFCGIHandler.process! nil, 50
> Me podeis ayudar por favor? Gracias
>
>
>
> _______________________________________________
> Ror-es mailing list
> Ror-es@lists.simplelogica.net
> http://lists.simplelogica.net/mailman/listinfo/ror-es
>
>   

Asegúrate de que en la configuración del apache haya algo parecido a 
esto:

LoadModule fcgid_module /usr/lib/httpd/modules/mod_fcgid.so

<IfModule mod_fcgid.c>
    SocketPath /tmp/fcgid_sock/
    AddHandler fcgid-script .fcgi
</IfModule>


o si no en la configuración de tu virtual host algo parecido a esto 
otro:

<VirtualHost *:80>
   SetEnv RAILS_ENV development
   ServerName dnsnameoripaddress
   DocumentRoot /var/www/rails/cookbook/public/
   ErrorLog /var/www/rails/cookbook/log/apache.log

   <Directory /var/www/rails/cookbook/public/>
      Options ExecCGI FollowSymLinks
      AddHandler fcgid-script .fcgi
      AllowOverride all
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>


Te recomiendo que sigas la guía esta, si tu servidor es CentOS:
http://wiki.rubyonrails.org/rails/pages/Rails+on+C...

o esta otra si es Fedora:
http://wiki.rubyonrails.com/rails/pages/RailsOnFedora

Del primer link he sacado los ejemplos ;-)

Suerte!
Posted by Miguel Angel Calleja Lázaro (Guest)
on 2007-10-04 11:32
(Received via mailing list)
Rafael G. 
escribió:
>> para probar.
>>
>>
>> # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
>> #
>> hosting y no se cómo solucionarlo. No funciona ni con cgi y el 
>>   
> </IfModule>
>   <Directory /var/www/rails/cookbook/public/>
> http://wiki.rubyonrails.org/rails/pages/Rails+on+C... 
>Ror-es mailing list
>Ror-es@lists.simplelogica.net
>http://lists.simplelogica.net/mailman/listinfo/ror-es
>  
>
Es una máquina virtual, está montado en linux pero no se cuál. El caso
es que está instalado ruby, rubygems y rails, y no me funciona ni en cgi
ni fcgi, ni una simple aplicación de prueba como un "Hola Mundo" hace
correr rails. Ya había probado lo que me dices, si añado la línea en
Apache (con su respectiva ruta)
LoadModule fcgid_module /usr/lib/httpd/modules/mod_fcgid.so, al
reiniciar Apache sale una advertencia diciendo que ya está cargado ese
módulo, es como si se cargara en otro sitio, asi que en el .htaccess
quito el  AddHandler fcgid-script .fcgi porque ya está cargado. Si en el
.htaccess le pongo como fcgi me imprime el dispatch y si lo pongo como
cgi me sale el Applicattion rails error y no puedo ver logs por que
están vacíos.
Al Hosting le he especificado ruby 1.8.4, rubygems 0.9.2, rails 1.1.6,
pero se instala rails 1.2.3 no se por qué y yo necesito la 
versión 1.1.6, le he dicho que necesito Fcgi y svn, está todo instalado, he
probado lo que me dices pero sigue igual no corre, y lo del virtual host
creo que no lo necesitamos porque sólo a haber una web, aun así lo he
probado y tampoco va ni con cgi ni fcgi.
Había hecho un symbolic link al public de mi aplicación, si existe
index.html lo muestra, hasta ahí bien, si lo renombro debe coger el
dispatch y ahí peta.

Viendo el log del apache me sale: Premature end of script headers:
dispatch.cgi
En dispatch.cgi tengo:
#!/usr/local/bin/ruby

require File.dirname(__FILE__) + "/../config/environment" unless
defined?(RAILS_ROOT)

# If you're using RubyGems and mod_ruby, this require should be changed
to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" --
otherwise performance is severely impaired
require "dispatcher"

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

Tengo creado un controlador con un simple "Hola Mundo", con cgi me sale
(www.miproyecto.com/prueba):


    Application error

Rails application failed to start properly

y me ha generado un error en el log:
Recognition failed for ""
./public/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:522:in
`recognition_failed'
./public/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:512:in
`recognize!'
./public/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in
`dispatch'
public/dispatch.cgi:10

No se qué puede fallar, si lo hago con fcgi antes al hacer gem install
fcgi me salía un error:
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install fcgi
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Asi que no se, tanto en cgi como fcgi me sale el Premature end of script
headers: dispatch.cgi o dispatch.fcgi

Mmmm, alguna sugerencia?
Posted by Raul Murciano (raul)
on 2007-10-04 11:41
(Received via mailing list)
Miguel Angel Calleja Lázaro 
escribió:> Al Hosting le he especificado ruby 1.8.4, rubygems 0.9.2, rails 1.1.6, 
> pero se instala rails 1.2.3 no se por qué y yo necesito la versión 
> 1.1.6

Sobre esto creo que Juan te dió la solución: congelar la versión 1.1.6
de Rails en /vendor. Aunque hayas generado tu proyecto con rails 1.1.6
si no tienes otra versión de Rails en /vendor tu aplicación sólo podrá 
correr sobre la versión que haya instalada en tu hosting (1.2.3, por lo
que comentas). Si tu environment.rb requiere la 1.1.6 y no la encuentra
ni instalada en el sistema ni en /vendor tendrás problemas para arrancar
la 
aplicación.
Saludos,
   Raul Murciano
Posted by Miguel Angel Calleja Lázaro (Guest)
on 2007-10-04 12:22
(Received via mailing list)
Raul Murciano 
escribió:
>que comentas). Si tu environment.rb requiere la 1.1.6 y no la encuentra 
>
Si, éso lo había hecho ya perdonad por no indicarlo

rake rails:freeze:edge TAG=rel_1-1-6

aparte cree mi aplicación de prueba para comprobar que corre rails en el 
servidor de esta manera también:
rails _1.1.6_ miproyecto

Entonces el environment está con la 1.1.6 también.

Si hago rails -v me sale 1.2.3 que es la que está instalada.

El problema es que da error el dispatch, ni el cgi ni el fcgi me sale el 
Premature end of script headers del dispatch

Ese es el problema que tengo, en el log sale:
Recognition failed for ""
./public/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:522:in
`recognition_failed'
./public/../config/../vendor/rails/actionpack/lib/action_controller/routing.rb:512:in
`recognize!'
./public/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in
`dispatch'

y cuando quise instalar fcgi (gem install fcgi) me salió este otro:
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install fcgi
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
public/dispatch.cgi:10

Estoy perdidísimo, os agradecería vuestra ayuda a ver si lo puedo solucionar 
porque el hosting parece que no está por la labor...
Posted by Rafael García (rafa)
on 2007-10-04 13:00
Attachment: rgo.vcf (242 Bytes)
(Received via mailing list)
Miguel Angel Calleja Lázaro escribió:
>>> on rails. Sobre Linux, apache 2, mysql, me han instalado ruby, 
>>>     Application error
>>>
>>> # exceptions which forced the FastCGI instance to exit, great for 
>>> #   # Default log path, normal GC behavior.
>>>
>>> _______________________________________________
>>
>>   ServerName dnsnameoripaddress
>> </VirtualHost>
>>
> es que está instalado ruby, rubygems y rails, y no me funciona ni en cgi 
> Al Hosting le he especificado ruby 1.8.4, rubygems 0.9.2, rails 1.1.6, 
> dispatch.cgi
> require "dispatcher"
>
> public/dispatch.cgi:10
> *** extconf.rb failed ***
>
>
>
>
>
> _______________________________________________
> Ror-es mailing list
> Ror-es@lists.simplelogica.net
> http://lists.simplelogica.net/mailman/listinfo/ror-es
>
>   
Sabía que ese error al instalar la gema lo había visto en algún lado y
lo he encontrado:

http://wiki.rubyonrails.org/rails/pages/HowtoSetup...

Saludos!
Posted by Miguel Angel Calleja Lázaro (Guest)
on 2007-10-04 14:55
(Received via mailing list)
Rafael G. 
escribió:
>>>> Estoy teniendo muchos problemas con el hosting para hacer correr 
>>>>
>>>> RewriteEngine On
>>>> # You may specify the path to the FastCGI crash log (a log of 
>>>> # could range from 10-100 depending on the memory footprint of your 
>>>> #   RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
>>>> Me podeis ayudar por favor? Gracias
>>> Asegúrate de que en la configuración del apache haya algo parecido a 
>>> o si no en la configuración de tu virtual host algo parecido a esto 
>>>      AddHandler fcgid-script .fcgi
>>>
>>> http://lists.simplelogica.net/mailman/listinfo/ror-es
>> reiniciar Apache sale una advertencia diciendo que ya está cargado 
>> Había hecho un symbolic link al public de mi aplicación, si existe 
>>
>> Tengo creado un controlador con un simple "Hola Mundo", con cgi me 
>> `recognition_failed'
>>     ERROR: Failed to build gem native extension.
>> script headers: dispatch.cgi o dispatch.fcgi
>> Ror-es mailing list
>
> Saludos!
>
>_______________________________________________
>Ror-es mailing list
>Ror-es@lists.simplelogica.net
>http://lists.simplelogica.net/mailman/listinfo/ror-es
>  
>
Me habían instalado mal el fcgi, lo hemos instalado de nuevo y ahora el
gem install fcgi lo hace bien.
Ése era un error que nos daba, pero el problema que tenemos es que tanto
el dispatch.cgi como el dispatch.fcgi parece que no le llega 
ningún parámetro

Si lo corremos como cgi por ejemplo,en la url ponemos:
 miproyecto.com/prueba, debería abrir el controlador prueba y al
dispatch no le está llegando, en el log muestra:

Recognition failed for ""^M
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:522:in
`recognition_failed'^M
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:512:in
`recognize!'^M
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
`dispatch'^M
./dispatch.cgi:10

El recognition failed tendría que estar esperando el nombre de un
controlador y viene vacío y por éso peta, ésto por qué puede ser?
Posted by Miguel Angel Calleja Lázaro (Guest)
on 2007-10-04 16:33
(Received via mailing list)
Resumo lo que he hecho hasta ahora, hemos vuelto a reinstalar el fastcgi
y ahora por fin ejecuta el dispacht correctamente.
Como en el hosting está instalado rails 1.2.3 y mi aplicación es 1.1.6
los paso que he hecho han sido:
1) Genero mi proyecto con la versión 1.1.6, así en el environment pone 1.1.6
    rails _1.1.6_ proyecto
2) rake rails:freeze:edge TAG=rel_1-1-6, se supone que ejecuta esta
versión de rails
3) Subo mi aplicación el app, db, config, public y vendor al servidor

En el navegador cuando abro mi proyecto me aparece este error:
No such file or directory - /tmp/mysql.sock

En la versión 1.1.6 nunca me había pedido ésto, pero pude comprobar que
en la 1.2.3 en el database.yml añade la línea
 socket: /tmp/mysql.sock
asi que lo pongo:
socket: /var/lib/mysql/mysql.sock

Ahora el error que me da es:

Mysql::Error: Lost connection to MySQL server during query: SET NAMES 
'utf8', la única parte que tengo puesto ut8 es en el database.yml le añado el 
encoding

y si lo quito  me vuelve a decir
Mysql::Error: Lost connection to MySQL server during query:


El mysql está instalado, porque nos han facilitado el Phpmyadmin y la
base de datos está creada, a qué puede deberse ese error?
Posted by Rafael García (rafa)
on 2007-10-04 20:44
Attachment: rgo.vcf (242 Bytes)
(Received via mailing list)
Miguel Angel Calleja Lázaro escribió:
> En el navegador cuando abro mi proyecto me aparece este error:
> Mysql::Error: Lost connection to MySQL server during query: SET NAMES 'utf8', la única parte que tengo puesto ut8 es en el database.yml le añado el encoding
>
> _______________________________________________
> Ror-es mailing list
> Ror-es@lists.simplelogica.net
> http://lists.simplelogica.net/mailman/listinfo/ror-es
>
>   
¿Qué te dice el log de mysql?
Posted by Miguel Angel Calleja Lázaro (Guest)
on 2007-10-05 10:09
(Received via mailing list)
Rafael G. 
escribió:
>> 3) Subo mi aplicación el app, db, config, public y vendor al servidor
>> Ahora el error que me da es:
>> base de datos está creada, a qué puede deberse ese error?
>
> ¿Qué te dice el log de mysql?
>
>_______________________________________________
>Ror-es mailing list
>Ror-es@lists.simplelogica.net
>http://lists.simplelogica.net/mailman/listinfo/ror-es
>  
>
Antes de nada, mysql está instalado en el servidor pero quise instalar
la gema de mysql en ruby on rails, creo que daba error de "Lost
connection to MySQL" porque no estaba instalada.
gem install mysql, pero daba unos errores

imac:/ root# gem install mysql
Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
Updating Gem source index for: <a 
href="http://gems.rubyforge.org">http://gems.rubyforge.o...
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (RuntimeError)
    ERROR: Failed to build gem native extension.
Gem files will remain installed in 
/usr/lib/ruby/gems/1.8/gems/mysql-2.5.1 for inspection.
  ruby extconf.rb install mysql\nchecking for mysql_query() in 
-lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

Googleando vi que podía ser que no tenía instalado mysql-dev o que no
encontraba las rutas del mysql_config porque puede que mysql esté 
instalado en otro sitio que no sea el standard.

Asi que he probado con una ruta y ahora me sale este error que ya me da
muy mal rollo

Bulk updating Gem source index for: http://gems.rubyforge.org
/usr/local/lib/ruby/1.8/yaml.rb:133: [BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [x86_64-linux]

Aborted

Salgo de un error y me meto en otro, este tiene bastante mala pinta, no
me deja hacer el gem install mysql
Posted by Rafael García (rafa)
on 2007-10-05 11:04
Attachment: rgo.vcf (242 Bytes)
(Received via mailing list)
Miguel Angel Calleja Lázaro escribió:
>>> 1) Genero mi proyecto con la versión 1.1.6, así en el environment 
>>> que en la 1.2.3 en el database.yml añade la línea
>>> y si lo quito  me vuelve a decir Mysql::Error: Lost connection to 
>>> Ror-es mailing list
>> http://lists.simplelogica.net/mailman/listinfo/ror-es
> Local gem file not found: mysql*.gem
> checking for mysql_query() in -lmysqlclient... no
> muy mal rollo
> _______________________________________________
> Ror-es mailing list
> Ror-es@lists.simplelogica.net
> http://lists.simplelogica.net/mailman/listinfo/ror-es
>
>   
Estás usando una debian o algo basado en debian?

Instala mysql-dev y luego haz gem install.
Posted by Rafael García (rafa)
on 2007-10-06 05:40
Attachment: rgo.vcf (242 Bytes)
(Received via mailing list)
Miguel Angel Calleja Lázaro escribió:
>>>       
>>>>> pone 1.1.6
>>>>>  socket: /tmp/mysql.sock
>>>>> MySQL server during query:
>>>>> Ror-es@lists.simplelogica.net
>>>>  
>>> Local gem file not found: mysql*.gem
>>> checking for main() in -lm... yes
>>> instalado en otro sitio que no sea el standard.
>>> Salgo de un error y me meto en otro, este tiene bastante mala pinta, 
>>
> _______________________________________________
> Ror-es mailing list
> Ror-es@lists.simplelogica.net
> http://lists.simplelogica.net/mailman/listinfo/ror-es
>
>   

Si no puedes instalar mysql-dev debes entonces bajarte el fuente de
mysql, compilarlo (no hace falta que lo instales) y a instalar la gema
especificarle donde están los includes y libs.
Posted by Jesus Granados (jfgg)
on 2011-01-21 22:14
yo tengo ese mismo problema...

#!/usr/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for
debugging)
# and the number of requests to process before running garbage
collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# and the GC period is nil (turned off).  A reasonable number of
requests
# could range from 10-100 depending on the memory footprint of your app.
#
# Example:
#   # Default log path, normal GC behavior.
#   RailsFCGIHandler.process!
#
#   # Default log path, 50 requests between GC.
#   RailsFCGIHandler.process! nil, 50
#
#   # Custom log path, normal GC behavior.
#   RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
#
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'

RailsFCGIHandler.process!

ya revise todo lo que comentan, pero no encuentro nada raro.. lo que si
es que no tengo acceso a la configuracion del apache por que estoy en un
VPS..

mirumb5@vps5147 [~/rubyApps/jescoEnvios2/public]$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2009-06-08 patchlevel 173) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/mirumb5/ruby/gems
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/mirumb5/ruby/gems/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/mirumb5/ruby/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gempath" => []
     - "gem" => "--remote --gen-rdoc --run-tests"
     - "gemhome" => "/home/mirumb5/ruby/gems"
     - "rdoc" => "--inline-source --line-numbers"
  - REMOTE SOURCES:
     - http://rubygems.org/

rails = 2.3.4
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.