My Rails site used to work, but after starting over after doing an OS upgrade, it is now showing only the index of / with the contents of the rails app's public directory.
My PHP site is working fine, so this must be a configuration issue. I have looked at this problem for a long time, so I'm at a loss here. I really appreciate your help.
I followed the instructions on http://library.linode.com/frameworks/ruby-on-rails-apache/ubuntu-10.04-lucid as before.
I have the following setup in /etc/apache2/sites-availabe/mydomain.com:
<VirtualHost ip:80>
ServerName mydomain.com
DocumentRoot /srv/www/mydomain.com/app/public/
ServerAlias www.mydomain.com
ErrorLog /srv/www/mydomain.com/log/error.log
CustomLog /srv/www/mydomain.com/log/access.log combined
</VirtualHost>
My app is under /srv/www/mydomain.com/app/.
What is wrong here? This used to work before migration.
The app is on ubuntu 10.4.
I had many troubles starting out with vHosts.
This little quick guide may help.
$ gem install passenger
$ passenger-install-apache2-module
Follow the screen instructions.
Edit your current vHost configuration.
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "/srv/www/mydomain.com/app/public/"
<Directory "/srv/www/mydomain.com/app/public/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Restart your Apache server.
$ sudo apache graceful
Add the following to the end of your /etc/hosts file in your favorite editor.
127.0.0.1 mydomain.com www.mydomain.com
Test your domain.
$ ping mydomain.com
You should see something like
PING mydomain.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.035 ms
Now you should be able to go into your favorite browser and navigate to mydomain.com and see your application instance.
For future readers, I found the answer here:
https://help.ubuntu.com/community/RubyOnRails#Installing%20rails
I had passenger gem installed.
What was missing was:
sudo apt-get install apache2-dev libapr1-dev libaprutil1-dev
Enable the passenger simply by typing:
a2enmod passenger
Then restart apache. Voila!
By the sounds of it you need to install Phusion Passenger?
If you need any help check out Dan Benjamin's guide.
When you upgraded the OS, you also upgraded Apache. If you were using Passenger, you probably installed it by having it compiled it manually, so that got lost in the process of the upgrade. You may need to re-run through the installation of Passenger again.
Related
I am attempting to get a Rails development environment up using a CentOS virtual machine. It will run Apache with Phusion Passenger, and I will access it from the host OS by entering the VM's LAN IP (eg 192.168.0.5).
I have been able to run Rails apps perfectly using WEBrick, and I have been able to serve static pages and PHP perfectly from Apache. But getting Passenger set up is proving to be a baffling nightmare of endless problems for me, and I would absolutely love some help from someone who knows what they're doing here.
So here's what I've done.
Booted into a fresh CentOS 6.3 machine. Using yum, installed httpd (Apache 2.2), sqlite-devel, all the other good stuff you need.
Installed RVM (to /home/vagrant/.rvm/), and Ruby 2.1.2, which I can confirm is working perfectly.
Installed Passenger with rvmsudo passenger-install-apache2-module.
Added the following to my httpd.conf.
.
LoadModule passenger_module /home/vagrant/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.45/buildout/apache2/mod_passenger.so
<IfModule module_passenger.c>
PassengerRoot /home/vagrant/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.45
PassengerDefaultRuby /home/vagrant/.rvm/gems/ruby-2.1.2/wrappers/ruby
</IfModule>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/dangerzone/public
<Directory /var/www/html/dangerzone/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
Finally, in /var/www/html, I executed rails new dangerzone to create the app.
Initially, trying to access my app gave me a Passenger error 'no JS runtime', which thrilled me because I'd spent 5 or so hours trying to get Passenger recognised at all. I installed Node-JS through Yum, and my current error is a 500, Internal server error.
I see nothing in /etc/httpd/logs/error_log.
I've followed the instructions on the RVM and Passenger websites to a letter. I've Googled this problem until I'd read the entire top 30 results. I've wiped the VM and started from scratch in case I did something wrong -- same problem. So I'm kind of baffled. Have I screwed up something really obvious?
I'm trying to deploy my first rails app on a mediatemple (dv) and i'm not having any luck.
I'm trying to use phusion passenger so i went over to http://www.modrails.com/videos/passenger.mov and watched the tutorial on installing this. I did everything with no issues and I'm when i point to my ip, i see an apache page and not my rails app.
I noticed that on mediatemple, I had to create a vhosts.conf file and run a command to reconfigure my project to look at this vhosts.conf file. Reference - http://kb.mediatemple.net/questions/1621/Why+is+my+vhost+file+not+being+used+by+Apache%3F#dv_40 For the last step I did /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx instead of reconfigure all.
Here's what my vhosts.conf file looks like:
LoadModule passenger_module
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby
<VirtualHost *:80>
ServerName xxx.xx.xx.xx
DocumentRoot /var/www/vhosts/myProject/httpdocs # <-- be sure to point
to 'public'!
<Directory /var/www/vhosts/myProject/httpdocs>
AllowOverride all # <-- relax Apache security settings
Options -MultiViews # <-- MultiViews must be turned off
</Directory>
</VirtualHost>
Anybody have any luck deploying a rails app on a mt (dv) that can shed some advice to a rails noob?
I've just go this done on my dv server so here is a quick walk through. I will assume that you are working with Ruby 1.9.3 and Rails 3.2, and running all of the commands below as root.
You also have the latest version of rake and passenger install on your server. If not, try:
gem update --system
gem install rake
gem install passenger
Next step is to login to your MediaTemple admin panel. Click on the Admin button (not the Plesk one) for the domain you are interested and choose "Root Access and Developer Tools" option. Install the developer tools (this will take about 10mins).
Once that's done, ssh into your server and do the following:
passenger-install-apache2-module
There is a pretty good guided installation so I won't go into details here. You may need to install some additional dependencies here via yum so check the output of this script carefully.
Once that's out of the way, go and edit your httpd.conf file. This is saved under /etc/httpd/conf/httpd.conf. You will want to add the following lines to the end of it (please note the paths may vary as I am using rvm to manage my ruby installations and gemsets).
# Passenger Module for Apache (For Rails apps)
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125#rails32/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125#rails32/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125#rails32/ruby
PassengerDefaultUser root
At this point you should be ready to create a new rails app so remove everything from your httpdocs folder and issue the following command while logged in as the domain user (not root!)
rails new /path/to/httpdocs
Edit your vhost.conf file (or create a new one) in /var/www/vhosts/www.domain.com/conf (you will need to do this as root).
ServerName domainname.com
ServerAlias domainname.com
DocumentRoot /var/www/vhosts/domainname.com/httpdocs/public
<Directory "/var/www/vhosts/domainname.com/httpdocs/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RailsEnv development
RailsBaseURI /
And finally, issue
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain xxx.xx.xx.xx
And restart apache
/usr/sbin/apachectl -k restart
That should be it!
This link really helped me with the whole thing: http://www.twohard.com/blog/setting-rails-passenger-mediatemple-dv35-servers
What's the easiest way to point domain.com to my RoR app? When I don't include the port, ie domain.com:3000 it lists the directory.
If you are using apache, you need to use a rails mod to get it working. The best one is Phusion Passenger. It is very easy to set up, follow their directions, set up your virtual host and you'll be on your way. Again, apache cannot serve rails apps without extra additions.
It sounds like you are getting the mongrel/webrick servers that you run with ruby script/server or rails server confused with apache. In production don't even bother with webrick or mongrel if you've got apache running. Install Passenger. Then its easy, just go to your conf file and add your VirtualHost.
<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /webapps/mysite/public
<Directory /webapps/mysite/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
I have been struggling to get passenger to run my Rails/Rack apps.
Steps I used (as root):
Clean Debian 6 installation
aptitude install apache2, (Ruby
requirements taken from RVM),
git-core, curl, (and some more
packages too I guess)
getting rvm installed (system wide)
installing ruby 1.9.2-p180, and
setting it to be used as default
installing passenger gem, and
running the apache2 module
installation (getting apache2
prequisites along the way)
creating
/etc/apache2/mods-available/passenger.load
and placing:
LoadModule
passenger_module ... (the one
printed after apache2 passenger
module got installed)
creating
/etc/apache2/mods-available/passenger.conf
and placing:
PassengerRuby ...
PassengerRoot ... (the ones printed after apache2
passenger module got installed)
ap2enmod passenger (and getting apache restarted afterwards)
mkdir /var/www
setting /var/www to be user: root, group: www-data
creating /var/www/testapp and copying my rails app there
creating /etc/apache2/sites-available/testapp and placing in there:
<VirtualHost *:80>
ServerName localhost/testapp
DocumentRoot /var/www/testapp/public
<Directory /var/www/testapp/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
ap2ensite testapp
bundle install from within /var/www/testapp
/etc/init.d/apache2 restart
After opening in the browser: localhost/testapp I can only see my rails app structure (it didnt fire the page)
I don't know what I have done wrong. It seems to be pretty much okay. I am concerned about file permissions, groups and so on, although I have no clue how should I set these up. How should permissions be structured? Apart from that, anything else that looks suspicious?
Thanks!
ServerName can't have slashes in it. Just make ServerName localhost, and go to http://localhost to visit your site.
If you need multiple websites deployed on localhost, you can do that, but you need to follow the extra steps here:
http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri
I have just restarted my apache server which is running ruby on rails. Now it isn't serving any web pages because I think that some of the Rails related services are not working.
Does anyone know how to sort this out? Any help greatly appreciated.
More info: error says "Ruby on Rails application could not be started" with Phusion Passenger on the front page.
The application was working before the restart and I have changed some javascript on one of the ruby generated html pages. No major config changes.
Are you sure you have it setup properly? If it only started failing after a restart, chances are you made a bad change to your config. Here's a sample configuration (/etc/apache2/sites-available/site):
<VirtualHost *:80>
ServerName www.site.com
DocumentRoot /var/rails/site/public
<Directory /var/rails/site/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Make sure apache has access to your app's folder. Usually, apache runs as www-data.
Guys - thanks for all of the feedback. You don't need to restart apache Web server , you just need to do following steps to restart passenger
cd /home/veriqual/r2/
touch tmp/restart.txt
Hope this helps people.