-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlamp-ubuntu.sh
executable file
·144 lines (124 loc) · 5.26 KB
/
lamp-ubuntu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#######################################
# Bash script para instalar la pila LAMP en Ubuntu
# Author: Samuel ([email protected])
declare -A opts_yes
opts_yes=([yes]=1 [YES]=1 [y]=1 [Y]=1)
# Verificar si se accedió como usuario root
if ((EUID)); then
echo "Este script debe ejecutarse como root" 1>&2
exit 1
fi
read -p 'Actualizar apt? [y/n]: ' r_apache2_opt
# Actualización del SO
if ((opts_yes[$r_apache2_opt])); then
apt update -y
fi
read -p 'Instalar Apache2? [y/n]: ' r_apache2_opt
## Instalación de apache
if ((opts_yes[$r_apache2_opt])); then
apt install apache2 -y
ufw allow in "Apache"
ufw status
fi
read -p 'Instalar Mysql? [y/n]: ' r_apache2_opt
# Instalación de MySQL database server
if ((opts_yes[$r_apache2_opt])); then
# Contraseña para el root de mysql
read -p 'db_root_password [secretpasswd]: ' db_root_password
echo
export DEBIAN_FRONTEND="noninteractive"
debconf-set-selections <<<"mysql-server mysql-server/root_password password $db_root_password"
debconf-set-selections <<<"mysql-server mysql-server/root_password_again password $db_root_password"
apt install mysql-server -y
fi
read -p 'Instalar php 8.1? [y/n]: ' r_apache2_opt
## Instalación de PHP
if ((opts_yes[$r_apache2_opt])); then
apt install software-properties-common && add-apt-repository ppa:ondrej/php -y
apt update -y
sudo apt upgrade -y
apt install php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-fpm libapache2-mod-fcgid php-mbstring php-zip php-gd php-json php-curl php-xml php-intl php8.1-xdebug -y
a2enmod proxy_fcgi setenvif && a2enconf php8.1-fpm
nano /etc/apache2/mods-enabled/dir.conf
systemctl reload apache2
systemctl status php8.1-fpm
php --version
read -p 'Instalar archivo info.php? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
cat config-files/info.php >>/var/www/html/info.php
fi
# Habilitación de Mod Rewrite
a2enmod rewrite
phpenmod mcrypt
fi
read -p 'Instalar phpmyadmin? [y/n]: ' r_apache2_opt
## Instalación de PhpMyAdmin
if ((opts_yes[$r_apache2_opt])); then
apt install wget zip unzip -y
wget -P ~/ https://files.phpmyadmin.net/phpMyAdmin/5.1.3/phpMyAdmin-5.1.3-all-languages.zip
wget -P ~/ https://files.phpmyadmin.net/phpmyadmin.keyring
gpg --import ~/phpmyadmin.keyring
wget -P ~/ https://files.phpmyadmin.net/phpMyAdmin/5.1.3/phpMyAdmin-5.1.3-all-languages.zip.asc
gpg --verify ~/phpMyAdmin-5.1.3-all-languages.zip.asc
unzip ~/phpMyAdmin-5.1.3-all-languages.zip -d /var/www/html
mv /var/www/html/phpMyAdmin-5.1.3-all-languages /var/www/html/phpmyadmin
cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
nano /var/www/html/phpmyadmin/config.inc.php
chmod 660 /var/www/html/phpmyadmin/config.inc.php
chown -R www-data:www-data /var/www/html/phpmyadmin
fi
read -p 'Configurar permisos para los usuarios www-data y USER para el directorio /var/www? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
# Configuracion general
read -p 'Nombre de usuario para vincular al grupo www-data: ' r_apache2_opt
usermod -a -G www-data $r_apache2_opt
chown -R www-data:www-data /var/www
chmod -R 775 /var/www
fi
read -p 'Reiniciar servidor apache2? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
systemctl reload apache2
fi
read -p 'Instalar y configurar herramientas de desarrollo? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
read -p 'Instalar y configurar node? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt install nodejs -y
mkdir ~/.npm-packages
npm config set prefix ~/.npm-packages
cat config-files/.bashrc >>~/.bashrc
source ~/.bashrc
npm install -g npm@latest
read -p 'Instalar y configurar yarn? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
npm install --global yarn
yarn --version
fi
fi
read -p 'Instalar y configurar symfony? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | tee /etc/apt/sources.list.d/symfony-cli.list
apt update -y
apt install symfony-cli
fi
read -p 'Instalar y configurar composer? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
fi
read -p 'Configurar puertos 8080 y 8081 para pruebas de aplicaciones symfony? [y/n]: ' r_apache2_opt
if ((opts_yes[$r_apache2_opt])); then
mkdir /var/www/symfony
mkdir /var/www/symfony/public
cat config-files/vhost-dev-symfony.conf >/etc/apache2/sites-available/vhost-dev-symfony.conf
cat config-files/vhost-prod-symfony.conf >/etc/apache2/sites-available/vhost-prod-symfony.conf
cat config-files/ports.conf >/etc/apache2/ports.conf
a2ensite vhost-dev-symfony.conf
a2ensite vhost-prod-symfony.conf
systemctl reload apache2
apache2ctl configtest
fi
fi