57 lines
1.3 KiB
Bash
57 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
function main() {
|
|
bold=$(tput bold)
|
|
normal=$(tput sgr0)
|
|
mainDomain="kj5.top"
|
|
phpsocket="/run/php/root8.2.sock"
|
|
|
|
echo -n "${bold}Ingresa el dominio nombre del subdominio: $normal"
|
|
read -r domain
|
|
domain=$domain.$mainDomain
|
|
echo -e "Creando configración para \"$domain\" \U2705"
|
|
|
|
mkdir "/var/www/$domain"
|
|
|
|
echo "server {
|
|
listen 80;
|
|
server_name $domain;
|
|
return 301 https://\$server_name\$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
|
|
ssl_certificate /etc/nginx/ssl/fullchain.cer;
|
|
ssl_certificate_key /etc/nginx/ssl/certificate.key;
|
|
|
|
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: https://$domain/"
|
|
else
|
|
echo "${bold} Error al instalar la configuración nginx $normal \U274C"
|
|
fi
|
|
}
|
|
|
|
main
|