httpd.conf
Archived Posts from this Category
January 7, 2008
- cd C:/InstantRails/www. This is assuming your Instant Rails is installed in C:
- rails -d mysql myapp. This will create a new Ruby on Rails application in C:/InstantRails/www with MySQL as the default database server.
- On command prompt, key in: ruby script/server –port=3003. Check that you are able to access myapp at http://localhost:3003/ in your browser.
- Check that Apache is running by typing http://localhost/. This will display the index file fron C:/InstantRails/www directory.
- cd C:/InstantRails/apache/conf.
- Open http.conf file. In this file search for ‘VirtualHost’. This will lead you to the bunch of virtualhost declations for typo and cookbook applications.
- httpd.conf with InstantRails has proxy_module already uncommented for use. LoadModule proxy_module modules/mod_proxy.s.
- Add myapp block to httpd.conf:

- In the InstantRails configuration tool, select Configure -> Windows Hosts File. Click it open and add an entry to the end: 127.0.0.1 myapp. Save the file and exit notepad.
- Restarting Apache server was not needed since I was running this set up for the development environment.
- Key in http://myapp/ in the browser to check that your app is indeed showing up the index.html page from myapp/public folder.
- As a further adventure, add up on myapp:
C:\InstantRails\www\myapp>ruby script/generate scaffold Blog blog_id:integer title:string body:text
- Run rake db:migrate
- Now key in http://myapp/blogs and it should show up the ‘index’ action for blogs correctly. Browse around by clicking on ‘new blog’ and see that the page is served as http://myapp/blogs/new.
- Also look at Apache access logs from InstantRails application and also the mongrel server logs from the command line.
- If keying in http://myapp/ takes you to http://www.myapp.com/, then you need to checks Windows Hosts file using InstantRails.
- If keying in http://myapp/ takes you to the Index of / directory listing that just shows the files in myapp folder, then you need to make sure you have given the DocumentRoot in the virtualhost declaration in httpd.conf as C:/InstantRails/www/myapp/public/ and NOT C:/InstantRails/www/myapp/ alone.
- Alternatives: in httpd.conf file if you
(a) provide ServerName as http://www.myapp.com/,
(b) provide ProxyPass / http://localhost:3003/ instead of ProxyPass /myapp/ http://localhost:3003/, and
(c) include the entry 127.0.0.1 http://www.myapp.com/ in Windows hosts file,
you can access you application at http://www.myapp.com/ from your desktop. If the browser continues to show the real http://www.myapp.com/ then just restart the browser or perhaps just clear the browser cache.
- It is not necessary to create your application under InstantRails/www. Having an application as InstantRails/rails_apps/myapp and providing the document root in httpd.conf as C:/InstantRails/rails_apps/myapp/public works just fine.