Skip to content

Instantly share code, notes, and snippets.

@prcongithub
Last active March 6, 2023 18:38
Show Gist options
  • Save prcongithub/c2dddd76b7154aeb954a to your computer and use it in GitHub Desktop.
Save prcongithub/c2dddd76b7154aeb954a to your computer and use it in GitHub Desktop.
Setup Ubuntu with NodeJS, MySQL, Nginx, Postgres, Ruby, Rails etc.

Setup NodeJS

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g express
sudo npm install -g express-generator
sudo npm install -g nodemon
express demo_app -e ejs
cd demo_app
npm install
nodemon bin/www

Install MySQL

sudo apt-get update
sudo apt-get install mysql-server
mysql -u root -p
create database testdb;
use testdb;
create table users(name varchar(255), email varchar(63));
npm install mysql
In connection.js
var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : 'rot880',
  database : 'testdb'
});
connection.connect();
module.exports = connection;
# In routes file
var connection =  require('../db/connection');
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
  if (err) throw err;
  console.log('The solution is: ', rows[0].solution);
});

Install git

sudo apt-get install git-core

Setup ZSH

sudo apt-get install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
chsh -s `which zsh`
sudo shutdown -r 0

Install nginx

sudo apt-get install nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment