System installation on Debian 9 (Stretch)

Here is a quick guide to set up the System Requirements manually on Debian 9. This guide will help you to install all the packages and modules needed for Akeneo PIM on a freshly installed Debian 9 system and then configure the application to match your local installation.

Note

Please perform the following commands as root.

System installation

MySQL 5.7

The easiest way to install MySQL 5.7 is to use the official vendor package.

First, start by installing the MySQL APT repository. It’s a tool that aims to ease the installation and update of MySQL products. During the installation of this tool, one will be asked to choose the versions of the MySQL server to install. MySQL 5.7 has to be chosen. It’s also recommended to disable all non desired tools, such as MySQL Workbench or MySQL Router.

$ apt install lsb-release apt-transport-https ca-certificates
$ wget -O mysql-apt-config.deb https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
$ dpkg -i mysql-apt-config.deb

Now is the time to install what has been configured in the step before:

$ apt update
$ apt install mysql-server

PHP 7.1

The easiest way to install PHP 7.1 is to use Ondrej Sury packages.

First, install the repository:

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

Then, install PHP and the required extensions:

$ apt install php7.1-apcu php7.1-bcmath php7.1-cli php7.1-curl php7.1-fpm php7.1-gd php7.1-intl php7.1-mcrypt php7.1-mysql php7.1-soap php7.1-xml php7.1-zip

For Enterprise Edition, please also install:

$ apt install php7.1-imagick

Elasticsearch 5.5+

The easiest way to install Elasticsearch 5.5+ is to use the official vendor package:

  • first install the PGP key
  • then install the package via the official repository
$ apt install apt-transport-https
$ wget -O - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
$ echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-5.x.list
$ apt update
$ apt install openjdk-8-jre-headless
$ apt install elasticsearch

Apache

$ apt install apache2
$ a2enmod rewrite proxy_fcgi
$ systemctl restart apache2

Note

If you migrate from Apache with mod_php, don’t forget to deactivate it by running the following commands

$ a2dismod php5

System configuration

You now have a system with the right versions of Apache, PHP, MySQL and Elasticsearch. The next step is to configure them to be able to run an Akeneo PIM instance.

MySQL

  • Create a dedicated MySQL database and a dedicated user (called akeneo_pim) for the application
$ mysql -u root -p
mysql> CREATE DATABASE akeneo_pim;
mysql> GRANT ALL PRIVILEGES ON akeneo_pim.* TO akeneo_pim@localhost IDENTIFIED BY 'akeneo_pim';
mysql> EXIT

PHP

  • Setup CLI php.ini file /etc/php/7.1/cli/php.ini
$ sudo vim /etc/php/7.1/cli/php.ini
memory_limit = 1024M
date.timezone = Etc/UTC

Note

Use the time zone matching your location, for example America/Los_Angeles or Europe/Berlin. See http://www.php.net/timezones for the list of all available timezones.

  • Setup FPM php.ini file /etc/php/7.1/fpm/php.ini

Note

If you have several PHP versions on your server, these files can be located in /etc/php/x.x/fpm/php.ini and /etc/php/x.x/cli/php.ini.

$ sudo vim /etc/php/7.1/fpm/php.ini
memory_limit = 512M
date.timezone = Etc/UTC

To avoid spending too much time on permission problems between the CLI user and the FPM user, a good practice is to use the same user for both of them.

Warning

This configuration is aimed to easily set up a development machine. It is absolutely not suited for a production environment.

  • Get your identifiers
$ id
uid=1000(my_user), gid=1000(my_group), ...

In this example, the user is my_user and the group is my_group.

  • Stop FPM
$ sudo service php7.1-fpm stop
  • Open the file /etc/php/7.1/fpm/pool.d/www.conf with your favorite text editor:
$ sudo vi /etc/php/7.1/fpm/pool.d/www.conf
# replace these environment variables:
user = my_user
group = my_group
listen = /run/php/php7.1-fpm.sock
listen.user = www-data
listen.group = www-data

Note

On the default installation, FPM user and group are www-data. listen.user and listen.group must be set on the same user than your Apache server. /run/php/php7.1-fpm.sock is the default socket path. If you changed it in /etc/php/7.1/fpm/pool.d/www.conf, change it in the Apache virtual host too.

  • Restart FPM
$ sudo systemctl restart php7.1-fpm

Elasticsearch

Depending on the volume of data, it can be interesting to tweak the amount of memory usable by the JVM, as recommended by the official documentation. Usually, this configuration lies in the file /etc/elasticsearch/jvm.options.

Apache

Creating the virtual host file

The next step is to create a virtual host for Apache to point to the installation folder of the Akeneo PIM. First, create the file /etc/apache2/sites-available/akeneo-pim.local.conf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<VirtualHost *:80>
    ServerName akeneo-pim.local

    DocumentRoot /path/to/installation/pim-community-standard/web
    <Directory /path/to/installation/pim-community-standard/web>
        AllowOverride None
        Require all granted

        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </Directory>

    <Directory /path/to/installation/pim-community-standard>
        Options FollowSymlinks
    </Directory>

    <Directory /path/to/installation/pim-community-standard/web/bundles>
        RewriteEngine Off
    </Directory>

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php7.1-fpm.sock|fcgi://localhost/"
    </FilesMatch>

    SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0

    ErrorLog ${APACHE_LOG_DIR}/akeneo-pim_error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/akeneo-pim_access.log combined
</VirtualHost>

Note

  • Replace /path/to/installation by the path to the directory where you want to install the PIM.
  • Replace pim-community-standard by pim-enterprise-standard for enterprise edition.
  • /run/php/php7.1-fpm.sock is the default socket path. If you changed it in /etc/php/7.1/fpm/pool.d/www.conf, change it in the virtual host too.
  • Don’t forget to add the web directory of your Symfony application.

Enabling the virtual host

The Apache configuration is done, you need to enable it:

$ sudo apache2ctl configtest
# This will return 'Syntax OK'

$ sudo a2ensite akeneo-pim.local
$ sudo systemctl reload apache2

Adding the virtual host name

The last step is to edit the file /etc/hosts and add the following line:

127.0.0.1    akeneo-pim.local

Node

$ curl -sL https://deb.nodesource.com/setup_8.x | -E bash -
$ apt-get install -y nodejs

Yarn

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
$ apt-get update && sudo apt-get install yarn