GNU/Linux >> Tutoriales Linux >  >> Cent OS

Cómo instalar Flarum Forum con Nginx y LE SSL en CentOS 8

Flarum es un software de foro gratuito, de código abierto y de próxima generación que le facilita iniciar y hacer crecer una comunidad en línea exitosa. Es un software simple, liviano, rápido y compatible con dispositivos móviles basado en PHP. Viene con un amplio conjunto de características que incluyen una interfaz de usuario elegante, interfaz de dos paneles, desplazamiento infinito, compositor flotante, totalmente receptivo y muchas más.

En este tutorial, explicaremos cómo instalar el foro Flarum en el servidor CentOS 8.

Requisitos

  • Un servidor que ejecuta CentOS 8.
  • Un nombre de dominio válido apuntado con la IP de su servidor
  • Se configura una contraseña raíz en el servidor.

Cómo empezar

Antes de comenzar, deberá instalar el repositorio EPEL y Remi en su sistema. Primero, instale el repositorio EPEL con el siguiente comando:

dnf install epel-release -y

A continuación, descargue e instale el repositorio de Remi con el siguiente comando:

wget http://rpms.remirepo.net/enterprise/remi-release-8.rpm
rpm -Uvh remi-release-8.rpm

Instalar Nginx, MariaDB y PHP

Primero, instale el servidor web Nginx y el servidor MariaDB con el siguiente comando:

dnf install nginx mariadb-server -y

Una vez que ambos paquetes estén instalados, deberá habilitar el módulo php:remi-7.3 para instalar PHP 7.3. Puede habilitarlo con el siguiente comando:

dnf module enable php:remi-7.3

Luego, instale PHP con otras dependencias requeridas con el siguiente comando:

dnf install php php-fpm php-common php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y

Una vez que todos los paquetes estén instalados, inicie el servicio Nginx, MariaDB y PHP-FPM y habilítelos para que se inicien después de reiniciar el sistema con el siguiente comando:

systemctl start nginx
systemctl start mariadb
systemctl start php-fpm
systemctl enable nginx
systemctl enable mariadb
systemctl enable php-fpm

Una vez que haya terminado, puede continuar con el siguiente paso.

Configurar base de datos MariaDB

De forma predeterminada, MariaDB no está protegido. Puede asegurarlo con el siguiente script:

mysql_secure_installation

Responda todas las preguntas como se muestra a continuación:

Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Una vez que haya terminado, inicie sesión en el shell de MariaDB con el siguiente comando:

mysql -u root -p

Proporcione su contraseña raíz cuando se le solicite, luego cree una base de datos y un usuario para Flarum con el siguiente comando:

MariaDB [(none)]> CREATE DATABASE flarumdb;
MariaDB [(none)]> GRANT ALL PRIVILEGES on flarumdb.* to 'flarum'@'localhost' identified by 'password';

A continuación, elimine los privilegios y salga del shell de MariaDB con el siguiente comando:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Una vez que haya terminado, puede continuar con el siguiente paso.

Configurar PHP-FPM para Nginx

A continuación, deberá configurar PHP-FPM para que funcione con Nginx. Puedes hacerlo editando el archivo www.conf:

nano /etc/php-fpm.d/www.conf

Cambie el nombre de usuario y grupo de apache a nginx como se muestra a continuación:

user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx

A continuación, busque la siguiente línea:

;listen = /run/php-fpm/www.sock

Y reemplácelo con la siguiente línea:

listen = 127.0.0.1:9000

Guarde y cierre el archivo cuando haya terminado. Luego, reinicie el servicio PHP-FPM para aplicar los cambios:

systemctl restart php-fpm

Instalar Flarum

Antes de instalar Flarum, deberá instalar Composer en su sistema.

Puede instalarlo con el siguiente comando:

curl -sS https://getcomposer.org/installer | php

Una vez instalado, debería obtener el siguiente resultado:

All settings correct for using Composer
Downloading...

Composer (version 1.9.2) successfully installed to: /root/composer.phar
Use it: php composer.phar

A continuación, mueva el archivo binario de Composer al directorio /usr/local/bin y otorgue el permiso adecuado:

mv composer.phar /usr/local/bin/composer
chmod 755 /usr/local/bin/composer

A continuación, cambie el directorio a la raíz del documento Nginx y cree un proyecto Flarum con el siguiente comando:

cd /var/www/html
composer create-project flarum/flarum . --stability=beta

A continuación, otorgue los permisos adecuados en el directorio raíz web de Nginx con el siguiente comando:

chown -R nginx:nginx /var/www/html
chmod -R 755 /var/www/html
chown -R nginx:nginx /var/lib/php

Una vez que haya terminado, puede continuar con el siguiente paso.

Configurar Nginx para Flarum

A continuación, deberá crear un archivo de configuración de host virtual de Nginx para Nginx. Puedes crearlo con el siguiente comando:

nano /etc/nginx/conf.d/flarum.conf

Agregue las siguientes líneas:

server {
    listen   80;
    server_name  flarum.example.com;

# note that these lines are originally from the "location /" block
root   /var/www/html/public;
index index.php index.html index.htm;

location / { try_files $uri $uri/ /index.php?$query_string; }
location /api { try_files $uri $uri/ /api.php?$query_string; }
location /admin { try_files $uri $uri/ /admin.php?$query_string; }

location /flarum {
    deny all;
    return 404;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~* \.html$ {
    expires -1;
}

location ~* \.(css|js|gif|jpe?g|png)$ {
    expires 1M;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types application/atom+xml
           application/javascript
           application/json
           application/vnd.ms-fontobject
           application/x-font-ttf
           application/x-web-app-manifest+json
           application/xhtml+xml
           application/xml
           font/opentype
           image/svg+xml
           image/x-icon
           text/css
           #text/html -- text/html is gzipped by default by nginx
           text/plain
           text/xml;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
   }

Guarde y cierre el archivo cuando haya terminado. A continuación, deberá aumentar el tamaño de hash_bucket en el archivo nginx.conf.

Puede hacerlo editando el archivo /etc/nginx/nginx.conf:

nano /etc/nginx/nginx.conf

Agregue la siguiente línea justo encima de la última línea:

server_names_hash_bucket_size 64;

Guarde y cierre el archivo. Luego, verifique Nginx por cualquier error de sintaxis con el siguiente comando:

nginx -t

Debería ver el siguiente resultado:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finalmente, reinicie el servicio Nginx y PHP-FPM para aplicar los cambios:

systemctl restart php-fpm
systemctl restart nginx

Configurar SELinux y Firewall

Primero, deberá crear una regla de firewall para permitir el servicio HTTP y HTTPS desde redes externas. Puedes permitirlo con el siguiente comando:

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

De manera predeterminada, SELinux está habilitado en CentOS 8. Por lo tanto, deberá configurar SELinux para que Flarum funcione correctamente. Puede configurar SELinux usando el siguiente comando:

setsebool httpd_can_network_connect on -P

Una vez que haya terminado, puede continuar con el siguiente paso.

Acceder a la interfaz de usuario web de Flarum

Ahora, abra su navegador web y escriba la URL http://flarum.example.com. Será redirigido a la siguiente página:

Proporcione el nombre de su foro, los detalles de la base de datos, el nombre de usuario del administrador, la contraseña y haga clic en Instalar Flarum botón. Una vez que la instalación se haya completado con éxito, debería ver el panel de control de Flarum en la siguiente página:

Asegure Flarum con Let's Encrypt SSL

Flarum ahora está instalado y configurado. Es hora de protegerlo con SSL gratuito de Let's Encrypt.

Para hacerlo, deberá descargar el cliente certbot en su servidor. Puede descargar y establecer el permiso correcto ejecutando el siguiente comando:

wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto

Ahora, ejecute el siguiente comando para obtener e instalar un certificado SSL para su sitio web flarum.

certbot-auto --nginx -d flarum.example.com

El comando anterior instalará primero todas las dependencias requeridas en su servidor. Una vez instalado, se le pedirá que proporcione una dirección de correo electrónico y acepte el término del servicio como se muestra a continuación:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y 


Obtaining a new certificate
Performing the following challenges:
http-01 challenge for flarum.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/flarum.conf

A continuación, deberá elegir si desea redirigir o no el tráfico HTTP a HTTPS, como se muestra a continuación:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Escriba 2 y presione Entrar para continuar. Una vez finalizada la instalación, debería ver el siguiente resultado:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/flarum.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://flarum.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=flarum.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/flarum.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/flarum.example.com/privkey.pem
   Your cert will expire on 2020-03-23. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

¡Eso es todo! Ahora puede acceder a su sitio web de Flarum usando la URL segura https://flarum.example.com.


Cent OS
  1. Cómo instalar Nextcloud con Nginx y PHP 7.3 en CentOS 8

  2. Cómo instalar ownCloud 9.1 con Nginx y MariaDB en CentOS 7

  3. Cómo instalar WordPress con HHVM y Nginx en CentOS 7

  4. Cómo instalar Nextcloud con Nginx y PHP7-FPM en CentOS 7

  5. Cómo instalar y configurar Varnish Cache 6 con Nginx en CentOS 8

Cómo instalar WonderCMS con Apache y Lets Encrypt SSL en CentOS 8

Cómo instalar Askbot con Nginx y Secure con Lets Encrypt en CentOS 8

Cómo instalar ElkArte Forum con Apache y Lets Encrypt SSL en CentOS 8

Cómo Instalar PrestaShop con Apache y Lets Encrypt SSL en CentOS 8

Cómo instalar OwnCloud 8 con Nginx y PHP-FPM en CentOS 6

Cómo instalar Let's Encrypt SSL con Nginx en CentOS 7