Deploying application on Linux Instance

Deploy applications on Linux

  1. We use git to clone the source code. First of all, install git with the following command:
sudo yum install git

create vpc for linux instance

  1. Check successful git installation with command
git version

create vpc for linux instance

  1. Clone repository application code
cd ~ec2-user
git clone https://github.com/First-Cloud-Journey/000004-EC2.git

create vpc for linux instance

  1. Go to the lab directory 000004-EC2 and check the files
cd 000004-EC2
ls

create vpc for linux instance

  1. NPM stands for Node package manager and is a tool to create and manage Javascript programming libraries for Node.js. Using npm init to initialize the project will generate a sample package.json file.
npm init

You proceed to configure the application’s information and it is saved in the file package.json

create vpc for linux instance

  1. Next we do dependencies installation
  • express
  • Dotenv
  • express-handlebars
  • body-parser
  • mysql
npm install express dotenv express-handlebars body-parser mysql

create vpc for linux instance

create vpc for linux instance

  1. Check the installed dependencies. The node_modules folder appears.
ls

create vpc for linux instance

  1. Create file .env
touch .env

create vpc for linux instance

  1. Use vi to edit the .env file. We perform the database configuration:
DB_HOST = 'localhost'
DB_NAME = 'DB_NAME'
DB_USER = 'root'
DB_PASS = 'password'

create vpc for linux instance

In the lab we use the database name awsuser and the database information has been configured in the database security configuration step (password: 123Admin)

  1. Check database configuration
ls -a

create vpc for linux instance

  1. Restart Express server. Use Nodemon to save time
npm install --save-dev nodemon

create vpc for linux instance

  1. Start local server
npm start

create vpc for linux instance

  1. In the EC2 interface
  • Select Instances
  • Select Linux-instance
  • Copy Public IPv4 DNS address

create vpc for linux instance

  1. Paste Public DNS IPv4 address into the browser and port 5000. Observe the AWS FCJ Management interface

create vpc for linux instance

create vpc for linux instance

  1. In the phpMyAdmin interface, we execute SQL Dummy Data
  • Select awsuser database
  • Select SQL
  • Paste the SQL query code in
INSERT INTO `user` 
(`id`, `first_name`,  `last_name`,    `email`,                 `phone`,         `comments`, `status`) VALUES
(NULL, 'Amanda',      'Nunes',        'anunes@ufc.com',        '012345 678910', '',          'active'),
(NULL, 'Alexander',   'Volkanovski',  'avolkanovski@ufc.com',  '012345 678910', '',          'active'),
(NULL, 'Khabib',      'Nurmagomedov', 'knurmagomedov@ufc.com', '012345 678910', '',          'active'),
(NULL, 'Kamaru',      'Usman',        'kusman@ufc.com',        '012345 678910', '',          'active'),
(NULL, 'Israel',      'Adesanya',     'iadesanya@ufc.com',     '012345 678910', '',          'active'),
(NULL, 'Henry',       'Cejudo',       'hcejudo@ufc.com',       '012345 678910', '',          'active'),
(NULL, 'Valentina',   'Shevchenko',   'vshevchenko@ufc.com',   '012345 678910', '',          'active'),
(NULL, 'Tyron',       'Woodley',      'twoodley@ufc.com',      '012345 678910', '',          'active'),
(NULL, 'Rose',        'Namajunas ',   'rnamajunas@ufc.com',    '012345 678910', '',          'active'),
(NULL, 'Tony',        'Ferguson ',    'tferguson@ufc.com',     '012345 678910', '',          'active'),
(NULL, 'Jorge',       'Masvidal ',    'jmasvidal@ufc.com',     '012345 678910', '',          'active'),
(NULL, 'Nate',        'Diaz ',        'ndiaz@ufc.com',         '012345 678910', '',          'active'),
(NULL, 'Conor',       'McGregor ',    'cmcGregor@ufc.com',     '012345 678910', '',          'active'),
(NULL, 'Cris',        'Cyborg ',      'ccyborg@ufc.com',       '012345 678910', '',          'active'),
(NULL, 'Tecia',       'Torres ',      'ttorres@ufc.com',       '012345 678910', '',          'active'),
(NULL, 'Ronda',       'Rousey ',      'rrousey@ufc.com',       '012345 678910', '',          'active'),
(NULL, 'Holly',       'Holm ',        'hholm@ufc.com',         '012345 678910', '',          'active'),
(NULL, 'Joanna',      'Jedrzejczyk ', 'jjedrzejczyk@ufc.com',  '012345 678910', '',          'active')
  • Select Format
  • Select Go

create vpc for linux instance

create vpc for linux instance

  1. Refresh the application interface

create vpc for linux instance

  1. View the user

create vpc for linux instance

  1. Edit users

create vpc for linux instance

  1. Add users

create vpc for linux instance

  1. Search for users

create vpc for linux instance

  1. Database after inserting the item

create vpc for linux instance

  1. The interface of the instance when starting the local server

create vpc for linux instance