Deploying a Prestashop ecommerce: the cloud friendly way — Part 3 — Database 🗄
Set up the database for Prestashop.
This article is a continuation of Deploying a Prestashop ecommerce: the cloud friendly way — Part 2
Once the server is configured the next step is to set-up de DB. In this serie of article we want to a cloud friendly Prestashop deployment. Hence the computing part — the current server — should be decoupled from the database. However let’s quickly remember how we would set-up a database inside our server, like in a “normal” Prestashop deployment.
Reminder on the “normal” way of creating and configuring a DB for Prestashop
Once connected to your server, log into the MySQL Shell as root:
mysql -u root -p
Once successful login to the MySQL shell. Now, create database for prestashop. We will call it prestashoptest:
CREATE DATABASE prestashoptest;
Next, you need to create a user that the Prestashop application can use to connect to the database. In this tutorial, we’ll call our user prestashopuser, use the password that you prefer:
CREATE USER prestashopuser@localhost IDENTIFIED BY 'prestashoppsswd';
Now, you have a database and a user for prestashop installation, but these two components have no relationship yet. The user has no access to the database. Fix it by granting the user account access to your database with the following command:
GRANT ALL PRIVILEGES ON prestashoptest.* TO prestashopuser@localhost;
Now the user has access to the database. We need to flush the privileges to tell mysql to reload the user table:
FLUSH PRIVILEGES;
Now sign out from MySQL shell:
exit;
Now we have a DB and user that we can specify during the Prestashop installation.
But in this series of articles we want to deploy Prestashop in a cloud friendly way. Hence let’s setup and external DB.
Set up an external DB
You can use any MySQL compatible — MariaDB, Aurora, etc. — database with Prestashop. AWS RDS offer you a wide variaty of DBs and configurations to suit your needs.
When you create a database in AWS RDS, make sure:
- You add it in the same VPC as the EC2 instance.
- Add a security group with the right ports and sources. See above. The same grup should also be added to the EC2 instance.
- Remember DB name, username, password, endpoint and port.
Cool! Your external DB should be up and running now. Just to recap, we have:
- Created an EC2 Ubuntu 14.04 server
- Configure it for Prestashop with its dependencies
- Created and external DB that we will link during installation
Next step is to set-up and external file system for our Prestashop media files
See Deploying a Prestashop ecommerce: the cloud friendly way — Part 4
If you want to use the file system in your server just skip Part 4 and go to Part 5