Created
September 18, 2025 03:58
-
-
Save felipealfonsog/389060d3b48bb6dd23bd33fb6940b944 to your computer and use it in GitHub Desktop.
Apache, PHP, and MariaDB have been installed and configuration script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Actualizar sistema | |
| sudo pacman -Syu --noconfirm | |
| # Instalar Apache, PHP, módulos PHP y MariaDB | |
| sudo pacman -S --noconfirm apache php php-apache mariadb | |
| # Configurar Apache para PHP | |
| sudo sed -i '/#LoadModule mpm_event_module modules\/mod_mpm_event.so/s/^#//' /etc/httpd/conf/httpd.conf | |
| sudo sed -i '/LoadModule mpm_event_module modules\/mod_mpm_event.so/s/^/#/' /etc/httpd/conf/httpd.conf | |
| sudo sed -i '/#LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so/s/^#//' /etc/httpd/conf/httpd.conf | |
| sudo sed -i '/#LoadModule php_module modules\/libphp.so/s/^#//' /etc/httpd/conf/httpd.conf | |
| # Habilitar index.php en DirectoryIndex | |
| sudo sed -i '/DirectoryIndex/s/index.html/index.php index.html/' /etc/httpd/conf/httpd.conf | |
| # Añadir configuración de PHP al final del archivo httpd.conf | |
| sudo tee -a /etc/httpd/conf/httpd.conf > /dev/null <<EOL | |
| # Configuración de PHP | |
| <FilesMatch \.php$> | |
| SetHandler application/x-httpd-php | |
| </FilesMatch> | |
| <FilesMatch \.phps$> | |
| SetHandler application/x-httpd-php-source | |
| Require all denied | |
| </FilesMatch> | |
| # Deshabilitar Multi-Processing Module para PHP | |
| <IfModule mpm_prefork_module> | |
| LoadModule php_module modules/libphp.so | |
| </IfModule> | |
| EOL | |
| # Reiniciar Apache para aplicar cambios | |
| sudo systemctl restart httpd | |
| # Iniciar y habilitar Apache para iniciar al arranque | |
| sudo systemctl enable --now httpd | |
| # Instalar y configurar MariaDB | |
| sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql | |
| sudo systemctl enable --now mariadb | |
| # Configurar MariaDB (contraseña de root) | |
| sudo mysql_secure_installation <<EOF | |
| Y | |
| password | |
| password | |
| Y | |
| Y | |
| Y | |
| Y | |
| EOF | |
| # Reiniciar Apache nuevamente para asegurar que todo esté funcionando correctamente | |
| sudo systemctl restart httpd | |
| echo "Apache, PHP, and MariaDB have been installed and configured successfully!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment