-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvhost_install_ubuntu.sh
More file actions
52 lines (33 loc) · 1.4 KB
/
vhost_install_ubuntu.sh
File metadata and controls
52 lines (33 loc) · 1.4 KB
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
#!/bin/bash
# Colors for the outputs uses tput
GREEN="$(tput setaf 2)"
CLEAR="$(tput sgr0)"
BOLD="$(tput bold)"
# Enable a virtual host in Historico 3
read -p 'Nombre del proyecto (sin .local, sin espacios en blanco ni caracteres raros): ' sitename
read -e -p 'IP local, si es localhost dejar esta : ' -i '127.0.0.1' siteip
# Add the register in /etc/hosts:
sed -i -e '$a'$siteip' '$sitename /etc/hosts
# Check if folder exist if not create it
if [ ! -d /home/veiss/historico3/$sitename ]; then
cp -rp /home/veiss/historico3/_plantilla /home/veiss/historico3/$sitename
chown -R veiss:www-data /home/veiss/historico3/$sitename
else
echo $BOLD$GREEN'El directorio ya existe y no ha sido creado'$CLEAR
fi
# Virtual Host
if [ ! -f /etc/apache2/sites-available/$sitename.local.conf ]; then
cp /etc/apache2/sites-available/1-plantilla.local.conf /etc/apache2/sites-available/$sitename.local.conf
# Search and replace in the created conf file
sed -i -e 's/____nombreproyecto____/'$sitename'/g' /etc/apache2/sites-available/$sitename.local.conf
# Enable site for apache2
a2ensite $sitename.local.conf
# Reload apache service
service apache2 restart
echo $BOLD$GREEN'Virtual Host Creado correctamente --> http://'$sitename$CLEAR
echo $BOLD$GREEN'Este es el status de Apache: '$CLEAR
# Output apache status
service apache2 status
else
echo $BOLD$GREEN'El Virtual Host ya existe y no ha sido creado'$CLEAR
fi