I have a webserver that''s happily running apache2 and PHP. I''d like to deploy a site that I wrote using RoR on that same server but read that there might be some conflicts with PHP and RoR trying to access the same MySQL database. How real are those conflicts? Could I mess up my running PHP site if I install mod_ruby and try to use Apache2? Would I be better off installing lighttpd and running it and apache2 at the same time? (Is that even possible?) -- Posted via http://www.ruby-forum.com/.
On 4-dec-2005, at 22:12, viniosity wrote:> I have a webserver that''s happily running apache2 and PHP. I''d > like to > deploy a site that I wrote using RoR on that same server but read that > there might be some conflicts with PHP and RoR trying to access the > same > MySQL database. > > How real are those conflicts? Could I mess up my running PHP site > if I > install mod_ruby and try to use Apache2? > > Would I be better off installing lighttpd and running it and > apache2 at > the same time? (Is that even possible?)I wasn''t able to get PHP and mod_ruby working with MySQL on the same Apache instance. Even when I compiled both of them myself. PHP had access to MySQL but Ruby didn''t. When I removed mod_php from the list of modules Ruby can get to the database easily. Running lighttpd proxied by Apache works reasonably well. -- Julian ''Julik'' Tarkhanov me at julik.nl
I recently took a site running apache2/mod_php and converted it to running lighttpd/fastcgi. Fastcgi is now driving both a (legacy) PHP application and an RoR application, and RoR is connecting to the legacy app''s MySQL instance without issues. I too was hesitant to migrate a functioning apache2/mod_php application to lighttpd but it wasn''t that difficult. The hardest part was finding good docs and examples for the lighttpd.conf file. Once I had the config file ironed out everything went very smoothly. The site has been online for about six weeks now without any problems. Lighttpd only implements a small subset of apache2''s features, but IMO if everything you need is covered by lighttpd, it is a better choice than the apache2 + proxy + lighttpd solution. If anyone is interested I''ll post my lighttpd.conf file here. viniosity wrote:> I have a webserver that''s happily running apache2 and PHP. I''d like to > deploy a site that I wrote using RoR on that same server but read that > there might be some conflicts with PHP and RoR trying to access the same > MySQL database. > > How real are those conflicts? Could I mess up my running PHP site if I > install mod_ruby and try to use Apache2? > > Would I be better off installing lighttpd and running it and apache2 at > the same time? (Is that even possible?) >
.> > If anyone is interested I''ll post my lighttpd.conf file here.I''m definitely interested! Actually, if you have step by step instructions that would be fab. Which distro did you use? I''m currently on Debian sarge which does not have a package for lighttpd.. -- Posted via http://www.ruby-forum.com/.
viniosity wrote:> I have a webserver that''s happily running apache2 and PHP. I''d like to > deploy a site that I wrote using RoR on that same server but read that > there might be some conflicts with PHP and RoR trying to access the same > MySQL database.Here I was running Apache2 + mod_php4. I added rails sites without too much efforts using scgi. The single non-trivial point is to give a separate scgi port number to each vhost. -- Jean-Christophe Michel
> > Here I was running Apache2 + mod_php4. I added rails sites without too > much efforts using scgi. The single non-trivial point is to give a > separate scgi port number to each vhost.I would appreciate any guidance you can give. I am not familiar with scgi at all and so am not familiar with what it would take to install/configure it and/or rails on my webserver. My situation is that I have a rails app I want to deploy but only have an apache2/php4 server at my disposal. -- Posted via http://www.ruby-forum.com/.
On Dec 4, 2005, at 6:25 PM, Vince Wadhwani wrote:> >> >> Here I was running Apache2 + mod_php4. I added rails sites without >> too >> much efforts using scgi. The single non-trivial point is to give a >> separate scgi port number to each vhost. > > I would appreciate any guidance you can give. I am not familiar with > scgi at all and so am not familiar with what it would take to > install/configure it and/or rails on my webserver. > > My situation is that I have a rails app I want to deploy but only have > an apache2/php4 server at my disposal. >SCGI is definitely a nice option but I have had very good luck with lighttpd proxied behind and apache vhost. This would allow you to pretty much leave your good running apache alone and just add one vhost per rails site like this: <VirtualHost *:80> ServerName example.com ServerAlias www.example.com #ProxyPreserveHost on #<-apache2 only ProxyPass / http://example.com:8000/ ProxyPassReverse / http://example.com:8000/ </VirtualHost> Then run your rails app on fastcgi/lighttpd. This way you can connect to your db from php and ruby with no problems. This is a tried and trusted way of doing things and m any shared web hosts that offer rails support do it this way. Cheers- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Here are the important sections of my lighttpd.conf file, with some comments added. I am using Gentoo but I don''t think there is anything distro-specific here. This config was pieced together from many examples. I''d love to hear comments or suggestions if anyone has them. One caveat: Initially I had trouble getting the rails application to route properly. I traced the problem to some of the rails code referenced in this ticket/patch: http://dev.rubyonrails.org/ticket/1048 Removing the apache-specific condition in relative_url_root fixed the problem. I haven''t been able to determine if this is a problem in my setup or in rails itself. -----------------------------------------start ########################################################### ########################################################### # # lighttpd.conf file serving both PHP and Ruby on Rails # applications via fastcgi. This file is for lighttpd 1.4.7 # # saltman-459giS/99bMmp8TqCH86vg@public.gmane.org # ####################################################### # General server config, see lighttpd docs for details. var.logdir = "/var/log/lighttpd" server.modules = ( "mod_rewrite", "mod_access", "mod_auth", "mod_accesslog", "mod_fastcgi", "mod_alias" ) include "mime-types.conf" server.username = "lighttpd" server.groupname = "lighttpd" server.pid-file = "/var/run/lighttpd.pid" server.indexfiles = ("dispatch.fcgi", "index.php", "index.html", "index.htm", "default.htm") server.tag = "lighttpd" server.follow-symlink = "enable" static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi", ".rb", ".rhtml") url.access-deny = ("~", ".inc", ".conf") server.errorlog = var.logdir + "/error.log" accesslog.filename = var.logdir + "/access.log" ######################################################## # By default, display an empty website. Rules below will # override this setting. This may not be appropriate or # necessary for all sites. server.document-root = "/var/www/empty" ######################################################## # A common directory for all web roots (optional). alias.url = ("/common/" => "/var/www/common/") ############################################################ # Main configuration. In this config, the root of the web # site hosts a legacy PHP application (http://the-site.com) # while an RoR application is available beneath the root at # http://the-site.com/rorapp $HTTP["host"] =~ "the-site.com" { # Root of the php application. server.document-root = "/var/www/phpapp" # Rewrite all requests to /rorapp to use dispatch.fcgi, except # static content. The rails app is in /var/www/rorapp. There is # a symlink from /var/www/phpapp/rorapp -> /var/www/rorapp/public. url.rewrite = ("^/rorapp/stylesheets/(.+)" => "/rorapp/stylesheets/$1", "^/rorapp/images/(.+)" => "/rorapp/images/$1", "^/rorapp/javascripts/(.+)" => "/rorapp/javascripts/$1", "^/rorapp/(.*)$" => "/rorapp/dispatch.fcgi") # Fastcgi configuration. The PHP application is spawned externally # via spawn-fcgi, while the RoR application is spawned and monitored # using the rails command script/process/spinner. # PHP must be compiled with fastcgi support. PHP/spawn-fcgi will # handle multiple processes internally, you only need to specify # the base port number here. See the spawn-fcgi docs for more info. # For the rails app, you need to specify each port spawned by # the spinner/spawner. This example uses three handlers. You may # need to install the fcgi ruby gem as well. fastcgi.server = ( ".php" => ( "localhost" => ( "host" => "127.0.0.1", "port" => 1200 ) ), ".fcgi" => ( "localhost" => ( "host" => "127.0.0.1", "port" => 1220 ), ( "host" => "127.0.0.1", "port" => 1221 ), ( "host" => "127.0.0.1", "port" => 1222 ) ) ) } ################################################ # SSL (optional). Specify the IP address of your # external interface here. $SERVER["socket"] == "172.16.0.1:443" { ssl.engine = "enable" ssl.pemfile = "/etc/lighttpd/ssl/the-site.com.pem" ssl.ca-file = "/etc/lighttpd/ssl/the-site.com.ca" } ########################################################### # Another web root is specified here. In my implementation # I have several of these serving different sites. This # is optional of course. $HTTP["host"] =~ "another-site.com" { ssl.engine = "disable" server.document-root = "/var/www/another-site" } ---------------------------------------------end viniosity <vince71-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> . >> >> If anyone is interested I''ll post my lighttpd.conf file here. > > I''m definitely interested! Actually, if you have step by step > instructions that would be fab. Which distro did you use? I''m > currently on Debian sarge which does not have a package for lighttpd.. >
Vince Wadhwani wrote:> My situation is that I have a rails app I want to deploy but only have > an apache2/php4 server at my disposal.Same here ;-)> I would appreciate any guidance you can give. I am not familiar with > scgi at all and so am not familiar with what it would take to > install/configure it and/or rails on my webserver.I first became familiar with scgi (er... simply I installed mod_scgi and scgi_rails on the dev box, read all the docs that Zed wrote and made some trys). Then some days later I made the same on the production box. -- Jean-Christophe Michel
jc.michel wrote:> I first became familiar with scgi (er... simply I installed mod_scgi and > scgi_rails on the dev box, read all the docs that Zed wrote and made > some trys). Then some days later I made the same on the production box.I think I''m getting close. When I resolve my URL for the rails app instead of displaying index.html (Congratlations you''re on rails) it gives me the 404.html. Does this mean that rails isn''t configured? I look at my Apache2 tag line for the non-rails app: Apache/2.0.54 (Debian GNU/Linux) PHP/4.4.0-4 mod_scgi/1.7 Server at 192.168.1.5 Port 80 So it looks like I have both scgi and php loaded... what am I missing? -- Posted via http://www.ruby-forum.com/.
Ok, I tried and tried and completely failed to get this working. In a moment of complete frustration I erased my box and started from scratch. This time with Ubuntu instead of Debian. Step 1: Get Rails working. Step 2. Get PHP working. Thanks to this fantastic tutorial I was able to accomplish Step 1. http://fo64.com/articles/2005/10/20/rails-on-breezy Now can anyone help me get my PHP sites back up? I assume I have to disable FastCGI for the particular site in Apache2''s sites-enabled and sites-available conf files but that''s just me guessing.. -- Posted via http://www.ruby-forum.com/.