- ssh root@your_server_ip
- adduser username
- usermod -aG sudo username
- ufw app list
- ufw allow OpenSSH
- ufw enable
- ufw status
- ssh username@your_server_ip
- Set A, domain.com record to public_ip
- Set A, www.domain.com record to public_ip
- Set CNAME, if want sub.domain.com to public_ip
- sudo apt update
- sudo apt install nginx
- sudo ufw app list
- sudo ufw allow 'Nginx HTTP'
- sudo ufw status
- sudo systemctl status nginx
- sudo systemctl stop nginx
- sudo systemctl start nginx
- sudo systemctl restart nginx
- sudo systemctl reload nginx
- sudo systemctl disable nginx
- sudo systemctl enable nginx
- sudo add-apt-repository ppa:certbot/certbot
- sudo apt install python-certbot-nginx
- sudo nano /etc/nginx/sites-available/default
- server_name domain.com www.domain.com;
- sudo nginx -t
- sudo systemctl reload nginx
- sudo ufw status
- sudo ufw allow 'Nginx Full'
- sudo ufw delete allow 'Nginx HTTP'
- sudo ufw status
- sudo certbot --nginx -d domain.com -d www.domain.com
- Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process. The certbot package we installed takes care of this for us by adding a renew script to /etc/cron.d.
- sudo certbot renew --dry-run
-
sudo nano /etc/nginx/sites-available/default
-
` index index.html server_name domain.com www.domain.com location / { try_files $uri $uri/ = 404; } location /hello/ { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }
`
-
sudo nginx -t
-
sudo systemctl restart nginx
- sudo mkdir -p /var/www/example.com/html
- sudo chown -R $USER:$USER /var/www/example.com/html
- sudo chmod -R 755 /var/www/example.com
- nano /var/www/example.com/html/index.html
6.sudo nano /etc/nginx/sites-available/example.com 7. server { listen 80; listen [::]:80;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
} 8.sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ 9. sudo nano /etc/nginx/nginx.conf 10. server_names_hash_bucket_size 64; 11. sudo nginx -t 12. sudo systemctl restart nginx
- curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
- sudo apt-get install nodejs
- sudo npm install pm2@latest -g
- pm2 start hello.js
- pm2 startup systemd
- pm2 save
- pm2 stop app_name_or_id
- pm2 restart app_name_or_id
- pm2 list
Nodejs Install
sudo apt-get install nodejs; not needed
sudo npm install n -g
sudo n stable
logout then login again