nginx-dev/bin/adddomain

45 lines
1.0 KiB
Plaintext
Raw Normal View History

2024-09-08 00:37:19 +02:00
#!/bin/bash
function main() {
bold=$(tput bold)
normal=$(tput sgr0)
phpsocket="/run/php/root8.2.sock"
echo -n "${bold}Ingresa el dominio nombre del subdominio: $normal"
read -r domain
echo -e "Creando configración para \"$domain\" \U2705"
mkdir "/var/www/$domain"
echo "server {
listen 80;
index index.html index.php;
server_name $domain;
root /var/www/$domain;
location ~ \\.php\$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:$phpsocket;
}
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
}"> "/etc/nginx/sites-available/$domain"
ln -s "/etc/nginx/sites-available/$domain" "/etc/nginx/sites-enabled/"
if nginx -t && service nginx reload;
then
echo "${bold}Instalación finalizada con éxito $normal \U2705 "
echo ""
echo "URL: http://$domain/"
else
echo "${bold} Error al instalar la configuración nginx $normal \U274C"
fi
}
main