What you need:
Fedora Core 4 installed
Apache httpd 2.0.54 installed
Connection to Internet
Access to root Login (otherwise you will just end up frustrating yourself)
I am using Plesk 8.0.1 to manage my domains. So some of the configuration settings will be specific to that. But it will also work on a simple Linux Box just as well.
Now that we have established what we need, lets get cracking.
Installing Ruby, Gems and Rails:
The Ruby RPM should come by default with your Fedora Core install. So to install Ruby, simply execute the following as root:
yum install ruby yum install ruby-devel yum install rdoc yum install irb mkdir /var/www/downloads cd /var/www/downloads wget <a href="http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz">http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz</a> tar xvf rubygems-0.9.0.tgz cd rubygems-0.9.0 ruby setup.rb cd .. rm ruby* -drf gem install rails --include-dependencies
Now that you are done with Ruby, Gems and Rails, next bit is to download latest SCGI source and build the mod_scgi.so Apache module.
Firstly, you will need the Apache httpd Development stuff.
yum install httpd-devel cd /var/www/downloads wget <a href="http://www.mems-exchange.org/software/scgi/scgi-1.10.tar.gz">http://www.mems-exchange.org/software/scgi/scgi-1.10.tar.gz</a> tar xvf scgi-1.10.tar.gz cd scgi-1.10/apache2 apxs -i -c mod_scgi.c
Next, copy the mod_scgi.so file into your Apache modules directory.
After this, you will need the mod_scgi.so module to be loaded. For this, add the following to your Apache httpd.conf:
LoadModule scgi_module modules/mod_scgi.so
Before we can make use of the Apache SCGI module, we will need to install the SCGI gem.
Before that, install the following 2 gems:
cd /var/www/downloads wget <a href="http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem">http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem</a> gem install scgi_rails-0.4.3.gem
All the installations are done. Now, lets create a rails application and make it available over the internet.
rails myapp cd myapp scgi_ctrl config <provide a password for configuration>
httpd.conf VirtualHost example configuration:
<VirtualHost your-ip:80> AddDefaultCharset utf-8 ServerName <a href="http://www.yourdomain">www.yourdomain</a> DocumentRoot /your-switchtower-root/current/public ErrorDocument 500 /500.html ErrorDocument 404 /404.html # handle all requests throug SCGI SCGIMount /myapp 127.0.0.1:9999 # matches locations with a dot following at least one more characters, that is, things like *,html, *.css, *.js, which should be delivered directly from the filesystem <LocationMatch \..+$> # don't handle those with SCGI SCGIHandler Off </LocationMatch> <Directory /your-switchtower-root/current/public/> Options +FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
Your public/.htaccess file should look like:
Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /rails/dispatch.cgi/$1 [QSA,L] ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
We are now ready to show off our rails app to the world.
Start SCGI.
cd myapp nohup scgi_ctrl start &
Time to restart Apache so that the new configuration becomes available. Execute the following as root:
apachectl restart
Visit the URL of your site and you should see the welcome screen. Next, visit URL/myapp and the rails app should be available there.
I spent many sleepless frustrating nights to eventually get it all working. Hope the above configuration saves a lot of people from same amount of frustration.
FYI, the latest version of SCGI (1.11) appears to be located here – the MEMS site appears out-of-date.
Original topic at PuneRuby
Ashish Kulkarni – ashish@sapforbusiness.com
Blog
See Also:
What you need:
Fedora Core 4 installed
Apache httpd 2.0.54 installed
Connection to Internet
Access to root Login (otherwise you will just end up frustrating yourself)
I am using Plesk 8.0.1 to manage my domains. So some of the configuration settings will be specific to that. But it will also work on a simple Linux Box just as well.
Now that we have established what we need, lets get cracking.
Installing Ruby, Gems and Rails:
The Ruby RPM should come by default with your Fedora Core install. So to install Ruby, simply execute the following as root:
yum install ruby yum install ruby-devel yum install rdoc yum install irb mkdir /var/www/downloads cd /var/www/downloads wget <a href="http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz">http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz</a> tar xvf rubygems-0.9.0.tgz cd rubygems-0.9.0 ruby setup.rb cd .. rm ruby* -drf gem install rails --include-dependencies
Now that you are done with Ruby, Gems and Rails, next bit is to download latest SCGI source and build the mod_scgi.so Apache module.
Firstly, you will need the Apache httpd Development stuff.
yum install httpd-devel cd /var/www/downloads wget <a href="http://www.mems-exchange.org/software/scgi/scgi-1.10.tar.gz">http://www.mems-exchange.org/software/scgi/scgi-1.10.tar.gz</a> tar xvf scgi-1.10.tar.gz cd scgi-1.10/apache2 apxs -i -c mod_scgi.c
Next, copy the mod_scgi.so file into your Apache modules directory.
After this, you will need the mod_scgi.so module to be loaded. For this, add the following to your Apache httpd.conf:
LoadModule scgi_module modules/mod_scgi.so
Before we can make use of the Apache SCGI module, we will need to install the SCGI gem.
Before that, install the following 2 gems:
cd /var/www/downloads wget <a href="http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem">http://www.zedshaw.com/downloads/scgi_rails/scgi_rails-0.4.3.gem</a> gem install scgi_rails-0.4.3.gem
All the installations are done. Now, lets create a rails application and make it available over the internet.
rails myapp cd myapp scgi_ctrl config <provide a password for configuration>
httpd.conf VirtualHost example configuration:
<VirtualHost your-ip:80> AddDefaultCharset utf-8 ServerName <a href="http://www.yourdomain">www.yourdomain</a> DocumentRoot /your-switchtower-root/current/public ErrorDocument 500 /500.html ErrorDocument 404 /404.html # handle all requests throug SCGI SCGIMount /myapp 127.0.0.1:9999 # matches locations with a dot following at least one more characters, that is, things like *,html, *.css, *.js, which should be delivered directly from the filesystem <LocationMatch \..+$> # don't handle those with SCGI SCGIHandler Off </LocationMatch> <Directory /your-switchtower-root/current/public/> Options +FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
Your public/.htaccess file should look like:
Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /rails/dispatch.cgi/$1 [QSA,L] ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
We are now ready to show off our rails app to the world.
Start SCGI.
cd myapp nohup scgi_ctrl start &
Time to restart Apache so that the new configuration becomes available. Execute the following as root:
apachectl restart
Visit the URL of your site and you should see the welcome screen. Next, visit URL/myapp and the rails app should be available there.
I spent many sleepless frustrating nights to eventually get it all working. Hope the above configuration saves a lot of people from same amount of frustration.
FYI, the latest version of SCGI (1.11) appears to be located here – the MEMS site appears out-of-date.
Original topic at PuneRuby
Ashish Kulkarni – ashish@sapforbusiness.com
Blog
See Also: