forked from justinmajetich/AirBnB_clone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
0-setup_web_static.sh
executable file
·53 lines (50 loc) · 1.33 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
#!/usr/bin/env bash
#Bash script that sets up your web servers for the deployment of web_static.
apt-get -q update
apt-get -qy install nginx
DW="/data/web_static"
mkdir -p $DW/releases/test/
mkdir -p $DW/shared/
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Airbnb deploy</title>
</head>
<body>
Airbnb deploy
</body>
</html>' > "$DW/releases/test/index.html"
ln -sf $DW/releases/test $DW/current
chown -R ubuntu:ubuntu /data/
NGPT="/etc/nginx"
HTML="/var/www/html"
url="https://github.com/solayof/"
echo "server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
error_page 404 /404.html;
root $HTML;
location / {
index index.nginx-debian.html index.html index.htm index.php;
}
location /hbnb_static {
alias $DW/current/;
}
location /redirect_me {
return 301 $url;
}
}" > "$NGPT/sites-available/default"
rm /etc/nginx/sites-enabled/default
ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
mkdir -p $HTML
echo "Hello World!" > "$HTML/index.nginx-debian.html"
echo "Ceci n'est pas une page" > "$HTML/404.html"
header="add_header X-served-By \$hostname"
if ! grep -q "$header" $NGPT/nginx.conf;
then
sed -i "/http {.*/a $header;" $NGPT/nginx.conf
fi
service nginx restart