Guest User

Untitled

a guest
Jan 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. domain=$1
  4. root="/var/www/$domain/html"
  5. block="/etc/nginx/sites-available/$domain"
  6.  
  7. # Create the Document Root directory
  8. sudo mkdir -p $root
  9.  
  10. # Assign ownership to your regular user account
  11. sudo chown -R $USER:$USER $root
  12.  
  13. # Create the Nginx server block file:
  14. sudo tee $block > /dev/null <<EOF
  15. server {
  16. listen 80;
  17. listen [::]:80;
  18.  
  19. root /var/www/$domain/html;
  20. index index.html index.htm;
  21.  
  22. server_name $domain www.$domain;
  23.  
  24. location / {
  25. try_files $uri $uri/ =404;
  26. }
  27. }
  28.  
  29.  
  30. EOF
  31.  
  32. # Link to make it available
  33. sudo ln -s $block /etc/nginx/sites-enabled/
  34.  
  35. # Test configuration and reload if successful
  36. sudo nginx -t && sudo service nginx reload
Add Comment
Please, Sign In to add comment