Unable to set up Rails app by Apache on Mac OS X 10.9.3

Hi,

I just upgrade a few apps from Rails 2.3.18 to Rails 4.0.4 and make sure
the apps are running on WEBrick. I follow the steps I have done to set
up
apps by Apache on Snow Leopard, first install passenger and add the
following to /etc/apache2/httpd.conf

LoadModule passenger_module
/usr/local/opt/passenger/libexec/buildout/apache2/mod_passenger.so

PassengerRoot
/usr/local/opt/passenger/libexec/lib/phusion_passenger/locations.ini

PassengerDefaultRuby /usr/bin/ruby
then try to add RailsBaseURI /most (most is my rail project) in the
.conf
inside /etc/apache2/sites/,
but no .conf file there anymore for Mac Marvericks, rather I find the
.conf
in folder
/Library/Server/Web/Config/apache2/sites, so I add the “RailsBaseURI
/most”
in the
file

Then I add a symlink as following:

ln -s /Library/WebServer/most/public /Library/WebServer/Documents/most

sudo apachectl stop
sudo apachectl start

Page http://localhost/most is like following:

Index of /most

Apache/2.2.26 (Unix) Phusion_Passenger/4.0.41 mod_ssl/2.2.26
OpenSSL/0.9.8y
DAV/2 mod_wsgi/3.3 Python/2.7.5 Server at localhost Port 80
and couldn’t display http://localhost/most/rannumgenerator/index
(rannumgenerator is controller I generated in most project).

Wonder if something that I should do for Mac Mavericks or some setting
for
Apache that I am not aware?

Thanks!
Liz H.

i used to go through this kind of drama, then one day someone told about
heroku.

-Sam

and couldn’t display http://localhost/most/rannumgenerator/index
(rannumgenerator is controller I generated in most project).

Wonder if something that I should do for Mac Mavericks or some setting for
Apache that I am not aware?

You may need to look in your error log (probably in /var/log/apache2/)
for
more details on what happened to Passenger. Also, I’ve never tried
accessing Rails projects under a subdirectory like that, you may need to
see if you need to set up something specifically to handle that.

I set my system up quite a bit differently to easier support working on
different projects. First, since Mac OS updates can overwrite
http.conf, I
put my custom config in the /etc/apache2/other/ directory, broken up
into
separate files. So, I have a passenger.conf file and a vhosts.conf
file.
I create entries in /etc/hosts to set up local domain names for my
various
projects. So I end up with something like this:

/etc/hosts:
127.0.0.1 my.greatproject.local

/etc/apache2/other/passenger.conf:

LoadModule passenger_module
/Users/jcrate/.rvm/gems/ruby-2.1.2@global/gems/passenger-4.0.45/buildout/apache2/mod_passenger.so

PassengerRoot
/Users/jcrate/.rvm/gems/ruby-2.1.2@global/gems/passenger-4.0.45
PassengerDefaultRuby
/Users/jcrate/.rvm/gems/ruby-2.1.2@global/wrappers/ruby

/etc/apache2/other/vhosts.conf:

<VirtualHost *:80>
ServerName my.greatproject.local
DocumentRoot /path/to/project/public

RackEnv development

PassengerRuby 

/Users/jcrate/.rvm/gems/ruby-2.1.2@myproject/wrappers/ruby

If you’re not using RVM, then your passenger-related paths will look a
little different. However, if you have more than one Rails project, you
probably want to be using RVM or some sort of ruby version manager.

Thanks! I will check heroku.

Liz

Thanks! I will try and see if I can figure it out, I use rbenv to manage
ruby versions.

Best,
Liz

I checked error log in apache2 folder, it is empty. I wonder if it is
related to permission for folders or files as I
am not using root, but admin account to develop rails projects.

Liz

Hi, Jim:

I followed your advice, still couldn’t get my site running. Do you set
up
your rails project in
Mac OSX Mavericks? It seems from its instruction,
/etc/apache2/httpd.conf
is
/Library/Server/Web/Config/apache2/httpd_server_app.conf
Wonder anyone here has luck setting up rails app in Mac OSX Mavericks.

Thanks!
Liz

On Mon, Jun 23, 2014 at 8:20 AM, Liz H. [email protected] wrote:

I just upgrade a few apps from Rails 2.3.18 to Rails 4.0.4 and make sure
the apps are running on WEBrick. I follow the steps I have done to set up
apps by Apache on Snow Leopard, first install passenger and add the
following to /etc/apache2/httpd.conf

Why?

If your goal is to sanity-check the app on httpd/Passenger because
that’s your production setup, you’d be far better off replicating that
prod environment in a VM and testing there.

FWIW,

Hassan S. ------------------------ [email protected]

twitter: @hassan

On Jun 27, 2014, at 1:45 PM, Liz H. [email protected] wrote:

Wonder anyone here has luck setting up rails app in Mac OSX Mavericks.

Yes, but I don’t use the built-in apache and its configs. Honestly, if
you want readily available help, probably best to turn off the “personal
web sharing” and install & configure your own web server, in the
“standard” unix-y location. I expect that would be easier than starting
with Apple’s built-in Apache config, which is configured for VERY basic
personal use and then try to figure out to tweak their config. Also, if
you install your own, it’s less likely that OS updates will fubar your
config and force you to go exploring again trying to figure out what to
fix.

I personally just the built-in (to rails that is) service for
development, then use nginx + unicorn for deployment.


Scott R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice

I followed your advice, still couldn’t get my site running. Do you set up
your rails project in
Mac OSX Mavericks? It seems from its instruction, /etc/apache2/httpd.conf
is
/Library/Server/Web/Config/apache2/httpd_server_app.conf

Are you using Server.app? If so, then things are somewhat different.
In
fact, looking back at your original message I see you mentioned a
Server-specific path.

You would want to put your passenger.conf file in
/Library/Server/Web/Config/apache2/other/.

You can still edit your /etc/hosts file to include a local domain for
your
project, which will make things easier. You would then set up a new
website in Server.app, using the domain you set up /etc/hosts for your
project, and tell it site files are stored in the public folder of your
rails project. I use RVM, so I have to edit the config file Server.app
generates to add

PassengerRuby /usr/local/rvm/gems/ruby-2.1.2@my_gemset/wrappers/ruby

You can run this command from your rails project directory to see what
you
should be using for PassengerRuby:

passenger-config --ruby-command

If you want to run your rails app in development mode, you’ll also need
to
add

RackEnv development

to your site config file. Your site config file will be in:

/Library/Server/Web/Config/apache2/sites/

and will be named something like:

0000_any_80_my.project.domain.conf

Your passenger installation doesn’t necessarily need to be done via
rbenv,
it will be just fine installed with the system ruby. However, you will
need the PassengerRuby directive so it knows where to find the ruby and
gem
set to use when it instantiates your project.

Jim

On Jun 28, 2014, at 7:20 AM, Jim [email protected] wrote:

In fact, the reason I started using the built-in apache was because I got tired
of MacPorts blowing away all my config files seemingly at random.

Ugh, shudder, no, I NEVER use MacPorts. If configure/make/install
won’t get the job done, I seriously reconsider whether I need it. (I’ve
only give up once, forget what it was, but the rat’s nest of
dependencies was too much to sort. But PostgreSQL, nginx, pgbouncer,
libevent, ghostscript, are all pretty easy…)


Scott R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice

On Friday, June 27, 2014 4:04:02 PM UTC-4, Scott R. wrote:

Yes, but I don’t use the built-in apache and its configs. Honestly, if you
want readily available help, probably best to turn off the “personal web
sharing” and install & configure your own web server, in the “standard”
unix-y location. I expect that would be easier than starting with Apple’s
built-in Apache config, which is configured for VERY basic personal use and
then try to figure out to tweak their config. Also, if you install your
own, it’s less likely that OS updates will fubar your config and force you
to go exploring again trying to figure out what to fix.

Actually, the default Mac OS X installation of apache is pretty standard
(in a BSD sense). The config files live in /etc/apache2/, and *.conf
files
in /etc/apache2/other/ are loaded by default. My config files haven’t
been
touched even when upgrading from 10.8 to 10.9. It’s a little more
tricky
if you need PHP too, but it’s still not difficult to add modules to the
built-in php.

In fact, the reason I started using the built-in apache was because I
got
tired of MacPorts blowing away all my config files seemingly at random.

Jim

On Saturday, June 28, 2014 9:54:15 AM UTC-4, Scott R. wrote:

On Jun 28, 2014, at 7:20 AM, Jim <[email protected] <javascript:>> wrote:

In fact, the reason I started using the built-in apache was because I
got tired of MacPorts blowing away all my config files seemingly at random.

Ugh, shudder, no, I NEVER use MacPorts.

I got rid of MacPorts in the early days of Homebrew. I also used to just
configure/make/install, but ImageMagick was a real hassle, and keeping
track of my config scripts which listed all the options I wanted was
annoying as well. I’m pretty happy with Homebrew.

Jim

Server admin in snow leopard is now server.app in Mavericks?

Liying

Dear Jm:

Thanks a lot for your reply!

Yes, server.app comes with Mavericks, so I use it to host Rails web apps
and have tried to create
passenger.conf under other folder etc. I set up everything in snow
leopard
under directory “/etc/apache2”,
and sites folder was also inside /etc/apache2, it is quite
straightfoward
and easy, but when I try
to do the samething with server.app under folder
/Library/Server/Web/Config/apache2. I couldn’t
make it work, the steps seem to be quite simple, but not easy to find
out
what might go wrong.

I used brew to install passenger.

Liz

On Monday, June 30, 2014 4:07:41 PM UTC-4, Liz H. wrote:

I used brew to install passenger.

The config file used for the web server in Mavericks Server
is httpd_server_app.conf. You may want to look in that file and make
sure
the line below exists and is not commented out. It should be near the
end
of the file.

Include /Library/Server/Web/Config/apache2/other/*.conf

I have never installed passenger with brew, only using ruby-gems either
in
the system ruby, or nowadays in RVM environments. So, I’m not sure of
any
differences there may be installing it with brew, but I don’t think
there
is any reason why it shouldn’t work.

It can be tricky to find out exactly what is going wrong. If you are
still just getting the public directory listing when you load the site
in
your browser, then Passenger most likely has not been activated, which
means there is some issue with your apache config. If Passenger is
loading
and you don’t have the PassengerRuby environment set up in your site
config
file properly, then you should get an error that Passenger can’t start
the
web app.

If Passenger isn’t loading at all, then check /var/log/apache2/error_log
when you start your web server, and see what it says. It should have
some
info about the startup process, and if Passenger is loading it should be
mentioned. If passenger is not mentioned, you can see if your
passenger.conf file is getting loaded by changing the “LoadModule
passenger_module” directive to have an incorrect path. When I do that,
apache silently fails to start (i.e. nothing in the access or error
logs).

Jim Crate

Great, it seems that I got further, now I got error message

It looks like Bundler could not find a gem. Maybe you didn’t install all
the gems that this application needs. To install your gems, please run:

bundle install

I did “bundle install” after I create the rails project, I did “gem
uninstall passenger”
afterwards as the developer of passenger told me that I installed
passenger by homebrew, I don’t
need gem install passenger, o.w. I would have trouble…

Liz

Thanks so much! I will carefully follow all your advice to see if I can
get
it work…

Best,
Liz

The problem was caused that line

PassengerRuby pathForRuby

got wiped out in file httpd_server_app.conf after I recreate the
websites.

Now I got this error message, didn’t find the fix…

integer 4294967294 too big to convert to int' (RangeError) /usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:724:inchown’
/usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:724:in
block in remove_entry_secure' /usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:718:inopen’
/usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:718:in
remove_entry_secure' /usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/utils/tmpio.rb:72:inensure in mktmpdir’
/usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/utils/tmpio.rb:72:in
mktmpdir' /usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/native_support.rb:147:indownload_binary_and_load’
/usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/native_support.rb:49:in
start' /usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/native_support.rb:405:in<top (required)>’
/usr/local/var/rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' /usr/local/var/rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
/usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger.rb:237:in
require_passenger_lib' /usr/local/Cellar/passenger/4.0.45/libexec/helper-scripts/rack-preloader.rb:75:ininit_passenger’
/usr/local/Cellar/passenger/4.0.45/libexec/helper-scripts/rack-preloader.rb:157:in
<module:App>' /usr/local/Cellar/passenger/4.0.45/libexec/helper-scripts/rack-preloader.rb:29:inmodule:PhusionPassenger
/usr/local/Cellar/passenger/4.0.45/libexec/helper-scripts/rack-preloader.rb:28:in
`’

Application root/Library/WebServer/mostEnvironment (value of RAILS_ENV,
RACK_ENV, WSGI_ENV, NODE_ENV and PASSENGER_APP_ENV)developmentRuby
interpreter command

/usr/local/var/rbenv/versions/2.1.0/bin/ruby

User and groups

uid=4294967294(nobody) gid=4294967294(nobody)
groups=4294967294(nobody),12(everyone),61(localaccounts),

404(com.apple.sharepoint.group.4),403(com.apple.sharepoint.group.3),100(_lpoperator),401(com.apple.sharepoint.group.1),

402(com.apple.sharepoint.group.2)

Yes, I did add that line in the .conf file inside sites folder and also
add
RackEnv development

above PassengerRuby directive as below:

ServerName ... ServerAdmin [email protected] DocumentRoot "/Library/WebServer/most/public" DirectoryIndex index.html index.php /wiki/ /xcode/ default.html CustomLog /var/log/apache2/access_log combinedvhost ErrorLog /var/log/apache2/error_log SSLEngine Off SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM" SSLProtocol -ALL +SSLv3 +TLSv1 SSLProxyEngine On SSLProxyProtocol -ALL +SSLv3 +TLSv1 Options All -Indexes -ExecCGI -Includes +MultiViews AllowOverride None DAV Off Deny from all ErrorDocument 403 /customerror/websitesoff403.html RackEnv development PassengerRuby /usr/local/var/rbenv/versions/2.1.0/bin/ruby

the error I got now seem to be something different…

integer 4294967294 too big to convert to int' (RangeError) /usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:724:inchown’
/usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:724:in
block in remove_entry_secure' /usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:718:inopen’
/usr/local/var/rbenv/versions/2.1.0/lib/ruby/2.1.0/fileutils.rb:718:in
remove_entry_secure' /usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/utils/tmpio.rb:72:inensure in mktmpdir’
/usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/utils/tmpio.rb:72:in
`mktmpdir’
/usr/local/Cellar/passenger/4.0.45/libexec/lib/phusion_passenger/native_support.rb:147:in

User and groups

uid=4294967294(nobody) gid=4294967294(nobody)
groups=4294967294(nobody),12(everyone),61(localaccounts),

404(com.apple.sharepoint.group.4),403(com.apple.sharepoint.group.3),100(_lpoperator),

401(com.apple.sharepoint.group.1),402(com.apple.sharepoint.group.2)

Environment variables