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

Cómo instalar Shopware 6 con NGINX y Lets Encrypt en CentOS 8

Shopware es una plataforma gratuita y de código abierto que lo ayuda a iniciar su propio sitio web de comercio electrónico para potenciar su negocio en línea. Proporciona muchas herramientas útiles que lo ayudan a crear y personalizar una tienda en línea totalmente receptiva. Es muy similar a Magento. En comparación con Magento, Shopware es una aplicación muy poderosa, fácil de usar y flexible. Te ayuda a crear y administrar contenido y productos fácilmente desde cualquier dispositivo con su moderna interfaz de usuario.

En este tutorial, le mostraremos cómo instalar Shopware con Nginx y Let's Encrypt SSL en CentOS 8.

Requisitos

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

Instalar servidor LEMP

Shopware se ejecuta en un servidor web y se basa en PHP con componentes Symfony y Zend, y utiliza MySQL o MariaDB como base de datos. Por lo tanto, deberá instalar Nginx, MariaDB, PHP y otras extensiones en su servidor. Puede instalarlos todos con el siguiente comando:

dnf install nginx mariadb-server php php-cli php-intl php-fpm php-common php-mysqli php-curl php-json php-zip php-gd php-xml php-mbstring php-opcache unzip -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 al reiniciar el sistema con el siguiente comando:

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

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

Configurar PHP-FPM

De forma predeterminada, PHP-FPM está configurado para ejecutarse como usuario y grupo de apache. Por lo tanto, deberá configurarlo para que se ejecute como usuario y grupo de Nginx. Puede hacerlo editando el archivo /etc/php-fpm.d/www.conf:

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

Cambie las siguientes líneas:

user = nginx 
group = nginx 

Guarde y cierre el archivo, luego cree un directorio de sesión y establezca la propiedad adecuada con el siguiente comando:

mkdir -p /var/lib/php/session 
chown -R nginx:nginx /var/lib/php/session

A continuación, edite el archivo php.ini y modifique algunas configuraciones recomendadas:

nano /etc/php.ini

Cambie las siguientes líneas:

memory_limit = 512M
upload_max_filesize = 20M
date.timezone = Asia/Kolkata

Guarde y cierre el archivo y luego reinicie el servicio PHP-FPM para aplicar los cambios:

systemctl restart php-fpm

Crear una base de datos para Shopware

A continuación, deberá crear una base de datos y un usuario para Shopware. Primero, conéctese a MariaDB usando el siguiente comando:

mysql

Una vez conectado, cree una base de datos y un usuario con el siguiente comando:

MariaDB [(none)]> CREATE DATABASE shopware;
MariaDB [(none)]> GRANT ALL ON shopware.* TO 'shopware' IDENTIFIED BY 'password';

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

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

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

Descargar Shopware

A continuación, deberá descargar la última versión de Shopware para su sitio web oficial. Primero, cree un directorio para Shopware dentro del directorio raíz de Nginx:

mkdir /var/www/html/shopware

A continuación, descargue Shopware con el siguiente comando:

wget https://www.shopware.com/en/Download/redirect/version/sw6/file/install_v6.3.5.0_ba08dbfc07784b5cefe7837f2abbda69dbf5b8b7.zip -O shopware.zip

Una vez completada la descarga, extraiga el archivo descargado en el directorio de software de la tienda:

unzip shopware.zip -d /var/www/html/shopware

A continuación, establezca el permiso y la propiedad adecuados con el siguiente comando:

chown -R nginx:nginx /var/www/html/shopware
chmod -R 775 /var/www/html/shopware

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

Configurar Nginx para Shopware

A continuación, cree un archivo de configuración de host virtual Nginx para Shopware con el siguiente comando:

nano /etc/nginx/conf.d/shopware.conf

Agregue las siguientes líneas:

server {
    listen 80;

    # Handle / to index.php
    index index.php;

    # Our server name
    server_name shopware.example.com;

    # Where the code is located
    root /var/www/html/shopware/public;

    # Needed for Shopware install / update
    location /recovery/install {
        index index.php;
        try_files $uri /recovery/install/index.php$is_args$args;
    }

    location /recovery/update/ {
        if (!-e $request_filename){
            rewrite . /recovery/update/index.php last;
        }
    }

    # Forward any not found file to index.php. Also allows to have beautiful urls like /homemade-products/
    location / {
        try_files $uri /index.php$is_args$args;
    }

    # Let php-fpm handle .php files
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        fastcgi_read_timeout 300s;
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        http2_push_preload on;
    }
}

Guarde y cierre el archivo, luego verifique el Nginx para cualquier error de sintaxis con el siguiente comando:

