0% found this document useful (0 votes)
144 views28 pages

Configuración de Servidor Web en CentOS 7

This document provides instructions for installing and configuring multiple PHP versions (PHP 5.6 and PHP 7.2) with Apache and Nginx on CentOS 7. It describes how to install each PHP version and its dependencies, configure PHP-FPM, set up virtual hosts in Apache and Nginx to route requests to the appropriate PHP versions, install MariaDB 10 and MySQL, and secure the installations with Let's Encrypt.

Uploaded by

Andres Sosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views28 pages

Configuración de Servidor Web en CentOS 7

This document provides instructions for installing and configuring multiple PHP versions (PHP 5.6 and PHP 7.2) with Apache and Nginx on CentOS 7. It describes how to install each PHP version and its dependencies, configure PHP-FPM, set up virtual hosts in Apache and Nginx to route requests to the appropriate PHP versions, install MariaDB 10 and MySQL, and secure the installations with Let's Encrypt.

Uploaded by

Andres Sosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

<VirtualHost 192.168.1.

200:443>
ServerAdmin contactos@[Link]
DocumentRoot /var/www/html/
ServerName [Link]
SSLEngine on
#SSLCertificateFile /etc/letsencrypt/live/[Link]/[Link]
#SSLCertificateKeyFile
/etc/letsencrypt/live/[Link]/[Link]
#SSLCertificateChainFile
/etc/letsencrypt/live/[Link]/[Link]
</VirtualHost>

INSTALACIÓN CENTOS 7 LINODE

Verifica el nombre de host de tu Linode.


hostname
hostname -f

actualizar centos

sudo yum update

deshabilitamos selinux

nano /etc/sysconfig/selinux

cambiamos a disabled y reiniciamos

reboot

INSTALAR MULTIPLE PHP CON APACHE

yum install httpd

yum install epel-release

yum install yum-utils

yum install [Link]

yum install php56

yum install php72

yum install php56-php-fpm

yum install php72-php-fpm

systemctl stop php56-php-fpm


systemctl stop php72-php-fpm

semanage port -a -t http_port_t -p tcp 9072

semanage port -a -t http_port_t -p tcp 9056

sed -i 's/:9000/:9056/' /etc/opt/remi/php56/php-fpm.d/[Link]

sed -i 's/:9000/:9072/' /etc/opt/remi/php72/php-fpm.d/[Link]

systemctl start php72-php-fpm

systemctl start php56-php-fpm

cat > /var/www/cgi-bin/[Link] << EOF

ingresar

#!/bin/bash

exec /bin/php56-cgi

EOF

cat > /var/www/cgi-bin/[Link] << EOF

ingresar

#!/bin/bash

exec /bin/php72-cgi

EOF

sudo chmod 755 /var/www/cgi-bin/[Link]

sudo chmod 755 /var/www/cgi-bin/[Link]

cat > /etc/httpd/conf.d/[Link] << EOF

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

AddHandler php56-fcgi .php


Action php56-fcgi /cgi-bin/[Link]

Action php72-fcgi /cgi-bin/[Link]

<Directory /var/www/html/php56>

DirectoryIndex [Link]

AllowOverride all

Require all granted

</Directory>

<Directory /var/www/html/php72>

DirectoryIndex [Link]

AllowOverride all

Require all granted

</Directory>

EOF

mkdir -p /var/www/html/php56

mkdir -p /var/www/html/php72

echo "<?php phpinfo(); ?>" > /var/www/html/php56/[Link]

echo "<?php phpinfo(); ?>" > /var/www/html/php72/[Link]

echo "AddHandler php72-fcgi .php" > /var/www/html/php72/.htaccess

systemctl enable httpd

systemctl enable php56-php-fpm

systemctl enable php72-php-fpm

systemctl start httpd

systemctl start php56-php-fpm

systemctl start php72-php-fpm


firewall-cmd --permanent --add-service=http

firewall-cmd --reload

probar

[Link]

[Link]

INSTALAR NGINX

sudo yum install epel-release


sudo yum install nginx
sudo systemctl start nginx
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo systemctl enable nginx

sudo nginx -v

Carpeta para webs /usr/share/nginx/html


carpetas virtuales /etc/nginx/conf.d
archivo principal /etc/nginx/[Link]

HABILITAR HTTPS NGINX

sudo nano /etc/nginx/[Link]

buscar

server_name _;

reemplazar por

server_name [Link] [Link];

sudo systemctl reload nginx


instalamos leftencrypt

yum install certbot-nginx

certbot --nginx

programar la renovación del certificado

abrir puertos 443

INSTALAR LETSENCRYP

yum install certbot

certbot --nginx

certbot --apache

ACTUALIZAR Y AGREGAR SUBDOMINIOS

certbot --cert-name [Link] -d [Link] -d


[Link] -d [Link]
INSTALAR APACHE

sudo yum install httpd

ejecutar y activar apache

sudo systemctl enable [Link]

sudo systemctl start [Link]

hacemos una copia del archivo de configuracion de apache

cp /etc/httpd/conf/[Link] ~/[Link]

verificamos los servicios aceptados por el firewalld

sudo firewall-cmd --zone=public --list-services

sudo firewall-cmd --zone=public --add-service=http –permanent

INSTALAR MARIADB 10

nano /etc/[Link].d/[Link]

Y agregamos

# MariaDB 10.5 CentOS repository list - created 2021-04-03 17:37


UTC

# [Link]
[mariadb]
name = MariaDB
baseurl = [Link]
gpgkey=[Link]
gpgcheck=1

instalamos

sudo yum install MariaDB-server MariaDB-client

activar e iniciar mysql

sudo systemctl enable [Link]

sudo systemctl start [Link]

ejecutamos la configuracion segura de mysql

sudo mysql_secure_installation
HABILITAR EL CACHE DE CONSULTAS EN MYSQL

Buscar si esta habilitado

MYSQL> show variables like 'have_query_cache';

Revisamos la actual configuración

show variables like 'query_cache_%' ;

ACTUALIZAR HACIA MARIADB 10

nano /etc/[Link].d/[Link]

Y agregamos

# MariaDB 10.5 CentOS repository list - created 2021-04-03 17:37


UTC

# [Link]
[mariadb]
name = MariaDB
baseurl = [Link]
gpgkey=[Link]
gpgcheck=1

desinstalamos la versión actualizar

yum remove mariadb-server mariadb mariadb-libs

eliminamos cache

yum clean all

instalamos

sudo yum install MariaDB-server MariaDB-client

systemctl start mariadb

systemctl enable mariadb

mysql_upgrade

mysql -V
INSTALAR MULTIPLE PHP CON NGINX EN UN DOMINIO

yum install epel-release

yum install yum-utils

yum install [Link]

yum install php56

yum install php74

yum install php56-php-fpm

yum install php74-php-fpm

yum install php56-php-gd php56-php-json php56-php-mbstring php56-


php-mysqlnd php56-php-xml php56-php-xmlrpc php56-php-opcache
php56-php-pecl-xdebug php56-php-soap php56-php-zip

yum install php74-php-gd php74-php-json php74-php-mbstring php74-


php-mysqlnd php74-php-xml php74-php-xmlrpc php74-php-opcache
php74-php-pecl-xdebug php74-php-soap php74-php-zip

yum install php7.4-php-gd php7.4-php-json php7.4-php-mbstring


php7.4-php-mysqlnd php7.4-php-xml php7.4-php-xmlrpc php7.4-php-
opcache php7.4-php-pecl-xdebug php7.4-php-soap php7.4-php-zip

systemctl stop php56-php-fpm

systemctl stop php74-php-fpm

- Buscamos los archivos php en ambas versiones

find / \( -iname "[Link]" -o -name "[Link]" \)

- Obtenemos

/opt/remi/php56/root/etc/php-fpm.d/[Link]
/opt/remi/php56/root/etc/[Link]

/etc/[Link]

/etc/opt/remi/php74/php-fpm.d/[Link]

/etc/opt/remi/php74/[Link]

Editamos para cada versión el [Link] cambiando:

user = nginx

group = nginx

[Link] = nginx

[Link] = nginx

listen = /var/run/[Link] // para php7

listen = /var/run/[Link] // para php5

pm = static

pm.max_children = 12

Luego editamos para cada versión

nano /opt/remi/php56/root/etc/[Link]

y cambiamos

emergency_restart_threshold 10

emergency_restart_interval 1m

process_control_timeout 10s

(repetir para la version 7)

Luego en el [Link] de cada versión quitamos comentario y


cambiamos valor a:

cgi.fix_pathinfo=1

- creamos 1 carpeta para un dominio y 2 carpetas para cada


versión, ademas de los logs

mkdir -p /var/www/html/[Link]/

mkdir -p /var/www/html/[Link]/php56
mkdir -p /var/www/html/[Link]/php74

mkdir -p /var/log/nginx/rado/misitio.com_access_log

mkdir -p /var/log/nginx/rado/misitio.com_error_log

- asignamos permisos (opcional para probar)

chown -R root:nginx /var/www/html/[Link]/

chmod -R 755 /var/www/html/[Link]/


chown -R root:nginx /var/log/nginx/rado/misitio.com_access_log
chmod -R 660 /var/log/nginx/rado/misitio.com_access_log

chown -R root:nginx /var/log/nginx/rado/misitio.com_error_log


chmod -R 660 /var/log/nginx/rado/misitio.com_error_log

- creamos un archivo index para cada version

echo "<?php phpinfo(); ?>" >


/var/www/html/[Link]/php56/[Link]

echo "<?php phpinfo(); ?>" > /var/www/html/[Link]


/php74/[Link]

- ahora crearemos el sitio virtual que tendra las 2 versiones de


php en un solo dominio. Si son mas de 1 dominio, se crea un .conf
para cada uno

sudo nano /etc/nginx/conf.d/[Link]

- y copiamos: (modificar variables según caso)

