forked from justinmajetich/AirBnB_clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0-setup_web_static.sh
executable file
·54 lines (42 loc) · 1.2 KB
/
0-setup_web_static.sh
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
#!/usr/bin/env bash
# sets up your web servers for the deployment of web_static
# Update servers repository and install nginx
apt update
apt -y install nginx
# create project directories
mkdir -p /data/web_static/shared/
mkdir -p /data/web_static/releases/test/
# create initial html
cat << EOF | tee /data/web_static/releases/test/index.html
<html>
<head>
</head>
<body>
Holberton School
</body>
</html>
EOF
# create a symlink to ..release/test/ dir
ln -sf /data/web_static/releases/test/ /data/web_static/current
# give ownership of /data/ to the current user
chown -R ubuntu:ubuntu /data/
# set up nginx server configuration
SERVER=$(hostname)
SERVER_CONFIG="server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
add_header X-Served-By '$SERVER';
try_files \$uri \$uri/ =404;
}
location /hbnb_static {
add_header X-Served-By '$SERVER';
alias /data/web_static/current;
}
}"
bash -c "echo -e '$SERVER_CONFIG' > /etc/nginx/sites-available/default"
/etc/init.d/nginx restart
exit 0