nodejs_mysql

A simple nodejs and bun similar applications that runs on port 3000. they use mysql database to fetch data and render html template using ejs nodejs application is in node_server.js and bun application is in bun_server.js

Requirements

nginx

install nginx

sudo apt install nginx -y

configure nginx

cd nginx
sudo cp qa_polls.conf /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/qa_polls.conf /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default

restart nginx

sudo systemctl restart nginx

mysql server

install mysql server

sudo apt install mysql-server -y

create database

sudo mysqladmin create qa_polls
```s

#### create user
```bash
sudo mysql
CREATE USER 'qa_polls'@'localhost' IDENTIFIED BY 'qa_polls';
GRANT ALL PRIVILEGES ON qa_polls.* TO 'qa_polls'@'localhost';

import the database

cd mysql_dumps
sudo mysql qa_polls < qa_polls.sql

Installation

nodejs

# install nodejs
curl -s https://deb.nodesource.com/setup_18.x | sudo bash
sudo apt install nodejs -y

# install dependencies
npm install

# start server
```bash
node node_server.js

bun

# install unzip
sudo apt install unzip -y
# install bun
curl -fsSL https://bun.sh/install | bash

# install dependencies
bun install

# start server
bun bun_server.js