https://github.com/teomandeniz/server_from_nodejs
Setup a server with NodeJS
https://github.com/teomandeniz/server_from_nodejs
javascript ngnix nodejs
Last synced: 3 months ago
JSON representation
Setup a server with NodeJS
- Host: GitHub
- URL: https://github.com/teomandeniz/server_from_nodejs
- Owner: TeomanDeniz
- License: mit
- Created: 2025-05-30T18:32:12.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-06-08T15:51:20.000Z (4 months ago)
- Last Synced: 2025-06-08T16:33:53.060Z (4 months ago)
- Topics: javascript, ngnix, nodejs
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setting up the machine
```sh
apt update && apt upgrade -y
apt install nodejs ufw npm git nginx certbot python3-certbot-nginx -y
```Add these to `~/.bashrc`
```sh
alias log='cat /var/log/SERVER.log'
alias pop='git -C "__FRONTEND_PATH__" pull'
alias nr='systemctl restart node'
alias rn='systemctl restart node'
```# Ngnix
```sh
ufw allow 443
ufw allow 80
```Move your `NGNIX/http.conf` and `NGNIX/https.conf` files inside `/etc/nginx/conf.d`
```sh
systemctl start nginx
systemctl enable nginx
```# SSL Certificate
```sh
certbot --nginx -d YOUR_DOMAIN -d YOUR_DOMAIN_2
```# Setting up NODE service
```sh
vim /etc/systemd/system/SERVER.service
``````ini
[Unit]
Description=SERVER
After=network.target[Service]
ExecStartPre=rm -rf /var/log/node.log
ExecStart=/bin/sh -c 'exec /usr/bin/node __BACKEND_PATH__/INDEX.js >> /var/log/SERVER.log 2>&1'
WorkingDirectory=/root/ETICARET/NODE
Restart=always
RestartSec=1
User=root
Environment=NODE_ENV=production[Install]
WantedBy=multi-user.target
``````sh
systemctl daemon-reload
systemctl start SERVER
systemctl status SERVER
```