How to Deploy Your Nodejs App on Centos 7

PM2 is a process manager for nodejs apps. It daemonizes apps built with nodejs, which means run-as-service.

Let’s install PM2 using npm.

1
npm install -g pm2@latest

Now you can start your app using pm2 like so:

1
pm2 start app.js

Next, register the app as a startup process.

1
2
pm2 startup systemd
pm2 save

You can check the currently running apps like so:

How to Configure Virtual Hosts on Centos 7 Apache Server

Prerequisites for a vhost setup:

1
chown -R apache:apache /path_to/site_root

Set the permission of the project root directory to 755, you may already know. 🙂

Well, let’s create a vhost config file before you edit it.

1
2
cd /etc/httpd/conf.d
vim domain_name.conf

Now, grab this content to your config file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<VirtualHost *:80>

  ServerName domain.com
  ServerAlias www.domain.com
  DocumentRoot /var/www/path_to/site_root

  <Directory /var/www/path_to/site_root>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
  </Directory>

  CustomLog /var/log/httpd/domain.com-access.log combined
  ErrorLog /var/log/httpd/domain.com-error.log
  # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
  LogLevel warn

</VirtualHost>

Finally, restart the apache server to apply your changes.

How to Login to a Linux Server with SSH

What is a SSH?

SSH is the acronym of Secure Shell, which is one of the popular networking protocols.

SSH uses cryptography to authenticate and encrypt connections between devices. To be more specific, it uses asymmetric encryption. Cryptography is out of scope for the purpose of this article though.

How to Generate a SSH Key Pair?

On a Linux machine(Or Mac), you can simply run:

1
ssh-keygen -t rsa -C "[email protected]"
  • -t: Type of key, typically you would use rsa or ed25519
  • -C: Comment, typically you would use your name or email. Used for identifying whose key it is.
  • -b: Byte length of the key, optional

You will be prompted for a few questions, it’s okay to choose default for all. So you didn’t specify a custom key file name or a custom key file path, then you will be able to find the created key files:

How to Use PPK File for SSH

In some situations, you are given only a ppk file for access to a cloud server. You know, however, it’s for Putty on windows, not for OpenSSH client which might be the most familiar to you.🤔

This post explains a method to convert a ppk file into a pem file so that you can login to the linux server with ssh command that you are most familiar with.

First off, install putty-tools on your machine.

CI/CD Basic Tutorial With Codeship for DevOps Beginners

CI/CD Build History

CI/CD Build History

Once you know the fundamentals of CI/CD, it’s all the same in other platforms like Circle CI, Codefresh, TeamCity, etc.

So without further ado, let’s get started.

First off, connect your VCS such as github, gitlab or bitbucket to the Codeship.

Connect the Project Repository to Codeship

Connect the Project Repository to Codeship

Once connected, select the project source repository and go to project -> project settings at the upper right corner of your project dashboard.