Explorar el Código

* Corregidos errores en configurarMediaWiki()
* Corregidos ficheros de configuración de MediaWiki con Nginx

Guzmán Castanedo Villalba hace 6 años
padre
commit
53156ae596

+ 0 - 2
etc/nginx-debian/sites-available/mediawiki-ssl.conf

@@ -60,8 +60,6 @@ server {
 	#
 	location ~ \.php$ {
 		include snippets/fastcgi-php.conf;
-	#	# With php7.0-cgi alone:
-	#	fastcgi_pass 127.0.0.1:9000;
 	#	# With php7.2-fpm:
 		fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 	}

+ 0 - 2
etc/nginx-debian/sites-available/mediawiki.conf

@@ -37,8 +37,6 @@ server {
 	#
 	location ~ \.php$ {
 		include snippets/fastcgi-php.conf;
-	#	# With php7.0-cgi alone:
-	#	fastcgi_pass 127.0.0.1:9000;
 	#	# With php7.2-fpm:
 		fastcgi_pass unix:/run/php/php7.2-fpm.sock;
 	}

+ 0 - 2
etc/nginx-rhel/sites-available/mediawiki-ssl.conf

@@ -60,8 +60,6 @@ server {
 	#
 	location ~ \.php$ {
 		include snippets/fastcgi-php.conf;
-	#	# With php7.0-cgi alone:
-	#	fastcgi_pass 127.0.0.1:9000;
 	#	# With php7.2-fpm:
 		fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
 	}

+ 0 - 2
etc/nginx-rhel/sites-available/mediawiki.conf

@@ -37,8 +37,6 @@ server {
 	#
 	location ~ \.php$ {
 		include snippets/fastcgi-php.conf;
-	#	# With php7.0-cgi alone:
-	#	fastcgi_pass 127.0.0.1:9000;
 	#	# With php7.2-fpm:
 		fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
 	}

+ 31 - 13
install

@@ -192,6 +192,9 @@ comprobarError() {
 		815)
 			error="$type $codeNum:\t'openssl' no instalado.\nDetalles:\n$extraInfo\n"
 			;;
+		816)
+			error="$type $codeNum:\t'find' no instalado.\n"
+			;;
 		900)
 			error="$type $codeNum:\tError interno (habilitar servicio).\n"
 			;;
@@ -322,6 +325,8 @@ comprobarDependencias() {
 	# Comprobamos hostnamectl
 	which hostnamectl > /dev/null 2>&1
 	comprobarError $? 802
+	which find > /dev/null 2>&1
+	comprobarError $? 816
 	if [ $debianOS = true ];then
 		# Comprobamos apt-get
 		which apt-get > /dev/null 2>&1
@@ -1185,20 +1190,31 @@ configurarMediaWiki() {
 	crearDBMediaWiki
 	# Configuramos LocalSettings.php
 	# Configuramos VirtualHost
-	if [ $nginxOn = true ] && [ $debianOS = true ] && [ $sslOn = false ]; then
-		virtualHost="./etc/nginx-debian/sites-available/mediawiki.conf"
-	elif [ $nginxOn = true ] && [ $debianOS = true ] && [ $sslOn = true ]; then
-		virtualHost="./etc/nginx-debian/sites-available/mediawiki-ssl.conf"
-	elif [ $nginxOn = true ] && [ $rhelOS = true ] && [ $sslOn = false ]; then
-		virtualHost="./etc/nginx-rhel/sites-available/mediawiki.conf"
-	elif [ $nginxOn = true ] && [ $rhelOS = true ] && [ $sslOn = true ]; then
-		virtualHost="./etc/nginx-rhel/sites-available/mediawiki-ssl.conf"
-	fi
-	if [ ! -f $virtualHost ];then
+	if [ $nginxOn = true ];then
+		if [ $debianOS = true ] && [ $sslOn = false ]; then
+			virtualHost="./etc/nginx-debian/sites-available/mediawiki.conf"
+		elif [ $debianOS = true ] && [ $sslOn = true ]; then
+			virtualHost="./etc/nginx-debian/sites-available/mediawiki-ssl.conf"
+		elif [ $rhelOS = true ] && [ $sslOn = false ]; then
+			virtualHost="./etc/nginx-rhel/sites-available/mediawiki.conf"
+		elif [ $rhelOS = true ] && [ $sslOn = true ]; then
+			virtualHost="./etc/nginx-rhel/sites-available/mediawiki-ssl.conf"
+		fi
+		if [ ! -f $virtualHost ];then
+			comprobarError $? 502
+		fi
+		# Configuramos dominio, logs y php-fpm.sock
+		sed -i '/server_name/c\\tserver_name '$dominioMediaWiki';' $virtualHost
+		comprobarError $? 502
+		sed -i '/access_log/c\\taccess_log /var/log/nginx/'$dominioMediaWiki'-access.log;' $virtualHost
+		comprobarError $? 502
+		sed -i '/error_log/c\\terror_log /var/log/nginx/'$dominioMediaWiki'-error.log;' $virtualHost
 		comprobarError $? 502
+		socket=$(find /var/run -type s -name 'php*.sock')
+		sed -i 'fastcgi_pass/c\\t\tfastcgi_pass unix:'$socket';'
 	fi
 	instalarVirtualHost $virtualHost $dominioMediWiki
-	unset virtualHost
+	unset virtualHost socket
 }
 
 crearDBMediaWiki() {
@@ -1209,8 +1225,10 @@ crearDBMediaWiki() {
 		comprobarError $? 503
 	fi
 	dbFile=$dbDir"/mediawiki.sql"
-	echo -en "CREATE DATABASE $dominioMediaWiki;\n" > $dbFile
-	echo -en "GRANT ALL PRIVILEGES ON $dominioMediaWiki.* TO '$dominioMediaWiki'@'localhost' IDENTIFIED BY '$sqlPasswd';\n" >> $dbFile
+	nombreDBMW=$(echo $dominioMediaWiki | sed -e 's/\./-/g')
+	userDBMW=$(echo $dominioMediaWiki | sed -e 's/\./-/g')
+	echo -en "CREATE DATABASE $nombreDBMW;\n" > $dbFile
+	echo -en "GRANT ALL PRIVILEGES ON $nombreDBMW.* TO '$userDBMW'@'localhost' IDENTIFIED BY '$sqlPasswd';\n" >> $dbFile
 	mysql -u root --password=$sqlPasswd < $dbFile
 	control=$?
 	rm -f $dbFile 2>/dev/null