OT: Two or more Rails Apps & Apache

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

OT: Two or more Rails Apps & Apache

Ralph Shnelvar
OT: Two or more Rails Apps & Apache Hi, this is more than a little off topic but not completely so.

I have a computer dedicated as a Rails server.  I've got everything working for a single rails app.

My environment is:
Ubuntu 16.04
Rails 5.2.0
Ruby 2.3.1p112

Apache
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2018-04-18T14:53:04

Right now I'm clueless how to run two Rails apps in an Apache environment.

A Google search doesn't seem to turn up much that is useful.

Anyone know a good place to find that information or ask the question?

Ralph Shnelvar

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1158758803.20180707100859%40dos32.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Hassan Schroeder-2
On Sat, Jul 7, 2018 at 9:08 AM, Ralph Shnelvar <[hidden email]> wrote:

> Right now I'm clueless how to run two Rails apps in an Apache environment.

How are you running the one app via httpd now?

What does running two look like? Different virtual hosts? Same host
name, different URL patterns?

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yC4_GPdF_TxTuu4NLVghNJO3y9XMGCK_rukZkEbYZtT3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Ralph Shnelvar
Re: [Rails] OT: Two or more Rails Apps & Apache Hassan,

How dare you ask such cogent and intelligent questions!  :-)

I'm not sure what "different virtual hosts" means.

What I have are two domains I have purchased.  Call them
www.ThisWorks.com and www.ThisIsNewAndDoesNotWorkYet.com.

Ralph



Saturday, July 7, 2018, 10:23:13 AM, you wrote:

HS> On Sat, Jul 7, 2018 at 9:08 AM, Ralph Shnelvar <
[hidden email]> wrote:

>> Right now I'm clueless how to run two Rails apps in an Apache environment.

HS> How are you running the one app via httpd now?

HS> What does running two look like? Different virtual hosts? Same host
HS> name, different URL patterns?

HS> --
HS> Hassan Schroeder ------------------------
[hidden email]
HS> twitter: @hassan
HS> Consulting Availability : Silicon Valley or remote




Ralph

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/33823057.20180707112259%40dos32.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Hassan Schroeder-2
On Sat, Jul 7, 2018 at 10:22 AM, Ralph Shnelvar <[hidden email]> wrote:

> I'm not sure what "different virtual hosts" means.

> What I have are two domains I have purchased.  Call them www.ThisWorks.com
> and www.ThisIsNewAndDoesNotWorkYet.com.

A single Apache httpd instance listening on a single IP address can
handle multiple "virtual hosts", e.g. different domains as above.

  https://httpd.apache.org/docs/2.4/vhosts/

The question is how are you doing the current single domain? Are
you using mod_proxy to forward to an app running on e.g. Puma,
or are you using Passenger?

If the former, it's easy to have each virtual host have its own proxy
settings defined.

  https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yA4Frh5n4V7HZ2_toLa8eMQEWmSRS900%2BZtLeq_VTmpVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Ralph Shnelvar
Re: [Rails] OT: Two or more Rails Apps & Apache Hassan,

I don't think I am using anything but Apache and Rails.

How can I tell?



One of the things that is confusing me is I have a file
 /etc/apache2/sites-available/ThisWorks.com.conf

How does Apache know which *.conf file to use?

I list my /etc/apache2/sites-available/ThisWorks.com.conf file below.



Thank you for pointing me at the documentation.  I'm going through it now.

Is there a book you can point me at that goes through this stuff in much greater detail?



<VirtualHost ThisWorks.asuscomm.com:80>
       # The ServerName directive sets the request scheme, hostname and port that
       # the server uses to identify itself. This is used when creating
       # redirection URLs. In the context of virtual hosts, the ServerName
       # specifies what hostname must appear in the request's Host: header to
       # match this virtual host. For the default virtual host (this file) this
       # value is not decisive as it is used as a last resort host regardless.
       # However, you must set it for any further virtual host explicitly.
       #ServerName www.example.com

       ServerAdmin [hidden email]
       DocumentRoot /var/www/ThisWorks.com/public_html

       # ServerName /var/www/test.com/public_html
       ServerName ThisWorks.asuscomm.com.com
       ServerAlias www.ThisWorks.asuscomm.com
       ServerAlias www.ThisWorks.com
       
       # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
       # error, crit, alert, emerg.
       # It is also possible to configure the loglevel for particular
       # modules, e.g.
       #LogLevel info ssl:warn

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined

       # For most configuration files from conf-available/, which are
       # enabled or disabled at a global level, it is possible to
       # include a line for only one particular virtual host. For example the
       # following line enables the CGI configuration for this host only
       # after it has been globally disabled with "a2disconf".
       #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet



Ralph



Saturday, July 7, 2018, 11:41:24 AM, you wrote:

HS> On Sat, Jul 7, 2018 at 10:22 AM, Ralph Shnelvar <
[hidden email]> wrote:

>> I'm not sure what "different virtual hosts" means.

>> What I have are two domains I have purchased.  Call them
www.ThisWorks.com
>> and www.ThisIsNewAndDoesNotWorkYet.com.

HS> A single Apache httpd instance listening on a single IP address can
HS> handle multiple "virtual hosts", e.g. different domains as above.

HS>  
https://httpd.apache.org/docs/2.4/vhosts/

HS> The question is how are you doing the current single domain? Are
HS> you using mod_proxy to forward to an app running on e.g. Puma,
HS> or are you using Passenger?

HS> If the former, it's easy to have each virtual host have its own proxy
HS> settings defined.

HS>  
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

HS> --
HS> Hassan Schroeder ------------------------
[hidden email]
HS> twitter: @hassan
HS> Consulting Availability : Silicon Valley or remote




Ralph

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/326130307.20180707131037%40dos32.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Hassan Schroeder-2
On Sat, Jul 7, 2018 at 12:10 PM, Ralph Shnelvar <[hidden email]> wrote:

> I don't think I am using anything but Apache and Rails.
>
> How can I tell?

How do you start your app on this server? `rails s` or ... ?

> One of the things that is confusing me is I have a file
>  /etc/apache2/sites-available/ThisWorks.com.conf
>
> How does Apache know which *.conf file to use?

The VirtualHost/ServerName/ServerAlias directives -- if you tried
to access a different hostname on that same IP address it would
just show the default host (from sites-available).

> Is there a book you can point me at that goes through this stuff in much
> greater detail?

I have no idea about a book; there are probably lots of tutorials out
there. The config files are super well-commented, though, and I'd
just start there, along with the online docs.

Note: the Apache httpd is based on Rob McCool's original NCSA
server circa 1993 so it's pretty "battle-tested" and that includes the
documentation :-)

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCuZcDhLgNcS%3DEB7A-3bjvaTjt8Um1cNVCjbtph%3DLucbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Ralph Shnelvar
Re: [Rails] OT: Two or more Rails Apps & Apache Hassan,

I start Apache via ...
 sudo apache2ctl start


In terms of sites-available ... where do I find the default host?
I do see something called
 /etc/apache2/sites-available

Does Apache look at all the *.conf files? If not, how does it know which .conf file to look at?

Ralph



Saturday, July 7, 2018, 2:01:08 PM, you wrote:

HS> On Sat, Jul 7, 2018 at 12:10 PM, Ralph Shnelvar <
[hidden email]> wrote:

>> I don't think I am using anything but Apache and Rails.

>> How can I tell?

HS> How do you start your app on this server? `rails s` or ... ?

>> One of the things that is confusing me is I have a file
>>  /etc/apache2/sites-available/ThisWorks.com.conf

>> How does Apache know which *.conf file to use?

HS> The VirtualHost/ServerName/ServerAlias directives -- if you tried
HS> to access a different hostname on that same IP address it would
HS> just show the default host (from sites-available).

>> Is there a book you can point me at that goes through this stuff in much
>> greater detail?

HS> I have no idea about a book; there are probably lots of tutorials out
HS> there. The config files are super well-commented, though, and I'd
HS> just start there, along with the online docs.

HS> Note: the Apache httpd is based on Rob McCool's original NCSA
HS> server circa 1993 so it's pretty "battle-tested" and that includes the
HS> documentation :-)

HS> --
HS> Hassan Schroeder ------------------------
[hidden email]
HS> twitter: @hassan
HS> Consulting Availability : Silicon Valley or remote




Ralph

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/88697272.20180707141247%40dos32.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Hassan Schroeder-2
On Sat, Jul 7, 2018 at 1:12 PM, Ralph Shnelvar <[hidden email]> wrote:

> I start Apache via ...
>  sudo apache2ctl start

But that's not starting Rails, unless you're running it via CGI
which TBH is something I've never seen. Generally you'd be
using mod_proxy to forward requests to your Rails apps.

> In terms of sites-available ... where do I find the default host?
> I do see something called
>  /etc/apache2/sites-available

You probably have a file called ~ '000-default.conf' with the
directive <VirtualHost *:80> -- notice the lack of hostname
and the wildcard * where you'd expect a name.

> Does Apache look at all the *.conf files? If not, how does it know which
> .conf file to look at?

It loads all config at initialization and then matches the http request
Host header to the server name.

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCagovXDtZkdRuaqPrJHo1Wuct5R%3DkEJ_0rf%3DmAMyK2vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Ralph Shnelvar
Re: [Rails] OT: Two or more Rails Apps & Apache Hassan,

I am so embarrassed.  I have no idea where in all this code I start Rails.  It just seems to be running when I need it.

You are correct, I do have something called /etc/apache2/sites-available/000-default.conf

You wrote: "It loads all config at initialization"
So, to confirm, it does load all the *.conf files?

Ralph



Saturday, July 7, 2018, 3:08:28 PM, you wrote:

HS> On Sat, Jul 7, 2018 at 1:12 PM, Ralph Shnelvar <
[hidden email]> wrote:

>> I start Apache via ...
>>  sudo apache2ctl start

HS> But that's not starting Rails, unless you're running it via CGI
HS> which TBH is something I've never seen. Generally you'd be
HS> using mod_proxy to forward requests to your Rails apps.

>> In terms of sites-available ... where do I find the default host?
>> I do see something called
>>  /etc/apache2/sites-available

HS> You probably have a file called ~ '000-default.conf' with the
HS> directive <VirtualHost *:80> -- notice the lack of hostname
HS> and the wildcard * where you'd expect a name.

>> Does Apache look at all the *.conf files? If not, how does it know which
>> .conf file to look at?

HS> It loads all config at initialization and then matches the http request
HS> Host header to the server name.

HS> --
HS> Hassan Schroeder ------------------------
[hidden email]
HS> twitter: @hassan
HS> Consulting Availability : Silicon Valley or remote




Ralph

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511190613.20180707191425%40dos32.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Phil Edelbrock


On Jul 7, 2018, at 6:14 PM, Ralph Shnelvar <[hidden email]> wrote:

Re: [Rails] OT: Two or more Rails Apps & Apache
Hassan,

I am so embarrassed.  I have no idea where in all this code I start Rails.  It just seems to be running when I need it.

You are correct, I do have something called /etc/apache2/sites-available/000-default.conf

You wrote: "It loads all config at initialization"
So, to confirm, it does load all the *.conf files?

Ralph



Saturday, July 7, 2018, 3:08:28 PM, you wrote:

HS> On Sat, Jul 7, 2018 at 1:12 PM, Ralph Shnelvar <
[hidden email]> wrote:

>> I start Apache via ...
>>  sudo apache2ctl start

HS> But that's not starting Rails, unless you're running it via CGI
HS> which TBH is something I've never seen. Generally you'd be
HS> using mod_proxy to forward requests to your Rails apps.

>> In terms of sites-available ... where do I find the default host?
>> I do see something called
>>  /etc/apache2/sites-available

HS> You probably have a file called ~ '000-default.conf' with the
HS> directive <VirtualHost *:80> -- notice the lack of hostname
HS> and the wildcard * where you'd expect a name.

>> Does Apache look at all the *.conf files? If not, how does it know which
>> .conf file to look at?

HS> It loads all config at initialization and then matches the http request
HS> Host header to the server name.

HS> --
HS> Hassan Schroeder ------------------------
[hidden email]
HS> twitter: @hassan
HS> Consulting Availability : Silicon Valley or remote




Ralph


I use Passenger as the glue between Apache and Rails apps, pretty easy to install and configure.  The free version is often just fine for most.  You can have multiple Rails apps running in different environments (including multiple Ruby installs) if you needed to.  I found it pretty solid.

Info:


Or just 'gem install passenger' for the free version:


Good luck!


Phil




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9090E8AA-35DB-4A57-8370-F2AC4C6184C6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: OT: Two or more Rails Apps & Apache

Brandon McClelland
I also use Passenger to manage a Rails app with Apache server. There is a great tutorial put out by Digital Ocean on getting it to  work: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04 pay close attention to the section on adding a new .conf file to your site-available folder for Apache.

On Sat, Jul 7, 2018 at 8:31 PM Phil Edelbrock <[hidden email]> wrote:


On Jul 7, 2018, at 6:14 PM, Ralph Shnelvar <[hidden email]> wrote:

Hassan,

I am so embarrassed.  I have no idea where in all this code I start Rails.  It just seems to be running when I need it.

You are correct, I do have something called /etc/apache2/sites-available/000-default.conf

You wrote: "It loads all config at initialization"
So, to confirm, it does load all the *.conf files?

Ralph



Saturday, July 7, 2018, 3:08:28 PM, you wrote:

HS> On Sat, Jul 7, 2018 at 1:12 PM, Ralph Shnelvar <
[hidden email]> wrote:

>> I start Apache via ...
>>  sudo apache2ctl start

HS> But that's not starting Rails, unless you're running it via CGI
HS> which TBH is something I've never seen. Generally you'd be
HS> using mod_proxy to forward requests to your Rails apps.

>> In terms of sites-available ... where do I find the default host?
>> I do see something called
>>  /etc/apache2/sites-available

HS> You probably have a file called ~ '000-default.conf' with the
HS> directive <VirtualHost *:80> -- notice the lack of hostname
HS> and the wildcard * where you'd expect a name.

>> Does Apache look at all the *.conf files? If not, how does it know which
>> .conf file to look at?

HS> It loads all config at initialization and then matches the http request
HS> Host header to the server name.

HS> --
HS> Hassan Schroeder ------------------------
[hidden email]
HS> twitter: @hassan
HS> Consulting Availability : Silicon Valley or remote




Ralph


I use Passenger as the glue between Apache and Rails apps, pretty easy to install and configure.  The free version is often just fine for most.  You can have multiple Rails apps running in different environments (including multiple Ruby installs) if you needed to.  I found it pretty solid.

Info:


Or just 'gem install passenger' for the free version:


Good luck!


Phil




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9090E8AA-35DB-4A57-8370-F2AC4C6184C6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Brandon McClelland
User Support Technician
Steve Jackson Games

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADuEqH%2BOn0BG40snwph9Hu_C%3Df%2B8oQgEvWNCxJnfFFD_nWw_Yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.