Advertisement
kwabenasapong

Untitled

Dec 22nd, 2022 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.95 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # configuring my servers as web servers
  3.  
  4. # Update and install nginx
  5. sudo apt-get update -y
  6. sudo apt-get install nginx -y
  7.  
  8. # Create necessary directories
  9. sudo mkdir -p /data/web_static/shared/
  10. sudo mkdir -p /data/web_static/releases/test/
  11.  
  12. # Create index.html
  13. echo "This is $(hostname) an ALX student server" | sudo tee /data/web_static/releases/test/index.html
  14.  
  15. # Create symlinks
  16. sudo rm -rf /data/web_static/current
  17. sudo ln -sf /data/web_static/releases/test/ /data/web_static/current
  18. sudo rm -rf /etc/nginx/sites-enabled
  19. sudo ln -sf /etc/nginx/sites-available/ /etc/nginx/sites-enabled
  20.  
  21. # Change ownership
  22. sudo chown -hR ubuntu:ubuntu /data/
  23.  
  24. # configure Nginx Servers
  25. replace="server_name _;"
  26. new="server_name _;\n\n\tlocation \/hbnb_static\/ \{\n\t\talias \/data\/web_static\/current\/;\n\t\}"
  27. sudo sed -i "s/$replace/$new/" /etc/nginx/sites-enabled/default
  28.  
  29. # Restart Nginx
  30. sudo service nginx restart                
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement