Instalar cerbot para nginx letsencrypt

Now that LEMP is installed, continue below to get Let’s Encrypt installed and configured. Let’s Encrypt now provides a Nginx client to automate this process. To get the client installed on Ubuntu, run the commands below

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx

After that run the commands below to obtain your free Let’s Encrypt SSL/TLS certificate for the domain example.com

sudo certbot --nginx -d example.com -d www.example.com

After running the above commands, you should get prompted to enter your email and accept the licensing terms. If everything is checked, the client should automatically install the free SSL/TLS certificate and configure the Nginx site to use the certs.

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-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

Choose Yes ( Y ) to share your email address

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: Y

This is how easy is it to obtain your free SSL/TLS certificate for your Nginx powered website.

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

Pick option 2 to redirect all traffic over HTTPS. This is important!

After that, the SSL client should install the cert and configure your website to redirect all traffic over HTTPS.

Congratulations! You have successfully enabled https://example.com and
https://www.example.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2018-02-24. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot 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

The highlighted code block should be added to your Nginx configuration file automatically by Let’s Encrypt certbot. Your site is ready to be used over HTTPS.

server {
    listen 80;
    listen [::]:80;
    root /var/www/html/example.com;
    index  index.php index.html index.htm;
    server_name  example.com www.example.com;
    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    fastcgi_index            index.php;
    fastcgi_pass             unix:/var/run/php/php7.1-fpm.sock; #Ubuntu 17.10
  # fastcgi_pass             unix:/var/run/php/php7.0-fpm.sock; #Ubuntu 17.04
    include                  fastcgi_params;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
 
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    # Redirect non-https traffic to https
    # if ($scheme != "https") {
    #     return 301 https://$host$request_uri;
    # } # managed by Certbot
}

After that, browse to your domain name and the site should respond over HTTPS.

 

Para renovar automáticamente los certificados.

  1. Para probar que todo funciona correcto (dry run — no se renovará nada)
    sudo certbot renew --dry-run
  2. Insertar en el cron
    sudo certbot renew

Cambiar versión php cli

Una vez instalados los diferentes cli de php se puede cambiar facilmente sin tener que crear enlaces simbólicos de la siguiente manera

sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --set php /usr/bin/php7.0
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set php /usr/bin/php7.2

Install Multiple Versions of PHP on Ubuntu 16.04/17.10 via PPA

The easiest way to install multiple versions of PHP is by using the PPA from Ondřej Surý, who is also the maintainer of certbot PPA. To add this PPA, run the following commands in terminal. The software-properties-common package is needed if you want to install software from PPA. It’s installed automatically on Ubuntu desktop, but might be missing on your Ubuntu server.

sudo apt install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt update

 

Now you can install PHP7.2 on Ubuntu 16.04/17.10 by executing the following command.

sudo apt install php7.3 php7.3-fpm
sudo apt install php7.3-mysql php7.3-mbstring php7.3-xml php7.3-gd php7.3-curl php7.3-zip
sudo apt install php7.2 php7.2-fpm

And install some common PHP7.2 extensions.

sudo apt install php7.2-mysql php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl php7.2-zip

You can view all available PHP7.2 extensions by typing in sudo apt install php7.2 and pressing Tab key twice.

 

To install PHP7.1 on Ubuntu 16.04/17.10, run

sudo apt install php7.1 php7.1-fpm

Install some common PHP7.1 extensions.

sudo apt install php7.1-mysql php7.1-mbstring php7.1-xml php7.1-gd php7.1-curl php7.1-zip

You can install PHP7.0 and PHP5.6 in the same way. Simply replace the version number in these commands.

 

Switching PHP Version in Nginx Server Block

It’s very easy to switch PHP version in Nginx server block. As you probably know, Nginx runs PHP code via PHP-FPM, which listens on a Unix socket. The socket file is located in /run/php/ directory.

location ~ \.php$ {
    fastcgi_pass unix:/run/php/php5.6-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
  }

I’m sure you get the idea now. Save and close the file. Then reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Compilar con Laravel Mix y Bootstrap 4

Para compilar y usar Laravel Mix en una instalación limpia debemos seguir estos pasos.

composer create-project laravel/laravel

php artisan preset none

Hacemos un full reset de npm por si acaso

rm -rf node_modules

rm package-lock.json yarn.lock

npm cache clear --force

Instalamos. Al indicar npm install bootstrap nos instalará la última versión. Hay que hacerlo después del instalar el popper ya que bootstrap necesita el popper.

npm install
npm install popper.js --save
npm install bootstrap

Asegurarse de cambiar el fichero resources/assets/sass/app.scss con este contenido

// Fonts
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');

// Variables
@import "variables";

// Bootstrap
@import '~bootstrap/scss/bootstrap';

Asegurarse de cambiar el fichero resources/assets/js/bootstrap.js con este contenido

window._ = require('lodash');
window.Popper = require('popper.js').default;

/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/

try {
   window.$ = window.jQuery = require('jquery');

   require('bootstrap');
} catch (e) {}

/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
* Next we will register the CSRF Token as a common header with Axios so that
* all outgoing HTTP requests automatically have it attached. This is just
* a simple convenience so we don't have to attach every token manually.
*/

let token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
   window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
   console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: process.env.MIX_PUSHER_APP_KEY,
//     cluster: process.env.MIX_PUSHER_APP_CLUSTER,
//     encrypted: true
// });

Compilamos

npm run dev

Tarjetas de prueba para integración REDSYS TPV

Nuevos datos de tarjetas de prueba que ha actualizado REDSYS (2023)

Tarjeta para prueba de operación aceptada

Número de tarjeta 4548810000000003
Caducidad 12/49
Código CVV2 123
Código CIP 123456

Tarjeta para prueba de operación denegada

Número de tarjeta 1111111111111117
Caducidad 12/23
Código CVV2 (No Requerido)

======================================================

Nuevos datos de Pruebas para TPV REDSYS

Numeración: 4548812049400004

Caducidad: 12/34

Código CVV2: 123

Datos para testear integración BIZUM

  • Número de teléfono: 700000000
  • Clave Bizum: 1234
  • Código de autenticación: 12345678
  • El importe máximo de las operaciones será 15€ para evitar que sean denegadas

OLD
Tu banco (ING, Bankia, BBVA, Santanter, Sabadell,…) te pedirá que realices estas dos pruebas:

  • Realizar al menos una operación Autorizada. Utilice esta tarjeta de prueba:
    • Número de tarjeta: 4548812049400004
    • Caducidad: 12/20
    • Código CVV2: 123
    • Código CIP: 123456
  • Realizar al menos una operación Denegada. Utilice esta tarjeta de prueba:
    • Número de tarjeta: 1111111111111117
    • Caducidad: 12/20

Una vez realizadas las pruebas, debes realizar por mail la petición para pasar al entorno REAL (PRODUCCIÓN).

Actualizar o Instalar PHP7 en Ubuntu / Debian

Para actualizar nuestra versión de PHP a la última versión 7.2 seguir los siguientes pasos:

  • Añadir el repositorio de ondrej/php

Ubuntu

sudo add-apt-repository ppa:ondrej/php
sudo apt update

Debian

sudo apt install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update

  • Instalar PHP 7.2

sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm

  • Instalar módulos adicionales

sudo apt install php-mbstring sudo apt install php-xml

Todo esto hará que tengamos ya nuestro php7 por consola, ahora tendremos que configurar que Apache se conecte a php7 en lugar de php5.

  • Instalar módulo php7

apt-get install libapache2-mod-php7.0

  • Desactivar módulo php5

a2dismod php5

  • Desactivar módulo php7

a2dismod php7.2

  • Reiniciar Apache

service apache2 restart

Migrar Prestashop

Proceso de copia y restauración de un respaldo manual de PrestaShop:

  1. Si usas Panel de Hosting (cPanel, Plesk, etc.) accede al Administrador de Archivo.
  2. Navega a la carpeta que contenga la Tienda de PrestaShop.
  3. Selecciona todos los archivos y carpetas y comprímelos en un archivo .zip
  4. Si no puedes hacerlo desde tu Panel de Hosting descarga los archivos/carpetas por FTP.
  5. Accede al gestor de bases de datos phpMyAdmin y exporta la base de datos de tu Tienda en formato comprimido.
  6. Sube los archivos de tu tienda en formato .zip al nuevo Hosting (Administrador de Archivos o FTP).
  7. Crear una base de datos «nueva» en el Hosting nuevo y anota los datos (Nombre base datos/usuario/contraseña).
  8. Desde el nuevo Hosting, Bases de Datos, phpMyAdmin, accede a la nueva base de datos.
  9. Importa la base de datos previamente descargada del anterior Hosting.
  10. Accede nuevamente a tu Panel de Hosting (cPanel), Administrador de Archivos.
  11. Accede a la carpeta /config y edita el archivo settings.inc.php.
  12. Cambia los valores del nombre de la base de datos _DB_NAME_, usuario _DB_USER_ y contraseña _DB_PASSWD_.
  13. Vacía la carpeta /tools/smarty/compile y /tools/smarty/cache

Si además de trasladar tu Tienda PrestaShop a otro servidor o Hosting, vas a trabajar o utilizar un dominio nuevo, entonces deberás realizar lo siguiente:

  1. Accede al Panel de Hosting (cPanel) donde has trasladado la Tienda.
  2. Bases de Datos, phpMyAdmin.
  3. Localiza y edita la tabla ps_configuration.
  4. Edita los registros PS_SHOP_DOMAIN y PS_SHOP_DOMAIN_SSL
  5. Cámbialos por el dominio nuevo.
  6. Guarda los cambios.

Antes de probar que tu Tienda trasladada carga correctamente deberá revisar si los archivos y carpetas trasladados al nuevo Hosting tienen los permisos correctos.

  • Archivos con permisos 644.
  • Carpetas con permisos 755.