GNU/Linux >> Tutoriales Linux >  >> Panels >> Panels

Cómo instalar Shopware 5 en Ubuntu 16.04 con MariaDB, PHP-FPM y Nginx

En este artículo verás cómo instalar Shopware 5 en Ubuntu 16.04 utilizando MariaDB, PHP-FPM y Nginx. Shopware es una plataforma de comercio electrónico moderna y de código abierto, escrita en PHP sobre componentes de Symfony y Zend. Es una de las soluciones más potentes del mercado para tiendas online de tamaño medio y grande.

La guía está probada en Ubuntu 16.04, aunque debería funcionar en otras distribuciones Linux para servidores.

Aviso: Ubuntu 16.04 dejó de recibir soporte en abril de 2021 y Shopware 5 está en fin de vida (Shopware 6 es la línea actual). Para un proyecto nuevo, planifica desde el inicio una LTS moderna y Shopware 6 con PHP 8.x.

1. Accede a tu VPS por SSH

ssh user@vps_IP

2. Actualiza el sistema e instala paquetes básicos

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common nano wget ant

3. Instala MariaDB 10.1

[user]$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
[user]$ sudo add-apt-repository 'deb [arch=amd64,i386] https://ftp.osuosl.org/pub/mariadb/repo/10.1/ubuntu xenial main'
[user]$ sudo apt-get update
[user]$ sudo apt-get install -y mariadb-server

Asegura la instalación:

[user]$ mysql_secure_installation

Crea la base de datos y el usuario de Shopware:

[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE shopware;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON shopware.* TO 'shopware'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

4. Instala PHP y los módulos necesarios

[user]$ sudo apt-get -y install php-fpm php-cli php-json php-curl php-gd php-mysql php-xml php-mbstring

Ajusta la configuración de PHP (512 MB de memoria, 100 MB de subida y zona horaria UTC):

sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/cli/php.ini
sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/cli/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/7.0/fpm/php.ini
sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/7.0/fpm/php.ini

Crea un pool de PHP-FPM dedicado a tu usuario (si todavía no lo tienes):

[user]$ sudo nano /etc/php/7.0/fpm/pool.d/your_user_name.conf
[your_user_name]
user = your_user_name
group = your_user_name
listen = /var/run/php/php7.0-your_user_name-fpm.sock
listen.owner = your_user_name
listen.group = your_user_name
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Sustituye your_user_name por tu nombre de usuario y reinicia el servicio:

[user]$ sudo service php7.0-fpm restart

5. Descarga e instala Shopware

Descarga la última versión desde GitHub (en el momento de redactar esta guía, la 5.1.6):

[user]$ wget https://github.com/shopware/shopware/archive/v5.1.6.zip
[user]$ unzip v5.1.6.zip
[user]$ mv shopware-5.1.6 ~/myShopware.com
[user]$ rm -f v5.1.6.zip

Prepara la configuración y la conexión a la base de datos:

[user]$ cd ~/myShopware.com/build
[user]$ ant configure
[user]$ ant build-unit

Descarga las imágenes de prueba:

[user]$ cd ~/myShopware.com
[user]$ wget https://releases.s3.shopware.com/test_images.zip
[user]$ unzip test_images.zip

6. Instala y configura Nginx

[user]$ sudo apt-get install nginx

Genera el certificado SSL autofirmado:

[user]$ sudo mkdir -p /etc/nginx/ssl
[user]$ cd /etc/nginx/ssl
[user]$ sudo openssl genrsa -des3 -passout pass:x -out shopware.pass.key 2048
[user]$ sudo openssl rsa -passin pass:x -in shopware.pass.key -out shopware.key
[user]$ sudo rm shopware.pass.key
[user]$ sudo openssl req -new -key shopware.key -out shopware.csr
[user]$ sudo openssl x509 -req -days 365 -in shopware.csr -signkey shopware.key -out shopware.crt

Si no quieres las advertencias típicas de los certificados autofirmados, adquiere un certificado de una autoridad de confianza o utiliza Let's Encrypt.

Crea el bloque de servidor de Nginx:

[user]$ sudo nano /etc/nginx/sites-available/myShopware.com
server {
    listen 443;
    server_name myShopware.com;
    root /home/your_user_name/myShopware.com;
    index shopware.php index.php;

    location / {
        rewrite files/documents/.* /engine last;
        rewrite backend/media/(.*) /media/$1 last;
        try_files $uri $uri/ /shopware.php$args;
    }

    ssl on;
    ssl_certificate /etc/nginx/ssl/shopware.crt;
    ssl_certificate_key /etc/nginx/ssl/shopware.key;
    ssl_session_timeout 5m;
    ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    access_log /var/log/nginx/shopware.access.log;
    error_log /var/log/nginx/shopware.error.log;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-your_user_name-fpm.sock;
        fastcgi_index shopware.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht { deny all; }
}

server {
    listen 80;
    server_name myShopware.com;
    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://$server_name$request_uri? permanent;
}

Cambia your_user_name por tu usuario, activa el sitio y reinicia Nginx:

[user]$ sudo ln -s /etc/nginx/sites-available/myShopware.com /etc/nginx/sites-enabled/myShopware.com

7. Comprueba la configuración y reinicia Nginx

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

Listo: Shopware 5 queda instalado en tu VPS Ubuntu 16.04. El usuario y la contraseña por defecto son demo; cámbialos inmediatamente después del primer acceso. Para la administración diaria, consulta la documentación oficial de Shopware.

Panels
  1. Instalar Cockpit CMS en Ubuntu 16.04 con Nginx y PHP-FPM 7.0

  2. Instalar Lychee en un VPS Ubuntu 14.04

  3. Cómo instalar Microweber en Ubuntu 14.04

  4. Cómo instalar WikkaWiki en Ubuntu

  5. Cómo instalar Rukovoditel en Ubuntu 16.04

Instalar Symphony CMS en un VPS Ubuntu 14.04

Cómo instalar Mautic en Ubuntu 14.04

Cómo instalar Sonerezh en Ubuntu 14.04

Instala Gogs en un VPS Ubuntu 14.04

Instala Magento 2 en un VPS Ubuntu 14.04

Cómo instalar Miniflux en Ubuntu 14.04