Deploy your website to DigitalOcean (part-3)

Hi, Today I'll continue talking about deploying to Digital Ocean. So far, I told you about uploading your files to the server. Today, I'll tell you how to set the database and some basic commands you need.
Note: I am using rails application as an example in the following steps.

4- Setup Database:


  • Make sure that you set the production part in "config/database.yml" like this:
adapter: mysql2
database: rails
username: rails
password: password_in_ credentials _email

  • Then upload the file (publish -> upload as in previous part)



  • Open your command line and login to the server using the credentials sent to you earlier by Digital Ocean using this command:
ssh root@xxx.xxx.xx.xx  (where "xxx.xxx.xx.xx" is the IP address found in the credentials email)


  • Change to the directory contains your code "/home/rails" using this command:
cd /home/rails


  • Setup database using the following commands:
RAILS_ENV=production rake db:create
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake db:seed


5- Configure assets:

  • Configure the assets using the following commands
RAILS_ENV=production rake assets:precompile
chown -R rails:www-data /home/rails

6- Start the server:

  • Make sure you have included "unicorn gem" in your gem file. If not, add line to your Gemfile then upload it (Publish -> upload).
gem "unicorn"

  • Finally restart unicorn using the following command
service unicorn restart


Now if navigate to your droplet IP address, you should see your server running.


Comments

Popular Posts