Instalar MySQL opción A
apt-get -y install mysql-server mysql-client
mysql_secure_installation
Ingresar password para root
Remover usuarios anónimos
Deshabilitar acceso root remoto
Eliminar las DB de testing
Reestablecer los privilegios
Instalar MariaDB opción B
apt-get -y install mariadb-server mariadb-client
mysql_secure_installation
Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y
Instalar Apache 2.4 + PHP 7 + Módulos
apt-get -y install apache2
apt-get -y install php7.0 libapache2-mod-php7.0
systemctl restart apache2
apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext
systemctl restart apache2
apt-get -y install php7.0-opcache php-apcu
apt-get install libapache2-mod-fastcgi php7.0-fpm
a2enmod actions fastcgi alias
systemctl restart apache2
a2enmod ssl
apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install certbot
Para obtener un certificado:
certbot --authenticator webroot --installer apache --webroot-path /var/www/{path-domain} -d {domain}
apt-get -y install phpmyadmin
Web server to configure automatically: <-- Select the option: apache2
Configure database for phpmyadmin with dbconfig-common? <-- Yes
MySQL application password for phpmyadmin: <-- Press enter, apt will create a random password automatically.
Cambiar url default por una personalizada:
nano /etc/apache2/conf-available/phpmyadmin.conf
y cambiar el alias /phpmyadmin
por el deseado.
Dar Acceso con todos los privilegios a un usuario:
mysql -u root -p
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
<-- cambiar myuser
y mypass
por el que deseen.
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'localhost' WITH GRANT OPTION;
<-- cambiar myuser
por el ingresado anteriormente.
FLUSH PRIVILEGES;
exit
Cambiar puerto SSH default 22 por custom ej: 3344
, editar nano /etc/ssh/sshd_config
Habilitar puertos para Apache 80 y 443 ufw allow in "Apache Full"
Habilitar puerto para ssh custom ufw allow 3344
Activar firewall ufw enable
Más info de configuración UFW
Editar nano /etc/apache2/conf-enabled/security.conf
y Agregar/Modificar según corresponda las siguientes opciones:
ServerTokens Prod
ServerSignature Off
<DirectoryMatch "/\.git">
Require all denied
</DirectoryMatch>
<FilesMatch "^(wp-config\.php|php\.ini|php5\.ini|install\.php|php\.info|readme\.md|README\.md|readme\.html|bb-config\.php|\.htaccess|\.htpasswd|readme\.txt|timthumb\.php|error_log|error\.log|PHP_errors\.log|\.svn)">
Require all denied
</FilesMatch>
<FilesMatch "\.(json)$">
Require all denied
</FilesMatch>
<FilesMatch "\.(sql)$">
Require all denied
</FilesMatch>
Header set X-Content-Type-Options: NOSNIFF
Header set X-Frame-Options: SAMEORIGIN
Ejecutar a2enmod headers
Editar nano /etc/apache2/apache2.conf
y modificar
<Directory /var/www/>
Options -Indexes
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Reiniciar apache: service apache2 restart