Advertisement
sergio_educacionit

deploy_site.sh

Nov 12th, 2022
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <VirtualHost *:80>
  2.  
  3. ServerAdmin webmaster@localhost
  4. DocumentRoot /var/www/html
  5. ServerName ec2-54-234-167-188.compute-1.amazonaws.com
  6. ServerAlias www.ec2-54-234-167-188.compute-1.amazonaws.com
  7.  
  8.  
  9. ErrorLog /error.log
  10. CustomLog /access.log combined
  11.  
  12. </VirtualHost>
  13. root@ec2-54-234-167-188:/home/ubuntu# cat deploy_site.sh
  14. #!/bin/bash
  15.  
  16. # Definir el hostname
  17. # este servidor solo correr un sitio web
  18. # definir el hotname con el fqdn: misitio.com.ar
  19.  
  20. read -p "Ingrese hostname: " host
  21.  
  22.  
  23. hostnamectl set-hostname $host
  24.  
  25.  
  26. read -p "Independicar directorio de datos para '$host'? y/n" crfs
  27.  
  28.  
  29. if [ $crfs == y ]; then
  30.  
  31. # detenemos el servicio
  32. systemctl stop apache2
  33.  
  34. # creamos el filesystem para xvdb
  35.  
  36. mkfs.xfs /dev/xvdb
  37.  
  38. # agregar entrada en el fstab
  39.  
  40. echo "/dev/xvdb /var/www xfs defaults 0 2" >> /etc/fstab
  41.  
  42. # montar el nuevo filesystem
  43.  
  44. mount -a
  45.  
  46. # recrear el document root
  47.  
  48. mkdir -p /var/www/html
  49.  
  50. # crear testigo
  51.  
  52. echo "Testigo" > /var/www/html/index.html
  53.  
  54. # Encender servicio apache2
  55.  
  56. systemctl start apache2
  57. fi
  58.  
  59.  
  60. # Configurar vhost de apache
  61.  
  62. echo "<VirtualHost *:80>
  63.  
  64. ServerAdmin webmaster@localhost
  65. DocumentRoot /var/www/html
  66. ServerName $host
  67. ServerAlias www.$host
  68.  
  69.  
  70. ErrorLog ${APACHE_LOG_DIR}/error.log
  71. CustomLog ${APACHE_LOG_DIR}/access.log combined
  72.  
  73. </VirtualHost>" > /etc/apache2/sites-available/000-default.conf
  74.  
  75. # Cargar nuevas configuraciones
  76.  
  77. systemctl reload apache2
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement