Rory is now ready to install the components required to provide a production environment for his Rails application. He installs: Ruby; the Rails, and Mongrel gems; a SVN client, MySQL, and Apache on his server. He then follows these steps to install and run his test application.
test_app
. His local domain is company.local
, and he has unimaginatively called his server "server".svn import -m "Rails test application" http://server.company.local/svn/test_app
$ rake db:migrate
http://server.company.local:3000/
and checks that the application is working at this point. Once he has made this check, he stops this Mongrel instance.$ mongrel_rails start -d -p 4000 e production
http://server.company.local:4000/
and checks that the application is working at this point too. conf/httpd.conf
. He edits httpd.conf
and restarts the Apache server. He then uses a browser to test the application.Rory already has web pages and applications running on his server. If he were simply to route all traffic to Mongrel, these other resources would cease to be available. He therefore decides to provide two name spaces for Apache to use, one for Rails and one for the existing pages. He therefore updates his DNS server by adding a new A host record of "intranet" mapped to the IP address of his server. He already has an A host record of "www" mapped to his server, and he intends keeping this for his existing systems.
Rory already has web pages and applications running on his server. If he were simply to route all traffic to Mongrel, these other resources would cease to be available. He therefore decides to provide two name spaces for Apache to use, one for Rails and one for the existing pages. He therefore updates his DNS server by adding a new A host record of "intranet" mapped to the IP address of his server. He already has an A host record of "www" mapped to his server, and he intends keeping this for his existing systems.
He then updates his httpd.conf
as follows:
LoadModule
statements for proxy_module
and proxy_http_module
as described above. NameVirtualHost
. This tells Apache that virtual hosts are being used for the service at this address. Without this line, the system will see the virtual hosts as clashing and revert to the first one it finds.# ServerName www.company.local:80 NameVirtualHost 10.0.0.1 <VirtualHost www.company.local:80> ServerName www.company.local DocumentRoot "C:/Program Files/Apache Software Foundation/ Apache2.2/htdocs" </VirtualHost> <VirtualHost intranet.company.local:80> ServerName intranet.company.local ServerAlias intranet.company.local ProxyPass / http://intranet.company.local:4000/ ProxyPassReverse / http://intranet.company.local:4000 ProxyPreserveHost on </VirtualHost>
He then stops and restarts his Apache server. He tests the system by first browsing to http://www.company.local
where he finds he is able to access his existing web pages. He browses to http://intranet.company.local
, and using this URL, he is able to access his test application.
Once Rory is satisfied that his test application is working, and therefore his production environment also works, he stops the Mongrel instance and deletes the test application folder, thereby removing the test application from his system. He then restores the httpd.conf
and restarts Apache.
As development of his application progresses, Rory gets to the point where he wants to load the application onto the production server, so that a wider user base can access it. He is fairly sure that the application is ready for more public viewing and he has tested it thoroughly in development mode. To get the Intranet application onto the server and running in production mode, Rory follows the steps he used to get the test application into production mode. That is with one exception: instead of checking out the test application from the Subversion repository, he checks out the Intranet application.
13.59.173.242