Yesterday I installed my very first Rails application on an Apache server. I had to change the mysql socket path and to apply to those setting I had to let Apache be restarted. Is that always necessary? I would like to run Rails in a shared environment so I can''t have regular users restart Apache. How is that done at hosting companies? Are there any practical solutions? Thanks for a great product!
Julian ''Julik'' Tarkhanov
2005-Oct-12 15:53 UTC
Re: Restarting the webserver to apply settings
On 12-okt-2005, at 8:46, Bart Braem wrote:> Yesterday I installed my very first Rails application on an Apache > server. I > had to change the mysql socket path and to apply to those setting I > had to > let Apache be restarted. > Is that always necessary? I would like to run Rails in a shared > environment > so I can''t have regular users restart Apache. How is that done at > hosting > companies? Are there any practical solutions?No. "Good" Rails environments let users restart their servers (on textdrive it is done by giving every user a port for his very own server, be it Lighttpd or Instiki in a WeBrick, proxying the response to Apache). All the other options you have, in alphabetical order: 1. Only allow people to run Rails as CGI. Personally, I would leave you in a second 2. Kill their FCGI intentionally after a certain period of time. See above 3. You might want to look if mod_fcgid has dynamic spawning (so that when FCGIs are killed it loads the new ones). mod_fcgi has this feature, but it doesn''t work - it is capable of spawning up to 50 Rails processes no matter what settings you apply and it never actually gets them shut down. 4. I think there ought to be a way to restart FCGI dispatchers separately from the server who forked them (but I am not sure). The thing is - Rails has to be persistent, in the sense that you cannot be as safe with it as with PHP (be sure that you reload everything of the user''s on request and get rid of it when it''s done). You can read what I wrote about it on TextDrive forum, but I would advise you - if you don''t trust your users, don''t give them false expectations. I ran into severe limits on one of the hosts who wrote me that I can run rails - but in the end they lost customers because they were inhonest (what they did was forced caching and killing of my server process every 4 minutes). -- Julian "Julik" Tarkhanov
Hey Bart- The best way IMHO to let users run rails apps in a shared hosting environment is to let each user run an instance of lighttpd/ fcgi that gets proxied from apache. Lighttpd is very lightweight as far as cpu and memory resources go so this is usually the best approach. This way rails users can restart there instance of lighttpd without restarting apache and bothering other users. Here is a vhost example for apache 1.3 to proxy to lighttpd on a higher port: <VirtualHost example.com> ServerName example.com ServerAlias www.example.com ProxyPass / http://example.com:8001/ ProxyPassReverse / http://example.com:8001/ </VirtualHost> If you set it up like this then the users just use lighttpd or even webrick if they want(although this is more resource intensive). Let me know and I can give you some sample lighttpd conf files if you need them. Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org On Oct 11, 2005, at 11:46 PM, Bart Braem wrote:> Yesterday I installed my very first Rails application on an Apache > server. I > had to change the mysql socket path and to apply to those setting I > had to > let Apache be restarted. > Is that always necessary? I would like to run Rails in a shared > environment > so I can''t have regular users restart Apache. How is that done at > hosting > companies? Are there any practical solutions? > > Thanks for a great product! > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
jonasb.12671723-opCBI309nnGakBO8gow8eQ@public.gmane.org
2005-Oct-12 16:47 UTC
Re: Restarting the webserver to apply settings
If you go for a ProxyPass solution it''s probably a good idea to use IP addresses instead of hostname due to performance issues (http://kb.textdrive.com/article/why-is-my-lighttpd-fastcgi-so-slow). Regards, Jonas Bengtsson (jonas.b-7XRkppT4KCs@public.gmane.org) --- rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org wrote: Hey Bart-> The best way IMHO to let users run rails apps ina shared> hosting environment is to let each user run an instance of lighttpd/> fcgi that gets proxied from apache. Lighttpd is very lightweight as> far as cpu and memory resources go so this is usually the best > approach.This way rails users can restart there instance of lighttpd> without restartingapache and bothering other users. Here is a vhost> example for apache1.3 to proxy to lighttpd on a higher port:> > <VirtualHost example.com>> ServerName example.com > ServerAlias www.example.com >ProxyPass / http://example.com:8001/> ProxyPassReverse / http://example.com:8001/> </VirtualHost> > > If you set it up like this then the users justuse lighttpd or> even webrick if they want(although this is more resourceintensive).> Let me know and I can give you some sample lighttpd conffiles if you> need them. > > Cheers- > > -Ezra Zygmuntowicz > YakimaHerald-Republic> WebMaster > http://yakimaherald.com > 509-577-7732 >ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org
Thats definitely true. I should have mentioned that as well but I just put the example.com instead of the IP I have in my actual conf file. The dns lookups required if you use names instead of IP''s will slow things down a bit. Good advice Jonas. -Ezra On Oct 12, 2005, at 9:47 AM, jonasb.12671723-opCBI309nnGakBO8gow8eQ@public.gmane.org wrote:> If you go for a ProxyPass solution it''s probably a good idea to use > IP addresses > instead of hostname due to performance issues (http:// > kb.textdrive.com/article/why-is-my-lighttpd-fastcgi-so-slow). > > > Regards, > Jonas Bengtsson (jonas.b-7XRkppT4KCs@public.gmane.org) > > --- rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > wrote: > Hey Bart- > >> The best way IMHO to let users run rails apps in >> > a shared > >> hosting environment is to let each user run an instance of lighttpd/ >> > > >> fcgi that gets proxied from apache. Lighttpd is very lightweight as >> > > >> far as cpu and memory resources go so this is usually the best >> approach. >> > This way rails users can restart there instance of lighttpd > >> without restarting >> > apache and bothering other users. Here is a vhost > >> example for apache >> > 1.3 to proxy to lighttpd on a higher port: > >> >> <VirtualHost example.com> >> > > >> ServerName example.com >> ServerAlias www.example.com >> >> > ProxyPass / http://example.com:8001/ > >> ProxyPassReverse / http://example.com:8001/ >> > > >> </VirtualHost> >> >> If you set it up like this then the users just >> > use lighttpd or > >> even webrick if they want(although this is more resource >> > intensive). > >> Let me know and I can give you some sample lighttpd conf >> > files if you > >> need them. >> >> Cheers- >> >> -Ezra Zygmuntowicz >> Yakima >> > Herald-Republic > >> WebMaster >> http://yakimaherald.com >> 509-577-7732 >> >> > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org
Bart Braem wrote:> Yesterday I installed my very first Rails application on an Apache server. > I had to change the mysql socket path and to apply to those setting I had > to let Apache be restarted. > Is that always necessary? I would like to run Rails in a shared > environment so I can''t have regular users restart Apache. How is that done > at hosting companies? Are there any practical solutions? >(Just answering myself because I''d like to answer both responses) Thanks a lot for the information, I didn''t know of that requirement. The system I''d like to run is not commercial and I know the users pretty much but restarting Apache seems over the top. So I''d love a solution with Lighttpd. But... Currently the FastCGI setup makes Rails very dynamic, every new user can run Rails without manual intervention from the sysadmin. And I''d like to keep it that way, is that possible? Can I have Lighttpd instances started automatically for Rails code? Another question: is it possible to use Lighttpd without Virtual Hosts? I have different users who don''t have their proper domains, just their proper home pages, so perhaps virtual hosts are a bit too much? Greetings