I followed this tutorial on the rails wiki about how to get apache with fastcgi working on a vps machine: http://wiki.rubyonrails.com/rails/pages/HowtoInstallAndRunRubyOnRailsOnCpanel In the tutorial it said to add this to the httpd.conf file to get fastcgi working. <IfModule mod_fastcgi.c> FastCgiIpcDir /tmp/fcgi_ipc/ AddHandler fastcgi-script .fcgi </IfModule> However in the rails book, it says to do: <IfModule mod_fastcgi.c> FastCgiIpcDir /tmp/fcgi_ipc FastCgiServer /path/to/app/public/dispatch.fcgi -initial-env RAILS_ENV=production -processes 15 -idle-timeout 60 </IfModule> Right now i have my app up and running on the vps machine. It seems to be pretty responsive considering it is in development mode. - How can i tell if the fastcgi setup is correct? I can see the obvious differences in the two versions of how to change httpd.conf. However, i cant understand why they are different. - In the first example, how many fastcgi servers are running? - How would i change to production environment? I''m not sure if i should use the version from the book because the tutorial was closer to how my vps is setup (cpanel on redhat). Please help... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060313/29d11e24/attachment.html
I am also getting similar errors on fedora. Although, I have set the /tmp/fcgi_ipc as owned by apache and with 755, the error_log still cannot seem to create the dynamic servers. not sure if there is some trick to get fastcgi running as the apache user without a problem. [Mon Mar 13 17:03:08 2006] [crit] (13)Permission denied: FastCGI: can''t create (dynamic) server "/var/www/html/test.rails/public/dispatch.fcgi": bind() failed [/tmp/fastcgi/dynamic/a452aa13feeda365028a2d43d1b2ce13] In my case the difference between FastCgiServer and the AddHandler. It seems from the rails book that this difference is if you specify the number of fastcgi processors that will startup or if apache will manage it for you.>From the book, it is better to specify the number manually like you have.However, if you are having the same permission errors as me, it will not make any difference and I am at a loss what is needed to get it working. On 3/13/06, Manish Shah <mnshah@gmail.com> wrote:> > I followed this tutorial on the rails wiki about how to get apache with > fastcgi working on a vps machine: > > http://wiki.rubyonrails.com/rails/pages/HowtoInstallAndRunRubyOnRailsOnCpanel > > > In the tutorial it said to add this to the httpd.conf file to get fastcgiworking. > > > <IfModule mod_fastcgi.c> > FastCgiIpcDir /tmp/fcgi_ipc/ > AddHandler fastcgi-script .fcgi > > </IfModule> > > > However in the rails book, it says to do: > > <IfModule mod_fastcgi.c> > FastCgiIpcDir /tmp/fcgi_ipc > FastCgiServer /path/to/app/public/dispatch.fcgi -initial-env > RAILS_ENV=production -processes 15 -idle-timeout 60 > </IfModule> > > Right now i have my app up and running on the vps machine. It seems to be > pretty responsive considering it is in development mode. > > - How can i tell if the fastcgi setup is correct? > > I can see the obvious differences in the two versions of how to change > httpd.conf. However, i cant understand why they are different. > > - In the first example, how many fastcgi servers are running? > - How would i change to production environment? > > I''m not sure if i should use the version from the book because the > tutorial was closer to how my vps is setup (cpanel on redhat). > > Please help... > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Regards, Ian Connor -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060313/e08e86d4/attachment.html
The problem for me turned out to be SELinux getting in the way. I was able to disable it and it started to work - hope that helps you. http://www.crypt.gen.nz/selinux/faq.html#GA.7 On 3/13/06, Ian Connor <ian.connor@gmail.com> wrote:> > I am also getting similar errors on fedora. Although, I have set the > > /tmp/fcgi_ipc as owned by apache and with 755, the error_log still cannot seem to create the dynamic servers. > > not sure if there is some trick to get fastcgi running as the apache user without a problem. > > > [Mon Mar 13 17:03:08 2006] [crit] (13)Permission denied: FastCGI: can''t create (dynamic) server "/var/www/html/test.rails/public/dispatch.fcgi": bind() failed [/tmp/fastcgi/dynamic/a452aa13feeda365028a2d43d1b2ce13] > > In my case the difference between FastCgiServer and the AddHandler. It > seems from the rails book that this difference is if you specify the number > of fastcgi processors that will startup or if apache will manage it for you. > From the book, it is better to specify the number manually like you have. > > However, if you are having the same permission errors as me, it will not > make any difference and I am at a loss what is needed to get it working. > > On 3/13/06, Manish Shah <mnshah@gmail.com> wrote: > > > I followed this tutorial on the rails wiki about how to get apache with > fastcgi working on a vps machine: > > http://wiki.rubyonrails.com/rails/pages/HowtoInstallAndRunRubyOnRailsOnCpanel > > > In the tutorial it said to add this to the httpd.conf file to get fastcgiworking. > > > <IfModule mod_fastcgi.c> > FastCgiIpcDir /tmp/fcgi_ipc/ > > AddHandler fastcgi-script .fcgi > > </IfModule> > > > However in the rails book, it says to do: > > <IfModule mod_fastcgi.c> > FastCgiIpcDir /tmp/fcgi_ipc > FastCgiServer /path/to/app/public/dispatch.fcgi -initial-env > RAILS_ENV=production -processes 15 -idle-timeout 60 > </IfModule> > > Right now i have my app up and running on the vps machine. It seems to be > pretty responsive considering it is in development mode. > > - How can i tell if the fastcgi setup is correct? > > I can see the obvious differences in the two versions of how to change > httpd.conf. However, i cant understand why they are different. > > - In the first example, how many fastcgi servers are running? > - How would i change to production environment? > > I''m not sure if i should use the version from the book because the > tutorial was closer to how my vps is setup (cpanel on redhat). > > Please help... > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > -- > Regards, > Ian Connor >-- Regards, Ian Connor -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060314/15b072d1/attachment.html
Manish Shah wrote:> <IfModule mod_fastcgi.c> > FastCgiIpcDir /tmp/fcgi_ipc/ > AddHandler fastcgi-script .fcgi > </IfModule>> <IfModule mod_fastcgi.c> > FastCgiIpcDir /tmp/fcgi_ipc > FastCgiServer /path/to/app/public/dispatch.fcgi -initial-env > RAILS_ENV=production -processes 15 -idle-timeout 60 > </IfModule> > > - In the first example, how many fastcgi servers are running? > - How would i change to production environment?Hi Manish, Here''s what (I think) I''ve gleaned from messing about with this stuff. In the first example you leave it entirely up to Apache to start and stop servers as it deems necessary (dynamic servers). In the second example you have started exactly 15 processes and they run for the lifetime of the apache server (static servers). There''s also FastCGIServerExternal where you start the fcgi servers yourself and just tell apache how to attach to them. (useful for the spinner/spawner/reaper model with swit...I mean capistrano). If you use ''ps'' with the first example you''d see a variable number of fcgi processes depending on load, with the second you''d see a fixed number. The first is probably more efficient in terms of processor resource and memory, the second in response times (apache doesn''t need to decide about, and actually start any processes while serving a request). HTH Alan -- Posted via http://www.ruby-forum.com/.
Alan, thats good stuff. However i cant seem to find any fastcgi processes running. I used top and ps, but nothing looks like a fastcgi process. What should i be lookng for? Also, if i stay with the first example, how can i set the RAILS_ENV to production mode? Thanks, Manish On 3/14/06, Alan Francis <alancfrancis@gmail.com> wrote:> > Manish Shah wrote: > > <IfModule mod_fastcgi.c> > > FastCgiIpcDir /tmp/fcgi_ipc/ > > AddHandler fastcgi-script .fcgi > > </IfModule> > > > <IfModule mod_fastcgi.c> > > FastCgiIpcDir /tmp/fcgi_ipc > > FastCgiServer /path/to/app/public/dispatch.fcgi -initial-env > > RAILS_ENV=production -processes 15 -idle-timeout 60 > > </IfModule> > > > > - In the first example, how many fastcgi servers are running? > > - How would i change to production environment? > > Hi Manish, > > Here''s what (I think) I''ve gleaned from messing about with this stuff. > > In the first example you leave it entirely up to Apache to start and > stop servers as it deems necessary (dynamic servers). In the second > example you have started exactly 15 processes and they run for the > lifetime of the apache server (static servers). > > There''s also FastCGIServerExternal where you start the fcgi servers > yourself and just tell apache how to attach to them. (useful for the > spinner/spawner/reaper model with swit...I mean capistrano). > > If you use ''ps'' with the first example you''d see a variable number of > fcgi processes depending on load, with the second you''d see a fixed > number. The first is probably more efficient in terms of processor > resource and memory, the second in response times (apache doesn''t need > to decide about, and actually start any processes while serving a > request). > > HTH > > Alan > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060314/4a90b314/attachment.html
Manish Shah wrote:> Alan, > > thats good stuff. However i cant seem to find any fastcgi processes > running. I used top and ps, but nothing looks like a fastcgi process. > What > should i be lookng for? > > Also, if i stay with the first example, how can i set the RAILS_ENV to > production mode? > > Thanks, > ManishManish, Have you modifed the public/.htaccess to use fcgi instead of cgi ? If not, it''ll all still work but apache would create a new instance every request. There''s a block of four lines near the bottom of the file and the last one should have dispatch.fcgi instead of .cgi The line you''d see in ps would be something like ''ruby /path/to/my/dispatch.fcgi'' A. -- Posted via http://www.ruby-forum.com/.
Manish Shah wrote:> if i stay with the first example, how can i set the RAILS_ENV to > production mode?Also see the top 4 lines of config/environment.rb for *a* way of forcing production, not sure if it''s the *best* way. I''ve been using Apache2.0 and External Servers on a virtual box I have root access to, so may not be very useful for Apache1.3, dynamic servers and cPanel. A. -- Posted via http://www.ruby-forum.com/.
Alan Francis wrote:> Manish Shah wrote: >> if i stay with the first example, how can i set the RAILS_ENV to >> production mode? > > Also see the top 4 lines of config/environment.rb for *a* way of forcing > production, not sure if it''s the *best* way. I''ve been using Apache2.0 > and External Servers on a virtual box I have root access to, so may not > be very useful for Apache1.3, dynamic servers and cPanel. > > A....or possibly.... "DefaultInitEnv RAILS_ENV production" in httpf.conf ...or possibly .... "SetEnv RAILS_ENV production" in public/.htaccess -- Posted via http://www.ruby-forum.com/.
alan, i checked my .htaccess and i did switch it to use dispatch.fcgi. I ran ps -A and saw 3 instances of dispatch.fcgi. So i guess it is working. Because they are dynamic, does apache take care of restarting them? Now i just have to find the right way to set rails to be in production environment. Thanks for all your help. On 3/14/06, Alan Francis <alancfrancis@gmail.com> wrote:> > Alan Francis wrote: > > Manish Shah wrote: > >> if i stay with the first example, how can i set the RAILS_ENV to > >> production mode? > > > > Also see the top 4 lines of config/environment.rb for *a* way of forcing > > production, not sure if it''s the *best* way. I''ve been using Apache2.0 > > and External Servers on a virtual box I have root access to, so may not > > be very useful for Apache1.3, dynamic servers and cPanel. > > > > A. > > ...or possibly.... > > "DefaultInitEnv RAILS_ENV production" in httpf.conf > > ...or possibly .... > > "SetEnv RAILS_ENV production" in public/.htaccess > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060314/2f0e8060/attachment.html
I have a feeling i have a bunch of zombie fcgi servers running. I see 8 when i run ps -A which should be wrong since i''m the only one using the app in the vps machine. How can i tell if a fcgi proc is a zombie? Do i need to kill them all? Also, whats the proper way to fully kill them? Lastly, i think this is causing a problem for me in switching to production mode. I changed my httpd.conf file to be just like the Agile Rails book. I tried this twice First Time: i made the change, and restarted httpd -> result: application error (rails) shown in the browser Second Time: i made the change, kill -USR1 <pid> for each dispatch,fcgi shown in ps -A, restarted httpd -> seemed to work, but after navigating around a little i got Application Error (rails). I''m not sure what to do. On 3/14/06, Manish Shah <mnshah@gmail.com> wrote:> > alan, i checked my .htaccess and i did switch it to use dispatch.fcgi. > > I ran ps -A and saw 3 instances of dispatch.fcgi. So i guess it is > working. Because they are dynamic, does apache take care of restarting > them? > > Now i just have to find the right way to set rails to be in production > environment. > > Thanks for all your help. > > > On 3/14/06, Alan Francis <alancfrancis@gmail.com> wrote: > > > Alan Francis wrote: > > > Manish Shah wrote: > > >> if i stay with the first example, how can i set the RAILS_ENV to > > >> production mode? > > > > > > Also see the top 4 lines of config/environment.rb for *a* way of > > forcing > > > production, not sure if it''s the *best* way. I''ve been using > > Apache2.0 > > > and External Servers on a virtual box I have root access to, so may > > not > > > be very useful for Apache1.3, dynamic servers and cPanel. > > > > > > A. > > > > ...or possibly.... > > > > "DefaultInitEnv RAILS_ENV production" in httpf.conf > > > > ...or possibly .... > > > > "SetEnv RAILS_ENV production" in public/.htaccess > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060316/15fecde1/attachment-0001.html