-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact.nginx.ubuntu.deployer.sh
More file actions
executable file
·58 lines (52 loc) · 1.75 KB
/
react.nginx.ubuntu.deployer.sh
File metadata and controls
executable file
·58 lines (52 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# React App hosting with NGINX & Node.JS
# @author Deepjyoti Mukherjee <djmsuman@gmail.com>
echo -e "\nUpdating full system..."
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get auto-remove -y
echo -e "\nInstalling NGINX server..."
sudo apt-get install -y nginx
echo -e "\nAllowing NGINX through Firewall..."
sudo ufw allow 'Nginx HTTP'
echo -e "\nInstalling Node.JS & NPM..."
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install npm
sudo npm install --global npm
sudo npm install --global n
n latest
sudo ln -sf /usr/local/bin/node /usr/bin/nodejs
echo -e "\nInstalling Yarn packege manager..."
sudo npm install --global yarn
echo -e "\nAdding user to www-data group in order to allow access permission for NGINX..."
sudo usermod -a -G www-data ubuntu
sudo chown -R ubuntu:www-data /var/www/html
echo -e "\nUpdate default server block to serve..."
sudo rm -f /etc/nginx/sites-available/default
sudo cat > /etc/nginx/sites-available/default <<- 'EOF'
# NGINX ServerBlocks are same as Apache VirtualHosts
# Default server configuration for NGINX
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
# Document root for server
root /var/www/html/build;
# Define Error & Access log paths
error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log combined;
# Serve default file in following order
index index.html index.htm index.js;
server_name _;
location / {
try_files $uri $uri/ /index.html =404;
}
}
EOF
sudo rm -f /var/www/html/index.nginx-debian.html
sudo service nginx restart
echo -e "\nSetup complete... Happy Hosting! :D"