Installing PrestaShop locally for development or testing

If you want to develop or experiment with PrestaShop, you should install it locally on your machine. The main advantage is that it makes it possible for you to entirely bypass the process of uploading your files to your online server in order to test it.

Another advantage is that a local test environment enables you to test code without risking breaking your production store. Having a local environment is the essential first step in the path of web development.

Installing any web application locally requires installing an adequate environment, namely the Apache web server, the PHP language interpreter, the MySQL database server, and ideally, a MySQL admin tool such as the phpMyAdmin tool.

This is called an *AMP stack: Apache+MySQL+PHP and the operating system, giving WAMP (Windows+Apache+MySQL+PHP), MAMP (macOS…), and LAMP (Linux+…). Since all of the items packaged are open-source, these installers are, most of the time, free.

Whatever your operating system, you can install this *AMP stack on your operating system or use Docker.

Which installation method is best for me?

You have three options:

  • Install an *AMP stack locally on your operating system, and run PrestaShop there.
  • Install Docker, and run PrestaShop in containers managed by Docker.
  • or install a Virtual Machine software, and run a LAMP stack in a Virtual Machine (not discussed here).

Depending on your experience, you will choose the method you are most at ease with.

If you have no experience, it can be easier to begin with Docker, since you will not need to install the *AMP stack and simply install Docker, create a manifest file, and start the containers with a CLI (Command Line Interface) command.

Install PrestaShop locally with Docker

timeline Setup environment: Install Docker Prepare PrestaShop installation : Create Docker Compose Manifest : Start Docker Compose stack Install PrestaShop : Automatically installed (or manually) Use PrestaShop : You are ready to go
Install PrestaShop locally with Docker

Install PrestaShop locally on an *AMP stack

timeline Setup environment: Install an *AMP stack : Create database Prepare PrestaShop installation : Download PrestaShop : Download dependencies : Setup file permissions Install PrestaShop : Install with GUI : or Install with CLI Use PrestaShop : You are ready to go

Prerequisites

Read System Requirements.

Setup environment

Install an *AMP stack on your operating system

Install an *AMP stack on Unix Install an *AMP stack on Windows Install an *AMP stack on MacOS

Creating a database for your shop

If you install PrestaShop on a web server, you must create the database and give access to a privileged user. You will need this user’s credentials to configure PrestaShop during the installation process.

Using phpMyAdmin

We assume you have root access to phpMyAdmin, and you’re using version 4.x.

  • Sign in to phpMyAdmin as the root user
  • Click User accounts, and then click on Add user account
  • Fill the User name and the Password
  • In the Database for user account, select Create database and Grant all privileges
  • Create a user, database and make sure the COLLATION of your database is utf8mb4_general_ci
From the command line

The database must be created with 4-Byte UTF-8 encoding (utf8mb4_general_ci). For information on installation and configuring MySQL, see the MySQL documentation. Connect as root to your MySQL server. In this example our root user is called adminusername:

$ mysql -u adminusername -p

Create the database and give it a name like “prestashop”:

> CREATE DATABASE prestashop COLLATE utf8mb4_general_ci;

Grant privileges to that database to a new user (the one that PrestaShop will use to connect to the database). Let’s call it “prestashopuser”.

> CREATE USER "prestashopuser"@"hostname" IDENTIFIED BY "somepassword";
> GRANT ALL PRIVILEGES ON prestashop.* TO "prestashopuser"@"hostname";

In the example above,

  • prestashop is the name of the new database
  • hostname is usually localhost (127.0.0.1 or localhost), if you don’t know the value, check with a system administrator
  • somepassword must be a strong password and of course, only known by you

Finally, flush privileges:

> FLUSH PRIVILEGES;

and exit the database connection:

> EXIT;

Prepare PrestaShop installation

Download PrestaShop

The source code of PrestaShop is hosted on the Official PrestaShop GitHub Repository.

You can find all the released versions of PrestaShop here: PrestaShop releases.

