📜 ⬆️ ⬇️

We place the project on Ruby on Rails

This is an article about how I hosted a Ruby on Rails project on shared hosting. I will make a reservation that I did everything in a simple way (who is such a capistrano? :)


At first I decided to deal with the untwisted framework. No sooner said than done. Then I decided to try it in action. The first thing that came to mind was embodied in the code. After that, the question arose where to place your creation.

My requirements for hosting:
1. Naturally, support of Ruby and Rails working on Mongrel,
2. as long as the shared hosting is enough
3. ssh access
4. installed svn client (I do not mess with ftp).
')
All considered CIS-shnyy hosting had significant drawbacks:
1. how many ($$$),
2. uptime as much as 99.99999999999% depends on the administrator's sobriety,
3. But about the mastercard heard?

I looked at foreign countries. The choice fell on www.webfaction.com :
1. there were good reviews and not a single bad
2. Great price,
3. awesome demo , how to install rails app.

Paid - received hosting. I must say, the support service is attentive. Before registration I answered all my technical questions.

Now step by step on the placement of the application.

Step 1. Create an application

In the admin we create an application that will be automatically generated in the ~ / webapps / test_app folder.



Then we add the domain.



Finally, create a website.



We get a working disc. The main thing in it is the autostart.cgi file for running the mongrel. Everything else can be safely deleted :) Do not forget to log into the server via ssh.

Step 2. Download your application

SVN makes this process easier. Run svn checkout. After the download of files is completed, we try to start by typing the application address in the browser. See endless attempts at “Restarting site ... click here”.

We look at the application logs: “can not find rails 2.0.2”. We freeze the Rails modules in our working copy (that is, we save all the Gems Rails in the plugins directory).

rake rails: freeze: gems

We do svn commit, then svn update, but already on the server. Opening the site - connection error with the database.

Step 3. Setting up the application

Clear pepper - no one has created a base :) A couple of clicks and it's done.



Password generated. We set the connection parameters in the production.rb file. Again svn commit, svn update. New error - there is no such table. No problem. We write in the console:

export RAILS_ENV = production
rake rake db: migrate

Works!

Step 4. Install dependent modules

I'm lying. The application crashes when a module is connected. Install gems in your home directory.

cd ~
mkdir gems
export GEM_PATH = ~ / gems
gem install -i ~ / gems module_name

Restart the application

>> ps -u [login]
list of processes is displayed
>> kill -9 [Mongrel process ID]
>> ./autostart.cgi

All type-top. The site works - I am satisfied as if for the first time.

Reflections

Still, it's nice when hosting is created for people, not for admins :) It’s good when there is svn and you don’t have to upload files via FTP.

What comfort does a rails offer when placing a project?

Creating and updating the database structure is complete without mysqldump> dump.sql and mysql <dump.sql. The database is controlled by CVS.

Conveniently, the separation of settings for production, development and test. No fear of overwriting configuration files.

You can run tests on the production server to finally verify that the application is working.

In general, when your application works by default and without a tambourine - this is very good!

P.S. Share your experience with Rails applications.

Source: https://habr.com/ru/post/21925/


All Articles