Skip to content

Instantly share code, notes, and snippets.

@stories2
Last active July 9, 2018 08:15
Show Gist options
  • Save stories2/ec21338deb3a8464c534e32773ada56c to your computer and use it in GitHub Desktop.
Save stories2/ec21338deb3a8464c534e32773ada56c to your computer and use it in GitHub Desktop.
Ubuntu install

After boot

Check network

ifconfig -a

Check update & install upgrade

apt-get update
apt-get upgrade

Check is ssh installed

netstat -ntlp | sshd
service ssh status

Install sshd service

apt-get install openssh-server

Restart sshd service

service ssh restart
service ssh status

Check process TCP network status

netstat -nap | grep tcp

How to connect to server using ssh

ssh <USER ID>@<SERVER IP ADDRESS>

Example

sssh stories2@192.168.0.20

Install latest npm, nodejs

apt-get update
apt-get install nodejs
apt-get install npm

Check npm version

npm -v

Check node js version

nodejs -v

Install specific version of node

wget https://nodejs.org/dist/v6.11.5/node-v6.11.5-linux-x64.tar.gz
mkdir -p /opt/nodejs
tar -xvzf node-v6.11.5-linux-x64.tar.gz -C /opt/nodejs/
cd /opt/nodejs/
mv node-v6.11.5-linux-x64 6.11.5
ln -s 6.11.5 current
ln -s /opt/nodejs/current/bin/node /bin/node
node -v

Server Program setting

Install dependencies

sudo npm install body-parser@1.18.3 ejs@2.6.1 express@4.16.3 heroku-ssl-redirect@0.0.4 log-color@1.0.0 mysql@2.15.0 path@0.12.7 socket.io@2.1.1 sqlstring@2.3.1 web-push@3.3.1
npm install forever --global

Setup env vars

vim /etc/profile

Write env vars

  • Goto bottom and type these
export PAPERTRAIL_API_TOKEN=<TOKEN>
export PUSH_SERVER_PRIVATE_KEY=<PRIVATE KEY>
export PUSH_SERVER_PUBLIC_KEY=<PUBLIC KEY>

Update env vars

source /etc/profile

Test Run backend program

node index.js

Install Mysql 5.7

Install Mysql

apt-get update
apt-get install mysql-server=5.7.22-0ubuntu0.16.04.1
mysql_secure_installation

Check is Mysql process running

systemctl status mysql.service

Setup enable remote access

vim /etc/mysql/mysql.conf.d/mysqld.cnf

Edit conf

bind-address            = 127.0.0.1 --> bind-address            = 0.0.0.0

Add permission to user

grant all privileges on *.* to root@'%' identified by <PASSWORD>;
flush privileges;

Install telnet

Install telnet

apt-get install telnet
apt-get install xinetd telnetd

Check telnet status

/etc/init.d/xinetd status

Restart telnet

/etc/init.d/xinetd restart

Setup ufw

Allow specific port

ufw allow <PORT NUMBER>

Install FTP

Install FTP

apt-get update
apt-get install vsftpd

Backup conf

cp /etc/vsftpd.conf /etc/vsftpd.conf.orig

Edit conf

vim /etc/vsftpd.conf

Edit conf

#write_enable=YES --> write_enable=YES
#chroot_local_user=YES --> chroot_local_user=YES
#utf8_filesystem=YES --> utf8_filesystem=YES
allow_writeable_chroot=YES

Restart FTP

systemctl restart vsftpd

Add new user

adduser <USER ID>

Set user can use super user permission

vim /etc/sudoers
  • Type these down below root ALL=(ALL:ALL) ALL
<USER ID> ALL=(ALL:ALL) ALL

Startup autorun backend server program

Setup startup file

vim /etc/rc.local

And type this command

source /etc/profile
forever /home/stories2/Kiosk-Node-Server/index.js &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment