Using Ruby On Rails With Apache2 On Debian Etch - Page 2
6 Modifying Our Application's .htaccess File
The web folder of testapplication is /var/rails/testapplication/public. It contains an .htaccess file that we must modify so that Apache2 can run RoR applications using mod-fcgid.
Comment out the AddHandler fastcgi-script .fcgi and AddHandler cgi-script .cgi lines and add the line AddHandler fcgid-script .fcgi. Also comment out the line RewriteRule ^(.*)$ dispatch.cgi [QSA,L] and add the line RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] (note that it's now dispatch.fcgi instead of dispatch.cgi). Afterwards, the file should look like this:
7 Creating A Virtual Host For Our RoR Application
(If you use ISPConfig, please go to chapter 8!)
Now it's time to create an Apache vhost for our application. I will use the hostname testapplication.example.com so that our application can be reached under http://testapplication.example.com (assuming that testapplication.example.com points to the correct IP address).
The easiest way to create such a vhost is to replace the existing default vhost in /etc/apache2/sites-available/default (assuming that this default vhost isn't needed!):
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default_old
Of course, instead of replacing the default vhost, you can simply add your testapplication.example.com vhost at the end of /etc/apache2/sites-available/default so that you keep the default vhost.
Now we restart Apache:
Next we open http://testapplication.example.com in a browser. We should see the default RoR page:
That's it! Now we can start to develop our RoR application in the /var/rails/testapplication directory.
8 RoR And ISPConfig
(If you don't use ISPConfig, skip this chapter!)
In this chapter I assume that you have created a web site called testapplication.example.com with the document root /var/www/web1/web in ISPConfig, and that your RoR testapplication is still in /var/rails/testapplication.
To make our RoR testapplication available in the testapplication.example.com vhost which we have created in ISPConfig, we do the following:
First, we put the following lines into the Apache Directives field of the testapplication.example.com web site in ISPConfig:
Then we rename /var/rails/testapplication/public to /var/rails/testapplication/web, copy the contents of /var/rails/testapplication to /var/www/web1, and make the Apache user the owner of /var/www/web1/web:
That's it. The RoR application should now work in the testapplication.example.com vhost which we have created in ISPConfig.