-
Notifications
You must be signed in to change notification settings - Fork 0
/
fw_addsite
executable file
·43 lines (33 loc) · 1.08 KB
/
fw_addsite
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
#!/bin/bash
#if $(id -g) != "0" ] && "É necessário executar esse sistema com permissão. Execute da seguinte forma: sudo addvhost" fi
VHOST_LOCATION="/etc/nginx/sites-available"
USER_DIR="/home/f5consult"
clear
read -p "Informe qual será o novo domínio: " site
clear
mkdir $USER_DIR/$site
chown `whoami`:`whoami` $USER_DIR/$site
cat > $VHOST_LOCATION/$site << EOF
server {
listen 80;
server_name $site www.$site;
root $USER_DIR/$site;
index index.php;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
include snippets/fastcgi-php.conf;
}
}
EOF
ln -s $VHOST_LOCATION/$site /etc/nginx/sites-enabled/$site
# Restart
echo "Domínio $site criado com sucesso"
read -p "Reiniciar o nginx agora para aplicar a configuração do novo site?" yn
case $yn in
[Yy]* ) systemctl restart nginx; clear; echo "Fim do processo";;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac