📜 ⬆️ ⬇️

Derby.js deploy on Amazon EC2

Intensive development of cloud services does not leave indifferent. Our focus is on Amazon - Elasctic Cloud Compute. There was a task to deploy the node.js project using Derby . Amazon Elastic Beanstalk also supports node.js, but we will limit ourselves to the Amazon EC2 service. In addition, out-of-the-box, Amazon Elastic Beanstalk offers Amazon Linux with a pre-installed node.js + nginx. In our case, Amazon Linux is not suitable, the node.js version and the node.js + nginx bundle as well. ,

Creating an instance and connecting to an EC2 server


It is assumed that you are registered with AWS, and have access to the AWS Managment Console .
Run EC2 Instance:
  1. Go to the AWS Managment Console
  2. Choose a region (in our case, US East (N.Virginia))
  3. Go Services -> Compute & Nerworking -> EC2
  4. Launch Instance: Select Ubuntu Server 13.04 x64 , configure keys, and other necessary parameters, incl. Instance Type (in our case t1.micro)
  5. After creating instances in the list, we observe how our server will receive state running
  6. Connecting to the server via ssh: to do this, in the list of instances, right-click on the one you need, select Connect -> Connect with a standalone SSH Client
    There will be something like:
    $ ssh -i yourkey.pem ubuntu@ec2-184-119-234-139.us-east-1.compute.amazonaws.com 
  7. We connect to the server according to the parameters obtained in paragraph 6.

We will use the following link: node.js + derby + redis + mongodb
Sequentially install the necessary packages.

Install Node.js.


For Derby.js we will use the version node.js 0.10.17
  1. Downloading source:
     $ wget http://nodejs.org/dist/v0.10.17/node-v0.10.17.tar.gz 
  2. Unpack:
     $ tar -xvf node-v0.10.17.tar.gz $ cd node-v0.10.17 
  3. Install:
      $ sudo apt-get -y install checkinstall $ checkinstall -D --install=no --nodoc --pkgversion=0.10.17 --pkgname="Node.js 0.10.17" $ sudo dpkg -i node*.deb 
  4. Install DerbyJS :
     $ sudo npm install -g derby 


Install Redis 2.6.16


  1. Download:
     $ wget http://download.redis.io/releases/redis-2.6.16.tar.gz 
  2. Unpack:
     $ tar -xvf redis-2.6.16.tar.gz $ cd redis-2.6.16 
  3. Install:
     $ sudo checkinstall -D --install=no --nodoc --pkgversion=2.6.16 --pkgname="Redis 2.6.16" $ sudo dpkg -i redis*.deb 
  4. Customize
     $ sudo mkdir /etc/redis $ sudo mkdir /var/redis $ sudo cp utils/redis_init_script /etc/init.d/redis $ sudo cp redis.conf /etc/redis/6379.conf $ sudo vi /etc/redis/6379.conf 
    specify the parameters
     daemonize yes logfile /var/log/redis.log dir /var/redis/ 
    save the file
  5. We start the service:
     $ sudo service redis start 
  6. Add to autoload:
     $ sudo update-rc.d redis defaults 
  7. Checking:
     $ redis-cli redis 127.0.0.1:6379> ping PONG redis 127.0.0.1:6379> exit 


Install MongoDB


  1. Installation:
     sudo apt-get -y install mongodb 
  2. Checking status:
     $ service mongodb status 
    Sample answer:
    mongodb start/running, process 24815

Create a Derby application


  1. Creature
     $ mkdir ~/www $ cd ~/www $ derby new myapp $ cd myapp 
  2. Check the launch:
     $ nmp start 

')

Run as a demon


Perhaps one of the easiest ways:
 $ cd ~/www/myapp $ nohup node server.js & 
You can also use supervisord or another tool.

References / sources


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


All Articles