How to upload existing rails application ?
After receiving the welcome email with login info to your hosting account
1. IP address : xx.xxx.xxx.xxx
2. Your hosting account username and password
3. Cpanel http://xx.xxx.xxx.xxx/cpanel
Log into Cpanel, click 'MySQL Database' option and set up mySQL database :-
1. Create a database
2. Create a dbuser
3. Assign that dbuser to the database (NOTE: this step is important otherwise you will not be able to connect to the database)
Also note that the actual dbname and dbuser name will have your hosting account login name as a prefix (e.g myacct_dbname, myacct_dbuser)
Upload your mysql dump file and import into newly created database
FTP upload your mysql dump file and SSH login to your hosting account and issue the following command to import the dump file content to the mysql server:-
mysql -umyacct_dbuser -pdbuser password -Dmyacct_dbame < mysqldumpfile
SSH into your hosting account shell and generate your new Rails app
SSH into your hosting account shell and at your home folder '/home/myacct/', run the following command:-
[~]# rails yournewrailsapp
Ruby on Rails will then generate the required folders and files for you.
Modify environment.rb and database.yml files
Both the database.yml and environment.rb file are in :-
yournewrailsapp/config/
Edit the database.yml file and make it look like this:
production:
adapter: mysql
database: myacct_dbname
username: myacct_dbusr
password: your_db_password
Leave the rest of the section in the file.
NOTE: You must run your rails app only in production environment with your shared hosting account.
In environment.rb file, just uncomment the following line to confirm you're in production mode:
ENV['RAILS_ENV'] | |= 'production'
Upload your rails application files into appropriate skeleton folders of this newly created app
- entire app folder (with the controllers, models, helpers, views)
- public/images
- public/javascripts
- public/stylesheets
- public/.htaccess (with the dispatch.fcgi rewrite, leave it if you have ammended the existing file)
- config/database.yml(leave it if you have follow above steps to amend this file)
- config/environment.rb(leave it if you have follow above steps to amend this file)
- config/routes.rb (see below for editing note before upload)
NOTE: before uploading you routes.rb file, edit the file and uncomment the following line :-
map.connect '', :controller => "your_main_controller_name"
upload it and then remove the yournewrailsapp/public/index.html, this will have your rails app calling your main controller when the application is called.
Create a symlink so that the 'public_html' folder is pointing to the new Rails app's public folder.
At the home folder , run the following commands:
[~]# mv public_html public_html_bk
[~]# ln -s yournewrailsapp/public public_html
Test if your rails app is working by entering your domain in browser window, if everthing is setup properly you will be seeing your rails app showing up