server {

listen 80;

server_name [Link]; #ip o dominio del sitio

root /var/www/html/rado/; #ruta principal del sitio

autoindex on;
index [Link] [Link] [Link];

#access_log /var/log/nginx/rado/rado_access_log;

#error_log /var/log/nginx/rado/rado_error_log error;

location / {

try_files $uri $uri/ /[Link]?$query_string;

#cache de archivos

location ~* \.(jpg|jpeg|png|gif|ico)$ {

access_log off;

log_not_found off;

expires 30d;

location ~* \.(css|js)$ {

access_log off;

log_not_found off;

expires 30d;

location ~ \.php$ {

fastcgi_pass unix:/var/run/[Link];
#versión php56 por defecto para todo el sitio

fastcgi_index [Link];

fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;

include /etc/nginx/fastcgi_params;

fastcgi_buffer_size 128k;

fastcgi_buffers 256 16k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

location /sistema/quintanas { #subcarpeta que recive php56


por defecto

try_files $uri $uri/


/sistema/quintanas/[Link]?/$request_uri;

location /sistema/stamaria { #subcarpeta que recive php56 por


defecto

try_files $uri $uri/


/sistema/stamaria/[Link]?/$request_uri;

location /prueba2 { #subcarpeta que recibe php74

location ~ ^/prueba2/(.+\.php)$ {

fastcgi_pass unix:/var/run/[Link];
fastcgi_index [Link];

fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;

include /etc/nginx/fastcgi_params;

- Luego activamos, iniciamos, reinciamos los servicios

systemctl enable php56-php-fpm

systemctl start php56-php-fpm

systemctl enable php74-php-fpm

systemctl start php74-php-fpm

systemctl restart nginx

nginx -t

INSTALAR PHPMYADMIN - APACHE

rpm -iUvh [Link]


[Link]

yum -y update

yum -y install phpmyadmin

nano /etc/httpd/conf.d/[Link]
<Directory /usr/share/phpMyAdmin/>

AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>

# Apache 2.4

Require all granted

# <RequireAny>

# Require ip [Link]

# Require ip ::1

# </RequireAny>

</IfModule>

<IfModule !mod_authz_core.c>

Order Deny,Allow

Deny from all

Allow from localhost ::1 [Link]

# Apache 2.2

# Order Deny,Allow

# Deny from All

# Allow from [Link]

# Allow from ::1

</IfModule>

</Directory>

systemctl restart httpd

INSTALAR PHPMYADMIN – NGINX – PHP5.6

yum install epel-release


yum install phpmyadmin

ln -s /usr/share/phpMyAdmin /usr/share/nginx/html

systemctl restart nginx

systemctl restart php-fpm

sudo chgrp -R nginx /etc/phpMyAdmin

//para php56

chown -R nginx:nginx /opt/remi/php56/root/var/lib/php/session/

//para php7

chown -R nginx:nginx /var/opt/remi/php74/lib/php/session/

- Agregar el location en la configuracion del sitio virtual del


nginx

location /phpMyAdmin {
root /usr/share/;
index [Link] [Link] [Link];
location ~ ^/phpMyAdmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass [Link]:9001;
fastcgi_index [Link];
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|
html|xml|txt))$ {
root /usr/share/;
}
}
location /phpmyadmin {
rewrite ^/* /phpMyAdmin last;
}

INSTALAR PHPMYADMIN – NGINX – PHP7.4

wget [Link]
[Link]

sudo tar -zxvf [Link]

sudo mv phpMyAdmin-5.0.1-all-languages /usr/share/phpMyAdmin

sudo cp -pr /usr/share/phpMyAdmin/[Link]


/usr/share/phpMyAdmin/[Link]

EDITAR
sudo nano /usr/share/phpMyAdmin/[Link]

AGREGAR LA KEY QUE SE PEUDE OBTENER DE


[Link]
g=5cecac771c51c
$cfg['blowfish_secret'] = 'c}ol0O}jXX:Vx;}poX34Ro]zx/dvSAS2';

importamos las tablas de phpmyadmin


mysql < /usr/share/phpMyAdmin/sql/create_tables.sql -u root -p

editamos el archivo [Link] de nginx


nano /etc/nginx/conf.d/[Link]

y agregamos el location

location /phpMyAdmin {
root /usr/share/;
index [Link] [Link] [Link];
location ~ ^/phpMyAdmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/[Link];
fastcgi_index [Link];
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|
png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}

location /phpmyadmin {
rewrite ^/* /phpMyAdmin last;
}

INSTALAR POSTGRESQL

yum install
[Link]
x86_64/[Link]

yum -y groupinstall "PostgreSQL Database Server 9.4 PGDG"

/usr/pgsql-9.4/bin/postgresql94-setup initdb

systemctl start postgresql-9.4


systemctl enable postgresql-9.4

firewall-cmd --zone=public --add-port=5432/tcp --permanent

modificar

nano /var/lib/pgsql/9.4/data/[Link]

modificar la linea

listen_addresses = '*'

luego modificar

nano /var/lib/pgsql/9.4/data/pg_hba.conf

agregar la linea

host all all [Link] [Link] md5

grabamos y reiniciamos

systemctl restart postgresql-9.4

ahora ingresamos

su postgres

bash-4.1> psql

postgres=# alter user postgres with password 'tuclave';

salimos

postgres=# \q

probamos conexión

bash-1.4> psql -U postgres -W

INSTALAR PHP 7.4 CENTOS 7

yum install -y [Link]


[Link]

yum install -y yum-utils

yum-config-manager --enable remi-php74


yum update -y

yum install php74 php74-php-fpm php74-php-gd php74-php-json php74-


php-mbstring php74-php-mysqlnd php74-php-xml php74-php-xmlrpc
php74-php-opcache php74-php-pecl-xdebug

yum install php56 php56-php-fpm php56-php-gd php56-php-json php56-


php-mbstring php56-php-mysqlnd php56-php-xml php56-php-xmlrpc
php56-php-opcache php56-php-pecl-xdebug php56-php-soap php56-php-
mcrypt php56-php-cli php56-php-curl php56-php-ldap php56-php-zip

--Activar lectura [Link] por los htaccess

sudo a2enmod rewrite

sudo systemctl restart apache2

– también

sudo nano /etc/apache2/[Link]

<VirtualHost *:80>

<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

. . .
</VirtualHost>

sudo systemctl restart apache2

INSTALAR PHP 5.6 CENTOS 7

yum install [Link]


[Link]

yum install [Link]

yum install yum-utils

yum-config-manager --enable remi-php56

yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-


ldap php-zip php-fileinfo

php -v
INSTALAR WEBMIN

nano /etc/[Link].d/[Link]

copiar

[Webmin]

name=Webmin Distribution Neutral


#baseurl=[Link]
mirrorlist=[Link]
enabled=1

luego

wget [Link]

rpm --import [Link]

yum check-update

yum install webmin -y

chkconfig webmin on

service webmin start

firewall-cmd --zone=public --add-port=10000/tcp --permanent

CREAR USUARIO PARA WEBMIN POR CONSOLA

adduser andres

passwd andres

editamos

nano /etc/webmin/[Link]

agregamos

andres:x:0:::::::0:0

nano etc/webmin/[Link]

agregamos

andres: acl adsl-client apache at backup-config bacula-backup bandwidth bind8 burner cfengine
change-user cluster-copy cluster-cron cluster-passwd cluster-shell cluster-software cluster-
useradmin cluster-usermin cluster-webmin cpan cron custom dfsadmin dhcpd dnsadmin dovecot
exim exports fdisk fetchmail file filter firewall frox fsdump grub heartbeat htaccess-htpasswd
idmapd inetd init inittab ipfilter ipfw ipsec jabber krb5 ldap-client ldap-server ldap-useradmin lilo
logrotate lpadmin lvm mailboxes mailcap majordomo man mon mount net nis openslp pam pap
passwd phpini postfix postgresql ppp-client pptp-client pptp-server procmail proc pserver
qmailadmin quota raid samba sarg sendmail sentry servers shell shorewall smart-status smf
software spam squid sshd status stunnel syslog syslog-ng tcpwrappers telnet time tunnel updown
useradmin usermin vgetty webalizer webminlog webmin xinetd vsftpd mysql package-updates
system-status webmincron ajaxterm

reiniciamos
service webmin restart

BUSCAR Y REEMPLAZAR CADENAS CON EL COMANDO SED

sed -i "s%[Link]
[Link]

INSTALAR FTP

yum install vsftpd


activamos
systemctl enable [Link]
iniciamos
systemctl start [Link]
habilitamos puertos en firewalld
firewall-cmd --permanent --add-service=ftp
reiniciamos firewall
systemctl restart [Link]
Luego configuramos el servidor ftp ingresando a:
nano /etc/vsftpd/[Link]
Y modificamos los siguientes parametros: (estos puntos son gracias
al blog [Link] )
listen = YES : Para que se inicie con el sistema.
anonymous_enable = NO : No permitimos que usuarios anónimos puedan
conectarse a nuestro servidor. Es por seguridad.
local_enable = YES : Para poder conectarse con los usuarios
locales del servidor donde está instalado.
write_enable = YES : Si quieres que los usuarios puedan escribir y
no sólo descargar cosas.
local_umask = 022 : Esta máscara hace que cada vez que subas un
archivo, sus permisos sean 755. Es lo más típico en servidores
FTP.
chroot_local_user = YES
chroot_list_enable = YES : Sirven para que los usuarios locales
puedan navegar por todo el árbol de directorios del servidor.
Evidentemente esto sólo queremos permitírselo a ciertos usuarios,
para ello tenemos el siguiente parámetro.
chroot_list_file = /etc/vsftpd.chroot_list : Indicamos el fichero
donde están listados los usuarios que pueden navegar hacía arriba
por los directorios del servidor, lo normal es que sea el
administrador del servidor.
Comentamos la línea:
# Listen_ipv6 = YES
Grabamos y salimos. Adicionalmente agregamos una linea mas a
nuestro archivo de configuración:
echo 'allow_writeable_chroot=YES' >> /etc/vsftpd/[Link]
Luego creamos un grupo
groupadd ftp
Creamos un shell fantasma
mkdir /bin/ftp
Editamos el shell del sistema
nano /etc/shells
y agregamos en la última linea
/bin/ftp
Grabamos y salimos. Ahora crearemos un usuario:
sudo useradd -g ftp -d /ruta_carpeta_destino -c "Nombre del
Usuario" nombre_usuario
Le asignamos una clave
sudo passwd usuarioftp
Buscamos a nuestro usuario recien creado en:
nano /etc/passwd
Copiamos (CTRL+C) la linea de nuestro usuario parecida a:
usuario:x:1004:118:Nombre del
Usuario:/ruta_carpeta_destino:/bin/ftp
Y lo pegamos con un clic en:
nano /etc/vsftpd/chroot_list
NOTA: Si chroot_list no existe debemos crearlo
Finalmente reiniciamos y listo!
systemctl restart [Link]

CONFIGURAR MOODLE – NGINX

- editar en

nano /etc/opt/remi/php74/php-fpm.d/[Link]

- la linea

security.limit_extensions = .php

- agregar el sgte location en la configuración de ngnix

nano /etc/nginx/conf.d/[Link]

- agregar

location ~ ^(.+\.php)(.*)$ {

root /usr/share/nginx/html/moodle/;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index [Link];
fastcgi_pass [Link]:9000;
include /etc/nginx/[Link];
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

CONFIGURAR DOMINIO CON VPS Y CLOUDFARE COMO DNS

1. Ingresamos a [Link] y creamos una cuenta

2. Agregamos 1 sitio

3. Hacemos clic en DNS y agregamos


4. Añadir los registros

TIPO Nombre Contenido TTL Estado proxy

A [Link] [Link] Automático Solo DNS

A WWW [Link] Automático Solo DNS

5. Ir al panel del dominio y agregar los dns de cloudfare (los que


se proporcionan)

[Link]

[Link]

6. Luego volvemos al panel del cloudfare y seleccionamos SSL/TLS:

- En la pestaña “información general” seleccionamos “Extremo”

- En la pestaña “certificados de perimetro” habilitar, usar


siempre HTTPS, Reescritura automáticas HTTPS

7. vamos ahora al vps y por consola:

sudo yum install -y epel-release

sudo yum install -y certbot

sudo yum install -y python2-cloudflare python2-certbot-dns-


cloudflare

Inicie sesión en su cuenta de Cloudflare y navegue hasta la página


Perfil .

Haga clic en el botón Ver en la línea Clave API global .

Por razones de seguridad, se le pedirá que vuelva a ingresar la


contraseña de su cuenta de Cloudflare. Ingrese y valide el
CAPTCHA. Luego haga clic en el botón Ver nuevamente. Verás tu
clave de API:

Copie esta clave. Lo usará en el siguiente paso.

Ahora regrese a su servidor para continuar con el proceso de obtención del certificado.

sudo certbot

sudo nano /etc/letsencrypt/[Link]

agregamos

dns_cloudflare_email = your_cloudflare_login

dns_cloudflare_api_key = your_cloudflare_api_key

sudo chmod 600 /etc/letsencrypt/[Link]


sudo certbot certonly --cert-name your_domain --dns-cloudflare --
dns-cloudflare-credentials /etc/letsencrypt/[Link] --
server [Link] -d
"*.your_domain" -d your_domain

Output

...
Plugins selected: Authenticator dns-cloudflare, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): your email

Output

-------------------------------------------------------------------------------
Please read the Terms of Service at
[Link] You must
agree in order to register with the ACME server at
[Link]
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

Output

-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: N

Output

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/your_domain/[Link]
Your key file has been saved at:
/etc/letsencrypt/live/your_domain/[Link]
Your cert will expire on 2018-07-31. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: [Link]


Donating to EFF: [Link]

sudo ls /etc/letsencrypt/live/your_domain
Output

[Link] [Link] [Link] [Link] README

El README archivo contiene información sobre estos archivos:

cat /etc/letsencrypt/live/your_domain/README

This directory contains your keys and certificates.


`[Link]` : the private key for your certificate.
`[Link]`: the certificate file used in most server software.
`[Link]` : used for OCSP stapling in Nginx >=1.3.7.
`[Link]` : will break many server configurations, and should not be used
without reading further documentation (see link below).
We recommend not moving these files. For more information, see the Certbot
User Guide at [Link]

Desde aquí, puede configurar sus servidores con el certificado comodín. Por lo general, solo
necesitará dos de estos archivos: [Link] y [Link].

Luego procederemos a instalar los certificados en el webserver apache o nginx

antes instalamos

sudo yum install mod_ssl

abrimos puertos

sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT

sudo iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT

EN APACHE

en el [Link] editar o añadir

Listen 443

<VirtualHost *:443>
ServerAdmin contactos@[Link]
DocumentRoot /var/www/html/
ServerName [Link]
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/[Link]/[Link]
SSLCertificateKeyFile /etc/letsencrypt/live/[Link]/[Link]
#SSLCertificateChainFile /etc/letsencrypt/live/[Link]/[Link]
</VirtualHost>

grabamos y luego

sudo apachectl configtest


debemos tener la sgte salida

Output
. . .
Syntax OK

EN NGINX

en etcnginx/conf.d/[Link]

server {

listen 443 http2 ssl;

listen [::]:443 http2 ssl;

server_name [Link];

ssl_certificate /etc/letsencrypt/live/[Link]/[Link];

ssl_certificate_key /etc/letsencrypt/live/[Link]/[Link];

root /var/www/html;

si hay error renombrar el archivo coomo [Link], ese archivo debe estar
vacio o no existir

/etc/httpd/conf.d/[Link]

Common questions

Powered by AI

To configure a virtual host with SSL on Apache using Certbot certificates, first ensure that you have mod_ssl installed with 'sudo yum install mod_ssl'. Use Certbot to obtain certificates by running 'certbot --apache'. Edit your Apache configuration file (e.g., 'httpd.conf') to add a new VirtualHost block for port 443. Include 'SSLEngine on', 'SSLCertificateFile /etc/letsencrypt/live/your_domain/fullchain.pem', and 'SSLCertificateKeyFile /etc/letsencrypt/live/your_domain/privkey.pem' within the VirtualHost block. Test the Apache configuration using 'apachectl configtest' to ensure there are no syntax errors, then restart Apache with 'systemctl restart httpd'. This setup requires opening port 443 on your firewall .

To set up a secure FTP server on CentOS 7 with vsftpd, install vsftpd with 'yum install vsftpd'. Enable and start the service using 'systemctl enable vsftpd.service' and 'systemctl start vsftpd.service'. Open the FTP service in the firewall using 'firewall-cmd --permanent --add-service=ftp' and reload the firewall. Edit '/etc/vsftpd/vsftpd.conf' to disable anonymous access ('anonymous_enable=NO'), allow local users ('local_enable=YES'), and enable writable directories ('write_enable=YES'). Set 'chroot_local_user=YES' and create a 'chroot_list_file' for users needing directory traversal permissions. Restart vsftpd to apply changes. Implement additional security by creating a specific FTP group and shell restrictions .

To install and enable multiple PHP versions on Apache in CentOS 7, first, update the system using 'sudo yum update' and disable SELinux by modifying '/etc/sysconfig/selinux' to 'disabled', then reboot. Install Apache with 'yum install httpd' and enable it to start at boot with 'systemctl enable httpd.service'. Next, install EPEL and Remi repositories with 'yum install epel-release' and 'yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm'. Install desired PHP versions (e.g., PHP 5.6 and PHP 7.2) with 'yum install php56' and 'yum install php72', as well as related PHP-FPM packages and stop them initially. Configure the FPM ports using 'semanage port -a -t http_port_t -p tcp' for each version, and adjust 'www.conf' files to change the default listening ports to prevent conflicts. Enable and start both PHP-FPM services. Set up CGI scripts for handling PHP requests and assign necessary permissions. Restart Apache with 'systemctl restart httpd' and ensure PHP versions are working through the provided URLs .

To configure SSL with Let's Encrypt on Nginx using Cloudflare DNS, first, ensure Cloudflare is set as your DNS provider by updating your domain name system records to use Cloudflare's DNS servers. Install Certbot and its DNS plugin for Cloudflare using 'yum install -y certbot python2-cloudflare'. Configure a Cloudflare API key in '/etc/letsencrypt/cloudflareapi.cfg', including 'dns_cloudflare_email' and 'dns_cloudflare_api_key'. Set the necessary permissions on this file using 'sudo chmod 600'. Generate a wildcard certificate with Certbot using 'sudo certbot certonly --cert-name your_domain --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflareapi.cfg'. Configure Nginx to use this certificate by specifying the paths to 'fullchain.pem' and 'privkey.pem' in your server block. Ensure ports 80 and 443 are open on your server's firewall and test your configuration .

To update MariaDB to version 10 on CentOS 7 via repository installation, first modify or create the appropriate repository file '/etc/yum.repos.d/MariaDB10.repo' with details for the MariaDB 10.5 repository. Remove any existing MariaDB-related packages using 'yum remove mariadb-server mariadb mariadb-libs' and clean cache with 'yum clean all'. Install the new version using 'sudo yum install MariaDB-server MariaDB-client'. Start and enable the MariaDB service with 'systemctl start mariadb' and 'systemctl enable mariadb'. Run 'mysql_upgrade' to migrate databases to the new version .

To install and configure MariaDB 10 on CentOS 7, edit '/etc/yum.repos.d/MariaDB10.repo' to include the MariaDB repository details. Then, install MariaDB server and client packages with 'sudo yum install MariaDB-server MariaDB-client'. Enable and start the MariaDB service using 'systemctl enable mariadb.service' and 'systemctl start mariadb.service'. Secure the installation by running 'sudo mysql_secure_installation', which helps set a root password and remove anonymous users. Optionally, enable the query cache by checking 'show variables like 'query_cache_%';' to make adjustments in the configuration file if needed .

To host multiple PHP versions on a single domain using PHP-FPM under Apache, install different PHP versions along with their PHP-FPM packages. Configure each version's FPM pool to listen on a unique port or socket by editing their respective 'www.conf' files. Create CGI scripts in '/var/www/cgi-bin/' that point to each PHP-FPM version. Update the Apache configuration to associate PHP file extensions with the desired action using 'AddHandler' and 'Action' directives. Ensure each PHP version has a dedicated 'Directory' block in the Apache configuration allowing access to the designated PHP folders. Start and enable both PHP-FPM services and restart Apache .

To configure Moodle with Nginx and PHP 7.4 on CentOS 7, first ensure PHP-FPM is installed and listening on a socket or port for PHP 7.4. Edit the 'www.conf' file under '/etc/opt/remi/php74/php-fpm.d/' to set appropriate execution limits. Secure the installation by setting 'security.limit_extensions = .php'. In the Nginx configuration file, add a location block to handle PHP scripts, ensuring 'fastcgi_pass' matches the PHP-FPM configuration, and include necessary FastCGI parameters. Set Moodle's directory as the root and ensure directory permissions allow Nginx to read Moodle files. Restart Nginx and PHP-FPM services to apply changes .

To configure Nginx to run multiple PHP versions for different subdirectories on the same domain, first, ensure that Nginx is installed and running. Set up separate PHP-FPM pools listening on different sockets for each PHP version. In your Nginx configuration file (e.g., 'misitio.com.conf'), define the server block for your domain and specify the root directory. Use the 'location' directive to manage requests for different subdirectories. For a default PHP version, use 'fastcgi_pass' with the socket for PHP 5.6 under location '/'. For subdirectories requiring PHP 7.4, specify a 'location' block (e.g., '/prueba2') with 'fastcgi_pass' pointing to the PHP 7.4 socket. Ensure each block includes 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name' and other necessary FastCGI parameters to handle PHP scripts effectively .

To configure and access PHPMyAdmin securely on Nginx with PHP 7.4, first install PHP and PHP-FPM with 'yum install php74 php74-php-fpm' and ensure PHP-FPM is running. Download PHPMyAdmin and place it in your Nginx web root (e.g., '/usr/share/phpMyAdmin'). Configure Nginx by adding a location block in '/etc/nginx/conf.d/default.conf' for PHPMyAdmin, specifying 'root /usr/share/;'. Ensure PHP scripts are handled by including 'fastcgi_pass unix:/var/run/php7-fpm.sock' and other necessary FastCGI parameters in the block handling PHP requests ('location ~ ^/phpMyAdmin/(.+\.php)$'). Restart Nginx and PHP-FPM, then restrict access potentially to certain IPs by editing '/etc/phpMyAdmin/config.inc.php' or using Nginx access controls to improve security .

You might also like