Clicky

Cómo instalar un servidor web dedicado paso a paso (método rápido) - 2ª parte

Categoría: Internet (Tutoriales y trucos)
Visitas: 1930
Servidores Kimsufi

Centos 8 + PHP + Apache + MariaDB utilizando el script de instalación de Virtualmin

En nuestro artículo anterior sobre la instalación de un servidor web dedicado vimos la instalación del Sistema Operativo Centos 8 y creación de particiones en una máquina Kimsufi. En este artículo vamos a instalar los paquetes necesarios para que el servidor pueda acoger páginas web funcionales.

Para ello utilizaremos un script de Virtualmin que instala casi todos los paquetes automáticamente, fundamentalmente PHP, Apache y MariaDB. Virtualmin necesita una serie de paquetes para funcionar por lo que el script primero comprueba que estén instalados en el sistema y sino los instala. Entre ellos está Perl, wget, curl, fetch, gnupg, BIND, Postfix, Dovecot, Amavis, SpamAssassin, Awastat, ProFTPD, etc.

Pasos preliminares

El script de instalación de Virtualmin incluye por defecto la versión 7.2 de PHP, por lo cual nosotros instalaremos primero la versión 7.3 de PHP y otros dos paquetes que se necesitan para que funcione Awastat:

Primero actualizamos el sistema que teníamos de la primera instalación que vimos en el artículo anterior:

# dnf check-update
# dnf update

Obtendremos una salida parecida a esta:

Upgraded:
qemu-guest-agent-15:2.12.0-88.module_el8.1.0+266+ba744077.2.x86_64
NetworkManager-1:1.20.0-5.el8_1.x86_64
NetworkManager-libnm-1:1.20.0-5.el8_1.x86_64
NetworkManager-team-1:1.20.0-5.el8_1.x86_64
NetworkManager-tui-1:1.20.0-5.el8_1.x86_64
audit-3.0-0.13.20190507gitf58ec40.el8.x86_64
audit-libs-3.0-0.13.20190507gitf58ec40.el8.x86_64
centos-gpg-keys-8.1-1.1911.0.9.el8.noarch
centos-release-8.1-1.1911.0.9.el8.x86_64
centos-repos-8.1-1.1911.0.9.el8.x86_64
glibc-2.28-72.el8_1.1.x86_64
glibc-all-langpacks-2.28-72.el8_1.1.x86_64
glibc-common-2.28-72.el8_1.1.x86_64
grub2-common-1:2.02-78.el8_1.1.noarch
grub2-pc-1:2.02-78.el8_1.1.x86_64
grub2-pc-modules-1:2.02-78.el8_1.1.noarch
grub2-tools-1:2.02-78.el8_1.1.x86_64
grub2-tools-extra-1:2.02-78.el8_1.1.x86_64
grub2-tools-minimal-1:2.02-78.el8_1.1.x86_64
kernel-tools-4.18.0-147.5.1.el8_1.x86_64
kernel-tools-libs-4.18.0-147.5.1.el8_1.x86_64
libarchive-3.3.2-8.el8_1.x86_64
openldap-2.4.46-11.el8_1.x86_64
openssh-8.0p1-4.el8_1.x86_64
openssh-clients-8.0p1-4.el8_1.x86_64
openssh-server-8.0p1-4.el8_1.x86_64
policycoreutils-2.9-3.el8_1.1.x86_64
policycoreutils-python-utils-2.9-3.el8_1.1.noarch
python3-audit-3.0-0.13.20190507gitf58ec40.el8.x86_64
python3-perf-4.18.0-147.5.1.el8_1.x86_64
python3-policycoreutils-2.9-3.el8_1.1.noarch
sqlite-libs-3.26.0-4.el8_1.x86_64
sudo-1.8.25p1-8.el8_1.1.x86_64
systemd-239-18.el8_1.4.x86_64
systemd-libs-239-18.el8_1.4.x86_64
systemd-pam-239-18.el8_1.4.x86_64
systemd-udev-239-18.el8_1.4.x86_64
tuned-2.12.0-3.el8_1.1.noarch

Installed:
kernel-4.18.0-147.5.1.el8_1.x86_64 kernel-core-4.18.0-147.5.1.el8_1.x86_64
kernel-modules-4.18.0-147.5.1.el8_1.x86_64 grub2-tools-efi-1:2.02-78.el8_1.1.x86_64
linux-firmware-20190516-94.git711d3297.el8.noarch

Complete!

Reiniciamos el servidor para aplicar los cambios:

# shutdown -r now

Abrimos de nuevo una consola y necesitaremos la versión 8 del repositorio EPEL y el repositorio REMI:

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Salida:

Installed:
epel-release-8-7.el8.noarch

Complete!

# dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Salida:

Installed:
remi-release-8.1-2.el8.remi.noarch

Complete!

Instalamos PHP con los siguientes comandos:

# dnf module reset php
# dnf module enable php:remi-7.3
# dnf update
# yum install php php-fpm php-gd php-mysqlnd

