Skip to content

Instantly share code, notes, and snippets.

@kalpesh-fulpagare
Last active December 17, 2015 19:39
Show Gist options
  • Save kalpesh-fulpagare/5661537 to your computer and use it in GitHub Desktop.
Save kalpesh-fulpagare/5661537 to your computer and use it in GitHub Desktop.
Deploying RoR app with apache server on local machine
Instruction for Ubuntu 12.X (should work on 11.x also)
a. Installing apache2 server
$ sudo apt-get install apache2
Restarting apache
$ sudo /etc/init.d/apache2 restart
b. Installing passenger gem
$ gem install passenger
c. Installing passenger-apache module
$ passenger-install-apache2-module
e.g. Your ruby on rails app path is /home/kalpesh/projects/demo_app/public
d. Configuring httpd.conf file of apache for rails
$ nano /etc/apache2/httpd.conf
<VirtualHost *:80>
Railsenv development
DocumentRoot /home/kalpesh/projects/demo_app/public
ServerName local.demoapp.com
serverAlias admin.demoapp.com
<Directory /home/kalpesh/projects/demo_app/public>
AllowOverride All
Railsenv development
</Directory>
</VirtualHost>
e. Configuring hosts file
$ nano /etc/hosts
127.0.0.1 localhost
127.0.1.1 kalpesh
127.0.0.1 admin.demoapp.com
127.0.0.1 local.demoapp.com
Now type local.demoapp.com or admin.demoapp.com to open your app.
*** Additional Examples of httpd.conf file of apache ***
<VirtualHost *:80>
DocumentRoot /home/kalpesh/projects/app1/public
ServerName local.app1.com
Railsenv development
</VirtualHost>
<VirtualHost 127.0.1.4:80>
DocumentRoot /home/kalpesh/projects/app2/public
ServerName local.app2.com
Railsenv development
</VirtualHost>
<VirtualHost 127.0.1.5:80>
DocumentRoot /home/kalpesh/projects/app3/public
ServerName local.app3.com
Railsenv development
</VirtualHost>
<VirtualHost 127.0.1.7:80>
DocumentRoot /home/kalpesh/projects/app4/public
ServerName local.app4.com
Railsenv production
</VirtualHost>
*** Additional Examples of hosts file ***
127.0.0.1 localhost
127.0.0.1 kalpesh
127.0.0.1 admin.app1.com
127.0.0.1 local.app1.com
127.0.1.4 local.app2.com
127.0.1.5 admin.app3.com
127.0.1.7 local.app4.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment