-
Notifications
You must be signed in to change notification settings - Fork 0
/
3-redirection
executable file
·39 lines (28 loc) · 1.17 KB
/
3-redirection
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
#!/usr/bin/env bash
# Configures a new ubuntu machine by installing
# Nginx where it should be listening on port 80
# Serve a page that would return a Hello World string
#
echo -e "Updating and installing Nginx.\n"
sudo apt-get update -y -qq && \
sudo apt-get install nginx -y
echo -e "\nSetting up some minor stuff.\n"
# starting nginx service
sudo service nginx start
# allowing nginx on firewall
sudo ufw allow 'Nginx HTTP'
# Give the user ownership to website files for easy editing
sudo chown -R "$USER":"$USER" /var/www/html
sudo chmod -R 755 /var/www
# Backup default index
cp /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.html.bckp
# Creating new index
echo -e "Hello World!" > /var/www/html/index.nginx-debian.html
# Setting up /redirect_me to my portfolio website
sudo sed -i '24i\ rewrite ^/redirect_me https://www.femiajanaku.vercel.app permanent;' /etc/nginx/sites-available/default
# Set up a 404 page
echo "Ceci n'est pas une page" >> /var/www/html/error_404.html
sudo sed -i '25i\ error_page 404 /error_404.html;' /etc/nginx/sites-available/default
# Restarting nginx
sudo service nginx restart
echo -e "\nCompleted.\n"