瀏覽代碼

Añadido instalarPHP y correciones menores

Guzmán Castanedo Villalba 5 年之前
父節點
當前提交
a3ae8292d9
共有 1 個文件被更改,包括 93 次插入19 次删除
  1. 93 19
      install

+ 93 - 19
install

@@ -28,13 +28,13 @@ comprobarError() {
 			error="$type $codeNum:\tInstalación interrumpida por el usuario.\n"
 			;;
 		2)
-			error="$type $codeNum:\tError interno (seleción express).\n"
+			error="$type $codeNum:\tError interno (selección express).\n"
 			;;
 		3)
-			error="$type $codeNum:\tError interno (seleción avanzada).\n"
+			error="$type $codeNum:\tError interno (selección avanzada).\n"
 			;;
 		100)
-			error="$type $codeNum:\tError interno (seleción del servidor web).\n"
+			error="$type $codeNum:\tError interno (selección del servidor web).\n"
 			;;
 		101)
 			error="\n$type $codeNum:\tError al instalar Apache2.\nDetalles:\n$extraInfo\n"
@@ -52,7 +52,7 @@ comprobarError() {
 			error="\n$type $codeNum:\tError interno (instalación Nginx).\n"
 			;;
 		200)
-			error="$type $codeNum:\tError interno (seleción de base de datos).\n"
+			error="$type $codeNum:\tError interno (selección de base de datos).\n"
 			;;
 		201)
 			error="\n$type $codeNum:\tError al instalar MySQL.\nDetalles:\n$extraInfo\n"
@@ -93,6 +93,21 @@ comprobarError() {
 		212)
 			error="$type $codeNum:\tImposible recargar base de datos.\n"
 			;;
+		300)
+			error="$type $codeNum:\tError interno (instalación PHP).\n"
+			;;
+		301)
+			error="$type $codeNum:\tError interno (Web Server no seleccionado).\n"
+			;;
+		302)
+			error="$type $codeNum:\tError al instalar PHP.\nDetalles:\n$extraInfo\n"
+			;;
+		303)
+			error="$type $codeNum:\tError al instalar Repositorio Remi.\nDetalles:\n$extraInfo\n"
+			;;
+		304)
+			error="$type $codeNum:\tSistema Operativo no compatible con PHP-7.2 ($OS $DIST $REV).\n"
+			;;
 		800)
 			error="$type $codeNum:\tEs necesario ser root ('sudo $0').\n"
 			;;
@@ -153,6 +168,7 @@ OSInfo() {
 			DIST=$(grep ^NAME= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
 			REV=$(grep ^VERSION= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
 			ID_LIKE=$(grep ^ID_LIKE= /etc/os-release | cut -d = -f 2 | cut -d '"' -f 2)
+			VERSION=$(grep ^VERSION_ID= /etc/os-release | cut -d = -f 2 | cur -d '"' -f 2)
 			for i in $ID_LIKE; do
 				#printf "$i\n"
 				case $i in
@@ -299,10 +315,12 @@ mostrarExpress() {
 }
 
 mostrarAvanzada() {
-	componentes=$(whiptail --title "INSTALACION AVANZADA" --checklist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge los componentes que quieres instalar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 7 \
-	"WebServer" "Instalar servidor web http/https" ON \
-	"Database" "Instalar una base de datos SQL" ON \
-	"PHP" "Instala PHP7" ON \
+	componentes=$(whiptail --title "INSTALACION AVANZADA" --checklist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge los componentes que quieres instalar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 6 \
+	"LAMP" "Linux + Apache + MySQL/MariaDB + PHP" ON \
+	"LEMP" "Linux + Nginx + MySQL/MariaDB + PHP" ON \
+#	"WebServer" "Instalar servidor web http/https" ON \
+#	"Database" "Instalar una base de datos SQL" ON \
+#	"PHP" "Instala PHP7" ON \
 	"SSL/TLS" "Instalar certificados para activar HTTPS" ON \
 	"MediaWiki" "Instalar wiki con MediaWiki" ON \
 	"Moodle" "Instalar campus virtual con Moodle" ON \
@@ -312,18 +330,32 @@ mostrarAvanzada() {
 	# Mejora: autodetección de componentes ya instalados
 	for i in $componentes; do
 		case $i in
-			\"WebServer\")
-				mostrarWebServer
-				progresoTotal=$((progresoTotal + 2))
-				;;
-			\"Database\")
+			\"LAMP\")
+				apacheOn=true
+				establecerFQDN
 				mostrarDatabase
-				progresoTotal=$((progresoTotal + 2))
+				phpOn=true
+				progresoTotal=$((progresoTotal + 6))
 				;;
-			\"PHP\")
+			\"LEMP\")
+				nginxOn=true
+				establecerFQDN
+				mostrarDatabase
 				phpOn=true
-				progresoTotal=$((progresoTotal + 2))
+				progresoTotal=$((progresoTotal + 6))
 				;;
+#			\"WebServer\")
+#				mostrarWebServer
+#				progresoTotal=$((progresoTotal + 2))
+#				;;
+#			\"Database\")
+#				mostrarDatabase
+#				progresoTotal=$((progresoTotal + 2))
+#				;;
+#			\"PHP\")
+#				phpOn=true
+#				progresoTotal=$((progresoTotal + 2))
+#				;;
 			\"SSL/TLS\")
 				# 2 Opciones: Let's Encrypt o Autofirmado
 				progresoTotal=$((progresoTotal + 2))
@@ -349,6 +381,7 @@ mostrarAvanzada() {
 }
 
 mostrarWebServer() {
+	# DEPRECATED
 	webServer=$(whiptail --title "SERVIDOR WEB" --radiolist "<ESPACIO>: seleccionar   <TAB>: cambiar   <FLECHAS>: moverse\n\nEscoge el servidor web que quieres usar:" $((ALTO * 9 / 10)) $((ANCHO * 9 / 10)) 2 \
 	"Apache" "Instalar el servidor web Apache2" ON \
 	"Nginx" "Instalar el servidor web Nginx" OFF \
@@ -492,7 +525,7 @@ instalarMySQL() {
 	if [ $debianOS = true ];then
 		result=$(apt-get -q -y install mysql-server mysql-client 2>&1)
 		comprobarError $? 201 $result
-	elif [ $rhelOS = true ]; then
+	elif [ $rhelOS = true ];then
 		# MySQL no disponible en RHEL. 2 opciones:
 		# 1) Instalar un repositorio adicional
 		# 2) No instalar MySQL en distribuciones RHEL
@@ -506,7 +539,7 @@ instalarMariaDB() {
 	if [ $debianOS = true ];then
 		result=$(apt-get -q -y install mariadb-server mariadb-client 2>&1)
 		comprobarError $? 202 $result
-	elif [ $rhelOS = true ]; then
+	elif [ $rhelOS = true ];then
 		result=$(yum -y install mariadb-server mariadb 2>&1)
 		comprobarError $? 202 $result
 	else
@@ -514,6 +547,47 @@ instalarMariaDB() {
 	fi
 }
 
+instalarPHP() {
+	# Instalamos PHP-7 de forma diferente si es junto a Apache o con Nginx
+	if [ $debianOS = true ];then
+		if [ $apacheOn = true ]; then
+			result=$(apt-get -q -y install php libapache2-mod-php php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
+			comprobarError $? 302 $result
+		elif [ $nginxOn = true ];then
+			result=$(apt-get -q -y install php-fpm libapache2-mod-php php-mysql php-intl php-mbstring php-mcrypt openssl 2>&1)
+			comprobarError $? 302 $result
+		else
+			comprobarError 1 301
+		fi
+	elif [ $rhelOS = true ];then
+		# Necesitamos un repositorio adicional para PHP-7 (EPEL-RELEASE)
+		result=$(yum -y install epel-release)
+		comprobarError $? 103 $result
+		# Necesitamos un repositorio adicional para PHP-7 (REMI-RELEASE)
+		if [ $VERSION = "7" ];then
+			result=$(rpm -U http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 2>&1)
+			comprobarError $? 303 $result
+		elif [ $VERSION = "6" ];then
+			result=$(rpm -U http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 2>&1)
+			comprobarError $? 303 $result
+		else
+			comprobarError 1 304
+		fi
+		# Instalamos PHP-7.2
+		if [ $apacheOn = true ];then
+			result=$(yum -y install php72 php72-php-pecl-mysql php72-php-intl php72-php-mbstring php72-php-pecl-mcrypt openssl 2>&1)
+			comprobarError 1 302 $result
+		elif [ $nginxOn = true ];then
+			result=$(yum -y install php72 php72-php-fpm php72-php-pecl-mysql php72-php-intl php72-php-mbstring php72-php-pecl-mcrypt openssl 2>&1)
+			comprobarError $? 302 $result
+		else
+			comprobarError 1 301
+		fi
+	else
+		comprobarError 1 300
+	fi
+}
+
 habilitarServicio() {
 	# Arrancamos y habilitamos el servicio (con SystemD, Upstart o SystemV)
 	# Intentamos con systemctl (SystemD)
@@ -619,7 +693,7 @@ mostrarExpress
 		printf "Instalando PHP-7..."
 		{
 			printf "%s\n" $((100 * progreso / progresoTotal))
-			sleep 2
+			instalarPHP
 			progreso=$((progreso + 1))
 		} > >(whiptail --gauge "Instalando PHP-7..." $((ALTO * 4 / 10)) $((ANCHO * 9 / 10)) $((100 * progreso / progresoTotal)))
 		printf " OK.\n"