nginx -t

Deberías obtener el siguiente resultado:

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

A continuación, reinicie el servicio Nginx para aplicar los cambios:

systemctl restart nginx

También puede verificar el estado de Nginx usando el siguiente comando:

systemctl status nginx

Deberías obtener el siguiente resultado:

? nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           ??php-fpm.conf
   Active: active (running) since Tue 2021-02-02 00:40:04 EST; 19s ago
  Process: 76059 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 76057 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 76054 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 76060 (nginx)
    Tasks: 3 (limit: 12523)
   Memory: 5.5M
   CGroup: /system.slice/nginx.service
           ??76060 nginx: master process /usr/sbin/nginx
           ??76061 nginx: worker process
           ??76062 nginx: worker process

Feb 02 00:40:04 centos8 systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Feb 02 00:40:04 centos8 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Feb 02 00:40:04 centos8 nginx[76057]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Feb 02 00:40:04 centos8 nginx[76057]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Feb 02 00:40:04 centos8 systemd[1]: Started The nginx HTTP and reverse proxy server.

Configurar SELinux y Firewall

De forma predeterminada, SELinux está habilitado en CentOS 8. Por lo tanto, deberá configurar el contexto de SELinux para Shopware. Puedes configurarlo con el siguiente comando:

setsebool httpd_can_network_connect on -P
chcon -R -u system_u -t httpd_sys_rw_content_t -r object_r /var/www/html/shopware

A continuación, permita los puertos 80 y 443 a través del cortafuegos con el siguiente comando:

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

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

Acceder a la interfaz web de Shopware

Ahora, abra su navegador web y escriba la URL http://shopware.example.com .

Seleccione su idioma y haga clic en Siguiente botón. Asegúrese de que se hayan cumplido todos los requisitos y luego haga clic en Siguiente botón. Debería ver la siguiente página:

Acepte los GTC y haga clic en Siguiente botón. Debería ver la siguiente página:

Proporcione su base de datos, nombre de usuario, contraseña y haga clic en Inicio instalación botón. Una vez que se haya completado la instalación, debería ver la siguiente página:

Haga clic en la página Siguiente. Se le pedirá que proporcione el nombre de su tienda, la dirección de correo electrónico, la moneda, el país, el nombre de usuario del administrador, la contraseña y haga clic en Siguiente. botón. Será redirigido al panel de control de Shopware:

Proporcione toda la información y haga clic en el botón Siguiente. Debería ver la siguiente página:

Instale los complementos de idioma deseados y haga clic en Siguiente botón. Debería ver la siguiente página:

Instale datos de demostración u omita esto y haga clic en Siguiente botón. Debería ver la siguiente página:

Haga clic en Configurar más tarde . Debería ver la siguiente página:

Haga clic en Omitir botón. Debería ver la siguiente página:

Haga clic en Siguiente botón. Deberías ver la siguiente página:

Haga clic en Omitir botón. Debería ver la siguiente página:

Haga clic en Finalizar botón. Debería ver la página de bienvenida de Shopware:

Asegure Shopware con Let's Encrypt SSL

A continuación, deberá instalar la utilidad Certbot en su sistema para descargar e instalar Let's Encrypt SSL para el dominio Let's Chat.

Puede instalar el cliente Certbot con 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

A continuación, obtenga e instale un certificado SSL para su dominio de Lets con el siguiente comando:

certbot-auto --nginx -d shopware.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 nginx, Installer nginx
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 shopware.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/shopware.conf

A continuación, seleccione 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/shopware.conf

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/shopware.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/shopware.example.com/privkey.pem
   Your cert will expire on 2021-04-2. 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

Ahora puede acceder a Shopware de forma segura utilizando la URL https://shopware.example.com.

Conclusión

¡Felicidades! ha instalado y configurado con éxito Shopware con Nginx y Let's Encrypt SSL en CentOS 8. Ahora puede alojar fácilmente su propia tienda en línea con Shopware. Siéntase libre de preguntarme si tiene alguna pregunta.


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 Nextcloud con Nginx y PHP7-FPM en CentOS 7

  4. Cómo instalar Laravel 5.x con Nginx y PHP-FPM 7.1 en CentOS 7

  5. Cómo instalar Let's Encrypt en CentOS 8 con Nginx

Cómo instalar Vanila Forum y asegurarlo con Lets Encrypt en CentOS 8

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

Cómo instalar Shopware 6 con Nginx y Lets Encrypt SSL en Ubuntu 20.04

Cómo instalar Shopware con NGINX y Lets encrypt en Debian 9

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