Nightly releases of PrestaShop are also generated daily. Their details can be found on a public Google Cloud storage.

Choose the right version for you

PrestaShop comes in two “flavors”:

  • Release package. A zip package, tuned for production environments.
  • Development version. The raw source code as it is on the GitHub repository, including automated test suites, build scripts and source codes for assets that are otherwise compiled (like javascript and css files).

Download files

Prefer cloning the repository using git for the development version.

If you intend to work on PrestaShop itself, we suggest using Git to clone the source code of PrestaShop from the GitHub repository.

Repository branches

As stated above, if you decide to work on PrestaShop itself, it’s best to clone the PrestaShop repository and work using Git. Depending on the version of PrestaShop you want to work on, you will need to choose the right branch:

  • The develop branch contains the current work in progress for the next minor or major version.
    • This is the right branch to contribute new features, refactors, etc.
  • The maintenance branches (8.0.x, …) contain all patches made for each minor version.
    • For example, the 8.0.x branch contains all patches from 8.0.0 to 8.0.99.
    • Whenever a new minor or major version is ready for release, a new maintenance branch is created. For example, 8.0.x for version 8.0.0, 8.1.x for 8.1.0, and so forth.
    • Only the most recent maintenance branch accepts new contributions

Clone the repository using Git or extract the zip package in a prestashop folder inside the document folder of the *AMP installer you chose:

  • XAMPP: C:\xampp\htdocs or /Applications/xampp/htdocs
  • WampServer: C:\wamp\www
  • EasyPHP: C:\easyphp\www
  • MAMP: /Applications/MAMP/htdocs/

Download dependencies

This step is only needed if you downloaded the development version.
PHP dependencies

Use composer to download the project’s dependencies:

cd /path/to/prestashop
composer install
# or alternatively:
make composer
JavaScript and CSS dependencies

PrestaShop uses NPM to manage dependencies and Webpack to compile them into static assets. You only need NodeJS 14.x (version 16.x is recommended, you can get it here), and NPM will take care of it all.

cd /path/to/prestashop
make assets

You can also compile assets for the particular element of the system:

  • make admin-default - for the legacy back office theme
  • make admin-new-theme - for the new back office theme
  • make front-core - front office theme core assets
  • make front-classic - front office default theme assets
  • make front - all assets for the the front office
  • make admin - all assets for the the back office

Alternatively, you can compile assets manually.

Setting up file permissions

PrestaShop needs recursive write permissions on several directories:

├─-admin-dev
|  â””--autoupgrade
├─-app/config
├─-cache
├─-config
├─-download
├─-img
├─-log
├─-mails
├─-modules
├─-override
├─-themes
├─-translations
├─-upload
â””--var

You can set up the appropriate permissions using this command:

$ chmod -R +w admin-dev/autoupgrade app/config var/logs cache config download img log mails modules override themes translations upload var

If you do not have some of the folders above, please create them before changing permissions. For example:

$ mkdir log var/logs

To ease up your life on a development environment, we suggest to make Apache run with your own user and group.

Never do that in production! Carefully change permissions folder by folder instead.

Install PrestaShop

With GUI

Open the PrestaShop installer and follow its instructions.

Depending on whether you downloaded a release package or cloned the repository, the route to the installer will be slightly different:

  • Release package: http://127.0.0.1/prestashop/install
  • Development version: http://127.0.0.1/prestashop/install-dev

You can read the Getting Started guide for more details.

With CLI

You can also install PrestaShop with CLI, please refer to this guide

Troubleshooting

Compile Error: Cannot declare class AppKernel, because the name is already in use

You may find this error message the first time you open up the Back Office.

This problem may arise in case-insensitive file systems like MacOS due to a misconfiguration. Check your Apache configuration and make sure that the root directory path to your PrestaShop matches the capitalization of the actual system path exactly. A typical error is for example having a folder named /path/to/PrestaShop (capital P, capital S) and then configuring it in Apache as /path/to/Prestashop (missing the capital S).