Forked from linuxdevops-34/configure-ec2-instance.md
Created
September 14, 2024 05:42
-
-
Save RodCyb3Dev/929d94c5f095d6db5d6ac25626a4f548 to your computer and use it in GitHub Desktop.
Revisions
-
manojkumararyan revised this gist
Mar 29, 2019 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,9 +39,8 @@ #login to your server from terminal using pem file (generated private key) - ssh -i "<Path of your pem file>" ubuntu@<Public IP Address> - sudo apt-get update && sudo apt-get -y upgrade #to update existing packages - sudo adduser deploy #create 'deploy' user for deploying the application to server - sudo adduser deploy sudo #provide sudo privilege ``` ### Generating ssh-key -
manojkumararyan revised this gist
Jan 23, 2019 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,9 +40,8 @@ - ssh -i "<Path of your pem file>" ubuntu@<Public IP Address> - sudo apt-get update && sudo apt-get -y upgrade #to update existing packages - create 'deploy' user for deploying the application to server - sudo adduser deploy - sudo adduser deploy sudo ``` ### Generating ssh-key @@ -172,9 +171,6 @@ end config/deploy.rb config/deploy/production.rb config/deploy/staging.rb #add these line to capfile require 'capistrano/bundler' @@ -183,6 +179,9 @@ require 'capistrano/rails/assets' # for asset handling add require 'capistrano/rails/migrations' # for running migrations require 'capistrano/puma' install_plugin Capistrano::Puma # Default puma tasks #upload puma config - cap production puma:config ``` Edit deploy.rb ``` -
manojkumararyan revised this gist
Jan 23, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -194,7 +194,7 @@ set :branch, :master #use `git rev-parse --abbrev-ref HEAD`.chomp for pick curre set :deploy_to, '/home/deploy/<application name>' set :pty, true set :linked_files, %w{config/database.yml config/application.yml} #if rails 5.2 & above master.key is used insted of application.yml set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} set :keep_releases, 5 ``` Edit the config/deploy/staging.rb -
manojkumararyan revised this gist
Jan 22, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -182,6 +182,7 @@ require 'capistrano/rvm' require 'capistrano/rails/assets' # for asset handling add require 'capistrano/rails/migrations' # for running migrations require 'capistrano/puma' install_plugin Capistrano::Puma # Default puma tasks ``` Edit deploy.rb ``` -
manojkumararyan revised this gist
Jan 22, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -74,7 +74,7 @@ server { listen 80; server_name localhost; root /home/deploy/<application name>/current/public; try_files $uri/index.html $uri @app; @@ -192,7 +192,7 @@ set :repo_url, '<git application path>' # Edit this to match your repository set :branch, :master #use `git rev-parse --abbrev-ref HEAD`.chomp for pick current branch set :deploy_to, '/home/deploy/<application name>' set :pty, true set :linked_files, %w{config/database.yml config/application.yml} #if rails 5.2 & above master.key is used insted of application.yml set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} set :keep_releases, 5 ``` -
manojkumararyan revised this gist
Aug 30, 2018 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -183,7 +183,7 @@ require 'capistrano/rails/assets' # for asset handling add require 'capistrano/rails/migrations' # for running migrations require 'capistrano/puma' ``` Edit deploy.rb ``` lock '3.11.0' #capistrano version @@ -210,7 +210,8 @@ server '<production server public IP address>', user: 'deploy', roles: %w{web ap ``` Deploy code to AWS ``` cap staging deploy #for staging server cap production deploy #for production server #login to server & finally restart the nginx sudo service nginx restart ``` -
manojkumararyan revised this gist
Aug 30, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -117,7 +117,7 @@ server { - curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - - sudo apt-get install -y nodejs ``` ### Installing MySQL or PostgreSQL ``` # install mysql - sudo apt-get install mysql-server mysql-client libmysqlclient-dev @@ -151,6 +151,8 @@ server { - add SECRET_KEY_BASE from your application to this file (or you can generate your own secret key base) SECRET_KEY_BASE: "8a2ff74119cb2b8f14a85dd6e213fa24d8540fc34dcaa7ef8a35c246ae452bfa8702767d19086461ac911e1435481c22663fbd65c97f21f6a91b3fce7687ce63" ``` Server configurations are done. Now configure your rails application. ### Rails application setup for capistrano ``` #configuring capistrano -
manojkumararyan revised this gist
Aug 30, 2018 . 1 changed file with 28 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -139,11 +139,17 @@ server { - mkdir <application name> - mkdir -p <application name>/shared/config - nano <application name>/shared/config/database.yml #for rails 5.2 'master.key' file is used for secret key - nano <application name>/shared/config/master.key - add key from master.key of your application to this file eg: da54dd7f691dd9d8707c3f67ec9d076f #for rails lower versions 'application.yml' or 'secrets.yml' is used for secret key - nano <application name>/shared/config/application.yml OR - nano <application name>/shared/config/secrets.yml - add SECRET_KEY_BASE from your application to this file (or you can generate your own secret key base) SECRET_KEY_BASE: "8a2ff74119cb2b8f14a85dd6e213fa24d8540fc34dcaa7ef8a35c246ae452bfa8702767d19086461ac911e1435481c22663fbd65c97f21f6a91b3fce7687ce63" ``` ### Rails application setup for capistrano ``` @@ -159,8 +165,14 @@ end - bundle install #create configuration files for capistrano - bundle exec cap install #this command will create config/deploy.rb config/deploy/production.rb config/deploy/staging.rb #upload puma config - cap production puma:config #add these line to capfile require 'capistrano/bundler' @@ -171,37 +183,28 @@ require 'capistrano/puma' ``` edit deploy.rb ``` lock '3.11.0' #capistrano version set :application, '<application name>' set :repo_url, '<git application path>' # Edit this to match your repository set :branch, :master #use `git rev-parse --abbrev-ref HEAD`.chomp for pick current branch set :deploy_to, '/home/deploy/<application name>' set :pty, true set :linked_files, %w{config/database.yml config/application.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} set :keep_releases, 5 ``` Edit the config/deploy/staging.rb ``` set :rails_env, 'staging' set :puma_env, fetch(:rack_env, fetch(:rails_env, 'staging')) server '<staging server public IP address>', user: 'deploy', roles: %w{web app db} ``` Edit the config/deploy/production.rb ``` set :rails_env, 'production' set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production')) server '<production server public IP address>', user: 'deploy', roles: %w{web app db} ``` Deploy code to AWS ``` -
manojkumararyan revised this gist
Aug 30, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -121,6 +121,7 @@ server { ``` # install mysql - sudo apt-get install mysql-server mysql-client libmysqlclient-dev # setup postgresql - sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list" - wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - -
manojkumararyan revised this gist
Aug 30, 2018 . 1 changed file with 28 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -103,12 +103,36 @@ server { ### Installing ruby ``` - su - deploy - sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev - gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - curl -sSL https://get.rvm.io | bash -s stable - source ~/.rvm/scripts/rvm - rvm install 2.5.1 - rvm use 2.5.1 --default - ruby -v - gem install bundler #install bundler ``` ### Installing NodeJs ``` - curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - - sudo apt-get install -y nodejs ``` ### Installing MySQL Or PostgreSQL ``` # install mysql - sudo apt-get install mysql-server mysql-client libmysqlclient-dev # setup postgresql - sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list" - wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - - sudo apt-get update - sudo apt-get install postgresql-common - sudo apt-get install postgresql-9.5 libpq-dev # create postgresql user - sudo -u postgres createuser foo -s # set password - sudo -u postgres psql postgres=# \password chris ``` ### Create files required by capistrano ``` - mkdir <application name> -
manojkumararyan revised this gist
Aug 29, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,7 +148,7 @@ edit deploy.rb ``` lock '3.4.0' set :application, '<application name>' set :repo_url, '<git application path>' # Edit this to match your repository set :branch, :master set :deploy_to, '/home/deploy/<application name>' -
manojkumararyan revised this gist
Aug 29, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -116,7 +116,7 @@ server { - nano <application name>/shared/config/database.yml #for rails 5.2 'master.key' file is used for secret key #for rails lower versions 'application.yml' or 'secrets.yml' is used for secret key - nano <application name>/shared/config/application.yml #change application.yml file name as per you required - add this to it #you can add master.key for rails 5.2 SECRET_KEY_BASE: "8a2ff74119cb2b8f14a85dd6e213fa24d8540fc34dcaa7ef8a35c246ae452bfa8702767d19086461ac911e1435481c22663fbd65c97f21f6a91b3fce7687ce63" ``` -
manojkumararyan revised this gist
Aug 29, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -177,7 +177,7 @@ set :puma_preload_app, false Edit the config/deploy/production.rb ``` server '<server public IP address>', user: 'deploy', roles: %w{web app db} ``` Deploy code to AWS ``` cap production deploy -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -149,9 +149,9 @@ edit deploy.rb lock '3.4.0' set :application, 'contactbook' set :repo_url, '<git application path>' # Edit this to match your repository set :branch, :master set :deploy_to, '/home/deploy/<application name>' set :pty, true set :linked_files, %w{config/database.yml config/application.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} @@ -177,7 +177,7 @@ set :puma_preload_app, false Edit the config/deploy/production.rb ``` server '<server public IP address>', user: 'deploy', roles: %w{web app db} ```document Deploy code to AWS ``` cap production deploy -
manojkumararyan revised this gist
Aug 28, 2018 . No changes.There are no files selected for viewing
-
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Deploy Rails Application to AWS EC2 ### Creating AWS EC2 Instance ``` - login to 'AWS Management Console' (https://aws.amazon.com/console/) -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -120,7 +120,7 @@ server { - add this to it #you can add master.key for rails 5.2 SECRET_KEY_BASE: "8a2ff74119cb2b8f14a85dd6e213fa24d8540fc34dcaa7ef8a35c246ae452bfa8702767d19086461ac911e1435481c22663fbd65c97f21f6a91b3fce7687ce63" ``` ### Rails application setup for capistrano ``` #configuring capistrano #add this to gemfile -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -178,6 +178,9 @@ Edit the config/deploy/production.rb ``` server '<server public IP address>', user: 'deploy', roles: %w{web app db} ``` Deploy code to AWS ``` cap production deploy #login to server & finally restart the nginx sudo service nginx restart ``` -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -132,9 +132,11 @@ group :development do gem 'capistrano-rvm' end - bundle install #create configuration files for capistrano - config/deploy.rb - config/deploy/production.rb #add these line to capfile require 'capistrano/bundler' require 'capistrano/rvm' @@ -172,3 +174,10 @@ set :puma_worker_timeout, nil set :puma_init_active_record, true set :puma_preload_app, false ``` Edit the config/deploy/production.rb ``` server '<server public IP address>', user: 'deploy', roles: %w{web app db} ``` ``` cap production deploy ``` -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 74 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,14 +67,14 @@ #add this content to file upstream app { # Path to Puma SOCK file, as defined previously server unix:/home/deploy/<application name>/shared/tmp/sockets/puma.sock fail_timeout=0; } server { listen 80; server_name localhost; root /home/deploy/<application name>/public; try_files $uri/index.html $uri @app; @@ -100,3 +100,75 @@ server { keepalive_timeout 10; } ``` ### Installing ruby ``` - su - deploy - gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 - \curl -sSL https://get.rvm.io | bash -s stable - rvm install ruby #you can specify required ruby version - rvm use ruby - gem install bundler #install bundler ``` ### Create files required by capistrano ``` - mkdir <application name> - mkdir -p <application name>/shared/config - nano <application name>/shared/config/database.yml #for rails 5.2 'master.key' file is used for secret key #for rails lower versions 'application.yml' or 'secrets.yml' is used for secret key - nano contactbook/shared/config/application.yml #change application.yml file name as per you required - add this to it #you can add master.key for rails 5.2 SECRET_KEY_BASE: "8a2ff74119cb2b8f14a85dd6e213fa24d8540fc34dcaa7ef8a35c246ae452bfa8702767d19086461ac911e1435481c22663fbd65c97f21f6a91b3fce7687ce63" ``` ### Rails application setup ``` #configuring capistrano #add this to gemfile group :development do gem 'capistrano' gem 'capistrano3-puma' gem 'capistrano-rails', require: false gem 'capistrano-bundler', require: false gem 'capistrano-rvm' end - bundle install #create configuration files for capistrano - config/deploy.rb - config/deploy/production.rb #add these line to capfile require 'capistrano/bundler' require 'capistrano/rvm' require 'capistrano/rails/assets' # for asset handling add require 'capistrano/rails/migrations' # for running migrations require 'capistrano/puma' ``` edit deploy.rb ``` lock '3.4.0' set :application, 'contactbook' set :repo_url, '[email protected]:devdatta/contactbook.git' # Edit this to match your repository set :branch, :master set :deploy_to, '/home/deploy/contactbook' set :pty, true set :linked_files, %w{config/database.yml config/application.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} set :keep_releases, 5 set :rvm_type, :user set :rvm_ruby_version, 'jruby-1.7.19' # Edit this if you are using MRI Ruby set :puma_rackup, -> { File.join(current_path, 'config.ru') } set :puma_state, "#{shared_path}/tmp/pids/puma.state" set :puma_pid, "#{shared_path}/tmp/pids/puma.pid" set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock" #accept array for multi-bind set :puma_conf, "#{shared_path}/puma.rb" set :puma_access_log, "#{shared_path}/log/puma_error.log" set :puma_error_log, "#{shared_path}/log/puma_access.log" set :puma_role, :app set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production')) set :puma_threads, [0, 8] set :puma_workers, 0 set :puma_worker_timeout, nil set :puma_init_active_record, true set :puma_preload_app, false ``` -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 46 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,5 +53,50 @@ - copy the ssh-key & set it as your deploy key on your repository(project on bitbucket or github) - copy your system public ssh-key & paste it into the following file on your instance as deploy user nano .ssh/authorized_keys #save & exit ``` ### Installing GIT ``` - sudo apt-get install git ``` ### Installing Nginx ``` - sudo apt-get install nginx - sudo nano /etc/nginx/sites-available/default #to configure default site ``` ``` #add this content to file upstream app { # Path to Puma SOCK file, as defined previously server unix:/home/deploy/contactbook/shared/tmp/sockets/puma.sock fail_timeout=0; } server { listen 80; server_name localhost; root /home/deploy/contactbook/public; try_files $uri/index.html $uri @app; location / { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Connection ''; proxy_pass http://app; } location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt { gzip_static on; expires max; add_header Cache-Control public; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } ``` -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Deploy Rails App to AWS EC2 ### Creating AWS EC2 Instance ``` - login to 'AWS Management Console' (https://aws.amazon.com/console/) -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ # Deploy Rails App to AWS ### Creating AWS EC2 Instance ``` - login to 'AWS Management Console' (https://aws.amazon.com/console/) - from 'Services'(in navbar) choose 'EC2' - from 'Create Instance' section, click on 'Launch Instance' - then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ### Creating AWS EC2 Instance ``` - login to _AWS Management Console_ (https://aws.amazon.com/console/) - from 'Services'(in navbar) choose 'EC2' - from 'Create Instance' section, click on 'Launch Instance' - then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ### Creating AWS EC2 Instance ``` - login to *AWS Management Console* (https://aws.amazon.com/console/) - from 'Services'(in navbar) choose 'EC2' - from 'Create Instance' section, click on 'Launch Instance' - then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ### Creating AWS EC2 Instance ``` - login to '*AWS Management Console*' (https://aws.amazon.com/console/) - from 'Services'(in navbar) choose 'EC2' - from 'Create Instance' section, click on 'Launch Instance' - then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,8 +54,3 @@ nano .ssh/authorized_keys #save & exit - sudo apt-get install git #install git ``` -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,7 +44,7 @@ - run 'sudo visudo' & add 'deploy ALL=(ALL:ALL) ALL' into the file & save ``` ### Generating ssh-key ``` - su - deploy - ssh-keygen #do not set a passphrase for the key -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 42 additions and 42 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,58 +1,58 @@ ### Creating AWS EC2 Instance ``` - login to 'AWS Management Console' (https://aws.amazon.com/console/) - from 'Services'(in navbar) choose 'EC2' - from 'Create Instance' section, click on 'Launch Instance' - then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example - select 'Instance Type' as per your requirement - then click 'Next:Configure Instance Details' to continue change 'Configure Instance Details' or used as default settings - click 'Next: Add Storage' adjust size as per your need (default is 8GB) - click 'Next: Tag Instance' create tag if you need any tagging for your instance - click 'Next: Configure Security Group' click 'Add Rule' to add new rule(for port, ip address etc.) default you can set it to - SSH TCP 22 Anywhere 0.0.0.0/0 HTTP TCP 80 Anywhere 0.0.0.0/0 - then click 'Review and Launch' check all your setting, then click 'Launch' - select existing or create new keypair to connect to your instance click 'Launch Instance', this will generate the key (in case of new keypair) & launches your instance find 'Public IP' from 'Description' ``` ### Setup Elastic IP ``` - you can generate an Elastic IP from 'Network & Security' tab - click 'Allocate new address' - then click 'Allocate', this will generate an Elastic IP - click 'Close', this will redirect you to Elastic IP Dashboard - select you Elastic IP & on right click select 'Associate address' - choose you instance (whom you want to associate) & click 'Associate' this will replace your Public IP with Elastic IP (& now this IP is used) ``` ### Setup the server to connect ``` #login to your server from terminal using pem file (generated private key) - ssh -i "<Path of your pem file>" ubuntu@<Public IP Address> - sudo apt-get update && sudo apt-get -y upgrade #to update existing packages - create 'deploy' user for deploying the application to server - sudo useradd -d /home/deploy -m deploy #the application will be deployed in /home/deploy directory - sudo passwd deploy #set the password for 'deploy' user - run 'sudo visudo' & add 'deploy ALL=(ALL:ALL) ALL' into the file & save ``` ### Generate ssh-key ``` - su - deploy - ssh-keygen #do not set a passphrase for the key - cat .ssh/id_rsa.pub - copy the ssh-key & set it as your deploy key on your repository(project on bitbucket or github) - copy your system public ssh-key & paste it into the following file on your instance as deploy user nano .ssh/authorized_keys #save & exit - sudo apt-get install git #install git ``` finally, -
manojkumararyan revised this gist
Aug 28, 2018 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ ### Creating AWS EC2 Instance ``` * login to 'AWS Management Console' (https://aws.amazon.com/console/) * from 'Services'(in navbar) choose 'EC2' * from 'Create Instance' section, click on 'Launch Instance' * then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example select 'Instance Type' as per your requirement then click 'Next:Configure Instance Details' to continue change 'Configure Instance Details' or used as default settings
NewerOlder