Learn the simple steps to install and set up the Prestashop e-commerce platform on Ubuntu 20.04 or 18.04 LTS Linux server running on localhost or cloud hosting such as AWS, Google, DigitalOcean, etc.
PrestaShop is an open-source and free-to-use e-commerce platform that has been written in PHP and is suitable for all sizes of businesses that want their products to be sold online. However, the appropriate developer and support are necessary.
This free e-commerce platform is available in two versions community and premium which are hosted and managed by the developers themselves. The hosting is provided by IONOS. Well, for those who want to host the Prestashop own their cloud hosting platforms, and have technical knowledge; the community edition is good to go. Whereas all functions and modules are not free, you have to purchase them for a fee. Also, the pre-build modules help a lot to extend the functions of Prestashop as required. Therefore, you don’t have to spend any money on features that you don’t need in the end.
The PrestaShop is quite flexible that’s why it gives the user the choice to opt between numerous themes, modules, and extensions, even if the number cannot keep up with giants like Magento.
The e-commerce platform is ideal for small shops and startups who desire to open online e-stores at relatively low investment but in a very quick way.
System Requirements to install Prestashop on Ubuntu
- Ubuntu 20.04 or 18.04 Linux server with root access
- Prestashop setup files
- Web server: Apache or Nginx
- PHP 5.6+ with extensions: Mcrypt, OpenSSL, Zip, Curl, GD, PDO and memory_limit to “128M” and upload_max_filesize to “16M”
- MySQL 5.0+
Access your Ubuntu 20.04 Server
If you are on the cloud then simply log in and access the terminal using SSH. Or use the local command terminal to do the same. Well, if you are installing Prestashop on a locally installed Linux server or desktop then you would already be there.
Now, first, run the system update and upgrade commands:
sudo apt update sudo apt upgrade
Install Apache and MySQL
You can use Nginx, however, here we are using the command on the popular web server Apache to show this tutorial along with Mysql Database.
sudo apt install apache2
Enable Apache mod_rewrite module
sudo a2enmod rewrite
sudo systemctl restart apache2
Install MySQL server
sudo apt install mysql-server
Get and Install PHP
The latest version of the PHP available on Ubuntu 20.04 LTS by default is v7.4 which could be different depending on when you are performing this tutorial. However, no need to worry about that. Just simply run the below command and the system will install the available supported version of PHP along with other key extensions we need to set up PrestaShop.
sudo apt install php php-cli php-common php-curl php-zip php-gd php-mysql php-xml php-mbstring php-json php-intl
Now, change the memory and upload file limits.
To find the path of your php.ini file run the below command:
php -i | grep -i php.ini
Now, see the path and use it to edit the php.ini file
In our case it was:
sudo nano /etc/php/7.4/cli/php.ini
Find two lines:
Change memory_limit value to 128M
memory_limit= 128M
And also increase the upload size of the file to 16 MB or 32 MB, as per your requirements.
upload_max_filesize = 32M
Finally, restart the apache
sudo systemctl restart apache2
Download PrestaShop
The latest version of the PrestaShop while performing this tutorial was v1.7.6.8. Thus, here we are downloading the same. Here is the Github page link to get the latest release or use the given command to get it.
sudo apt install curl
cd /tmp
curl -s https://api.github.com/repos/PrestaShop/PrestaShop/releases/latest | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d \" | wget -qi -
Unzip and move Prestashop to the www folder
After downloading the latest version of the PrestaShop, unzip it and move the folder to the webroot directory of the web server. So, that it could be used safely for calling through a web browser.
sudo unzip prestashop_*.zip -d /var/www/prestashop/
Note: If you don’t have an unzip tool, then install it using the command:sudo apt install unzip
Change Permission to Apache user
Change the permission of the Prestashop folder to Apache’s www-data user and group, for that the syntax will be:
sudo chown -R www-data: /var/www/prestashop/
Secure MySQL Installation
If you are installing the Prestashop on localhost then you can skip this step, however, for those who want it to use for commercial purposes, it is recommended to run the below command and follow the instructions. This will remove the demo database, force the admin to set a strong password for the MySQL server, and turn off the remote access of MySQL to secure it.
Login to MySQL first:
sudo mysql
Set root password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'MyPassword@123';
Note: Change MyPassword@123 with some strong password, you want to set.
Exit:
exit;
Run the Secure Installation script again.
sudo mysql_secure_installation
The script will ask these questions.
Enter the password for user root: type the root password you set above and then press ENTER.
VALIDATE PASSWORD COMPONENT- If you want to check your root password strength then press Y otherwise type No and hit the Enter key.
Change the password for root? Type No, then ENTER.
Remove anonymous users? Press Y, then ENTER.
Disallow root login remotely? Press Y, then ENTER.
Remove the test database and access it. Press Y, then ENTER.
Reload privilege tables now? Press Y, then ENTER.
Create Database
sudo mysql
Note:presta_h2s
is the database here and prestauser
is the user and the password
is the password we used for the database user. Change them as per your choice.
Create Database
create database `presta_h2s`;
Create a User with a password
create user 'prestauser'@'localhost' identified by 'password';
Grant all permissions of Database to User
GRANT ALL PRIVILEGES ON `presta_h2s`.* to `prestauser`@localhost;
exit;
Configure PrestaShop virtual Host for Apache
In case you are planning to use multiple domains on your Apache webserver then creating a virtual host for Prestashop will be a great idea. This will also let us use our domain for accessing the front-end and backend of the PrestaShop without showing the directory in which we have kept its all files. Therefore create a new Apache configuration file and enable make it.
sudo nano /etc/apache2/sites-available/prestashop.conf
Copy-paste the following lines in the file and save them by using Ctrl+X
and type Y
and hit the Enter
key.
Note: change your_example.com, the domain you want to use for PrestaShop.
<VirtualHost *:80> ServerAdmin admin@your_example.com ServerName your_example.com ServerAlias www.your_example.com DocumentRoot /var/www/prestashop <Directory /var/www/prestashop> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog /var/log/apache2/prestashop-error_log CustomLog /var/log/apache2/prestashop-access_log common </VirtualHost>
Enable the Prestashop Apache configuration and restart the web server.
sudo a2ensite prestashop.conf
Disable the default Apache page
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
Access your Ecommerce Store
Everything is ready and it’s time to access our Ubuntu 20.04 or 18.04 installed PrestaShop eCommerce store for further settings. Open the browser on your local system and type the Ip address or domain.com pointing to the store.
http://ip-address
http://your_domain.com
Select the Language
Choose the language in which you want to install the PrestaShop and then select the Next button.
Accept the License
Information about your Store
Provide the information to be used with the store you want to create such as Shop name, main category, country, time zone, and others.
Connect Database
The database we have created in this article, enter the details of that or any remote database you want to use with your PrestaShop installation.
Wait for a few minutes, once done you will be able to access the installed Ecommerce portable.
Login to PrestaShop BackEnd
To login to the backend, just type admin
at the end of your PrestaShop e-commerce URL. For example http://www.domain.com/admin
or http://ip-address/admin
But as we tried to log in, an error will appear “For security reasons, you can not connect to the back office until you have- deleted the Install folder”
To delete the install folder run the below command on the server:
sudo rm -r /var/www/prestashop/install
After deleting the folder, simply refresh the login page, and this time you will get the login page.
Excelente tutorial….
small typo
sudo apt install myslq-server –> sudo apt install mysql-server
Thanks for pointing it out
Thanks.
Very clear ; the installation was perfect.
In my previous comment i wrote that installation was perfect.
Now with version ps 1.7.7.5 fails at 67% addons addressing module ps_facebook.
Again, after install php7.4-fpm , the problem was solved.
i can’t access the my presta store what should i do?
when i enter the ip_adress is shows me the apache default page??
Disable the default Apache test page:
sudo a2dissite 000-default.conf
After either follows the tutorial again or point your browser to http://your-server-ip/prestashop
How to log in to phpmyadmin ?
Using Database username and password
Once you get to the part where you do the secure install of Mysql the tutorial assumes you already did steps. I was not able set a password because there was no user to assign it to. I had to follow another tutorial to learn how to uninstall mysql. I’ll find another tutorial. Let’s be real, most of us are just copying and pasting because “The author said this is what I do to make it work”. So omitting steps like creating a user in mysql usually leaves us thinking? Why is this so impossible, I did exactly what they said and it still doesn’t work.
I have updated the article, you can now use the command to secure your MySQL instance. Earlier our system, while securing MySQL did not ask to change the root password using the ALTER command, but now it is.
How to launch the phpmyadmin website?
mysite.com/phpmyadmin did not work
for that apart from PrestaShop, you have to first install phpmyAdmin https://www.how2shout.com/linux/how-to-install-phpmyadmin-on-ubuntu-20-04-using-repository/