Salida:

Installed:
php-7.3.16-1.el8.remi.x86_64
php-fpm-7.3.16-1.el8.remi.x86_64
php-gd-7.3.16-1.el8.remi.x86_64
php-mysqlnd-7.3.16-1.el8.remi.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
php-mbstring-7.3.16-1.el8.remi.x86_64
php-opcache-7.3.16-1.el8.remi.x86_64
php-xml-7.3.16-1.el8.remi.x86_64
apr-1.6.3-9.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
centos-logos-httpd-80.5-2.el8.noarch
gd-2.2.5-6.el8.x86_64
httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64
httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch
httpd-tools-2.4.37-16.module_el8.1.0+256+ae790463.x86_64
jbigkit-libs-2.1-14.el8.x86_64
libXpm-3.5.12-7.el8.x86_64
libjpeg-turbo-1.5.3-10.el8.x86_64
libtiff-4.0.9-15.el8.x86_64
libwebp-1.0.0-1.el8.x86_64
mod_http2-1.11.3-3.module_el8.1.0+213+acce2796.x86_64
oniguruma-6.8.2-1.el8.x86_64
libxslt-1.1.32-3.el8.x86_64
mailcap-2.1.48-3.el8.noarch
libargon2-20171227-3.el8.x86_64
php-cli-7.3.16-1.el8.remi.x86_64
php-common-7.3.16-1.el8.remi.x86_64
php-json-7.3.16-1.el8.remi.x86_64
php-pdo-7.3.16-1.el8.remi.x86_64

Complete!

También necesitaremos instalar dos paquetes para que no nos de error Awastat: GeoIP y perl-Geo-IP (esto es importante):

# dnf install GeoIP

Installed:
GeoIP-1.6.12-7.el8.x86_64 GeoIP-GeoLite-data-2018.06-5.el8.noarch

Complete!

# rpm -Uhv https://kojipkgs.fedoraproject.org/packages/perl-Geo-IP/1.51/9.el8/x86_64/perl-Geo-IP-1.51-9.el8.x86_64.rpm


Retrieving https://kojipkgs.fedoraproject.org/packages/perl-Geo-IP/1.51/9.el8/x86_64/perl-Geo-IP-1.51-9.el8.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:perl-Geo-IP-1.51-9.el8 ################################# [100%]

En mi caso necesitaré algunos paquetes más de PHP para que Joomla! funcione:

# yum install php-zip php-mcrypt php-curl php-pear php-bcmath

Salida

Installed:
php-bcmath-7.3.16-1.el8.remi.x86_64 php-pear-1:1.10.10-4.el8.remi.noarch
php-pecl-mcrypt-1.0.3-1.el8.remi.7.3.x86_64 php-pecl-zip-1.18.2-1.el8.remi.7.3.x86_64
libmcrypt-2.5.8-26.el8.x86_64 libzip-1.6.1-1.el8.remi.x86_64
php-fedora-autoloader-1.0.1-2.el8.remi.noarch php-process-7.3.16-1.el8.remi.x86_64

Complete!

Comprobamos la versión:

# php -v


PHP 7.3.16 (cli) (built: Mar 17 2020 10:18:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.16, Copyright (c) 1999-2018, by Zend Technologies

Es posible que también necesitéis habilitar un módulo de PHP:

# yum module enable perl:5.26

Enabling module streams:
perl 5.26

Instalación de paquetes con el script de Virtualmin

Ahora que ya tenemos el sistema actualizado y preparado, descargaremos es script de instalación de Virtalmin en el directorio que escojas:

# wget -O install.sh https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh

--2020-04-06 21:44:43-- https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.36.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.36.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 32282 (32K) [text/plain]
Saving to: ‘install.sh’

install.sh 100%[=======================================================>] 31.53K --.-KB/s in 0.01s

2020-04-06 21:44:43 (2.55 MB/s) - ‘install.sh’ saved [32282/32282]

Ejecutamos el script de instalación:

# /bin/sh install.sh

Deberéis haber instalado con éxito Virtualmin/Webmin en vuestro sistema.

instalación de Virtualmin

Antes de abrir el panel de administración de Virtualmin es recomendable ejecutar:

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): Enter
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

 By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Y reiniciar Webmin:

# /etc/init.d/webmin restart

Tenemos que habilitar e iniciar Apache y MariaDB:

# systemctl enable httpd.service
# systemctl start httpd.service

# systemctl enable mariadb
# systemctl start mariadb

Ahora podréis acceder al login del panel escribiendo en vuestro navegador: https://ns381524.ip-91-121-80.eu:10000/
(cambiar ns381524.ip-91-121-80.eu por el nombre de vuestra máquina o la dirección IP del servidor)

login en Webmin/Virtualmin

Artículo anterior: Cómo instalar un servidor web dedicado paso a paso (método rápido) - 1ª parte : Instalación del Sistema Operativo Centos 8 y creación de particiones