0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Rails】主要コマンドまとめ

Last updated at Posted at 2020-05-10

#参考文献

#Rails編

###gemインストール(path指定)

$ bundle install --path vendor/bundle

###model作成

$ rails g model sample name:text    #name=カラム名(text型)

#Docker編

###railsプロジェクト作成

$ docker-compose run web bundle exec rails new . --force --skip-bundle

###キャッシュを利用したくない場合

$ docker-compose build --no-cache   

###MySQL利用

$ docker-compose run web rails new . --force --database=mysql

###DB関連コマンド

$ docker-compose exec web bundle exec rake db:drop     #削除
$ docker-compose exec web bundle exec rake db:create  #作成
$ docker-compose exec web bundle exec rake db:migrate #マイグレーション
$ docker-compose exec web bundle exec rake db:seed   #データ投入

###サーバ起動

$ docker-compose up -d

###exit1が発生する場合

$ rm tmp/pids/server.pid

#Unicorn編

###起動コマンド

$ bundle exec unicorn_rails -E XXXXXXX -c config/unicorn/XXXXXX.rb -D

###起動確認

$ ps -ef | grep unicorn | grep -v grep

#Nginx編

###起動コマンド

$ sudo systemctl start nginx.service

###起動確認

$ ps aux | grep nginx

#Capistrano編

###database.ymlアップロード

$ bundle exec cap XXXXXXX deploy:upload      #環境名(ex: development)

###デプロイチェック

$ bundle exec cap XXXXXXX deploy:check   #環境名(ex: development)

###デプロイ実行

$ bundle exec cap XXXXXXX deploy        #環境名(ex: development)

#SSH関連コマンド

###公開鍵作成

$ ssh-keygen -t rsa

###EC2接続

$ ssh -i XXXXX.pem ec2-user@XX.XX.XXX.XXX

###ssh-agentに鍵の登録

$ ssh-add -K ~/.ssh/XXXX_key_rsa

###リモートマシン-ローカル間のファイルコピー

$ scp XXXXXX.txt ユーザ名@サーバホスト名:/var/www/XXXXX/XXXX
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?