Book Image

Modernizing Enterprise CMS Using Pimcore

By : Daniele Fontani, Marco Guiducci, Francesco Minà
Book Image

Modernizing Enterprise CMS Using Pimcore

By: Daniele Fontani, Marco Guiducci, Francesco Minà

Overview of this book

Used by over eighty thousand companies worldwide, Pimcore is the leading open source enterprise-level content management system (CMS) solution. It is an impressive alternative to conventional CMSes and is ideal for creating e-commerce and complex enterprise websites. This book helps developers working with standard CMSes such as WordPress and Drupal to use their knowledge of CMSes to learn Pimcore CMS in a practical way. You'll start by learning what Pimcore is and explore its various services such as PIM, MDM, and DAM. The book then shows you various techniques for developing custom websites in Pimcore based on the scale of your organization. You'll learn how to use Pimcore to improve the digital transformation of a company by implementing enterprise Pimcore features. As you advance, you'll discover Pimcore's capabilities and features that make it a faster and more secure alternative to traditional CMSes. As well as demonstrating practical use cases, Modernizing Enterprise CMS Using Pimcore can help you understand the benefits of using Pimcore as a CMS solution, sharing best practices and proven techniques for designing professional Pimcore sites. By the end of this book, you'll be a trained Pimcore developer, able to create complex websites, and be well-versed in Pimcore's enterprise features such as MDM, PIM, and DAM.
Table of Contents (16 chapters)

Installing Pimcore from Composer (without Docker)

Even though we encourage the use of Docker and the book is based on Docker containers, we should not fail to explain how to perform a vanilla installation. As you will learn after following all the steps, the process of installing Pimcore the vanilla way is basically the same as what is done internally by the Docker container. The most important difference is that using Docker, you do not have to grapple with the server, dependencies, and so on. This is because Pimcore is released through Composer, the PHP package manager. This makes the installation the same in all possible scenarios. If you are inside a Docker container, a virtual machine, or your PC, Composer is the same.

So, all you need to do to install Pimcore in your local environment is to run a few commands in the terminal after you have installed all the required dependencies mentioned in the Technical requirements section:

Note

This book uses a ready-to-use Docker container for this process. We are including this section to explain how a low-level installation of Pimcore works, but if you are interested in starting Pimcore quickly, you can skip this section and go to Installing Pimcore using Docker. Moreover, unlike Docker, using Composer in your local environment has a lot of dependencies (MySQL, Composer, and others) and needs complex PHP tuning. This is well covered by the Pimcore documentation and you can follow the official guidance for that. In this section, we will cover Pimcore's installation, assuming that you already have your environment set up and you just need to install Pimcore.

  1. Create a folder in your filesystem. We assume that this folder is named my-project. There are no restrictions from Pimcore about where you can create that folder. It depends on your local settings (that is, it has to be accessible to your web server). For example, when using Apache, a common value is /var/www/html.
  2. Run the following command:
    COMPOSER_MEMORY_LIMIT=-1 composer create-project Pimcore/skeleton my-project

    This command will install the Pimcore/skeleton package in the my-project folder. This will also create a new folder in your filesystem, and the final path will be /your/project/my-project. Pimcore is available in two different releases: skeleton and demo. When starting a new project, it is recommended that you use the skeleton template, but if you want to see Pimcore's features, you can install the demo package to get a website with data that is ready to test. The process will take a moment, and you will see some console output that will display its progress.

  3. If you do not have one yet, you will need to create a database. To do this, type the following command in your terminal:
    mysql -u root -p -e "CREATE DATABASE project_database charset=utf8mb4;"

    You can fine-tune the preceding command by changing the host, username, and password to fit your needs, or you can use a visual tool such as MySQL Workbench. You can also change the database name. The most important thing to remember is to use the right charset, utf8mb4, to fully support Unicode encoding.

  4. Edit your Apache virtual host. It needs to point to the web folders inside my-project, so your Apache file should have the document root set as follows:
    DocumentRoot /my/project/my-project/public

    Note that Pimcore needs to be installed outside of the document root. So, if you installed it inside my-project, you cannot use this folder as the document root. This, besides causing functional issues, will expose you to security issues in terms of allowing access to protected content. A complete configuration for Apache can be found here: https://pimcore.com/docs/pimcore/current/Development_Documentation/Installation_and_Upgrade/System_Setup_and_Hosting/Apache_Configuration.html.

  5. Set the filesystem permissions. The Apache user (or the Nginx user, depending on which web server you are using) will need to access all the files inside the Pimcore directory and will need additional write permission for the /var and /public/var folders. In most cases, this is done by entering the following code:
    chown -R www-data .
    chmod 764 ./var
    chmod 764 ./public/var

    Here, chown makes www-data (usually the group where the user that runs the web server belongs) the group owner of the Pimcore folder, and then chmod adds write permission to the required folders.

  6. Navigate to the Pimcore directory and type the following command:
    cd ./my-project

    This will bring you to the /your/project/my-project directory.

  7. Launch the Pimcore installation by typing the following command:
    ./vendor/bin/Pimcore-install --MySQL-host-socket=localhost --MySQL-username=yourusename --MySQL-password=yourpassword --MySQL-database=databasename

    Here, MySQL-host-socket is the hostname of the MySQL database, MySQL-username and MySQL-password are the database credentials, and MySQL-database is the database name. This command will set up the Pimcore connection settings and will install Pimcore in the database. You will be prompted to choose the admin user for the Pimcore back office; we will choose admin\pimcore as a credential, but you can use whatever you want (although the use of simple passwords in your production environment is discouraged).

    In the following screenshot, we can see the console output that we receive after launching the installation command:

    Figure 2.1 – Pimcore installation and admin password prompt

    Figure 2.1 – Pimcore installation and admin password prompt

  8. You will be prompted to enter the username and password of the Pimcore administration user, and then you will be asked to confirm the installation.
  9. The final step is to set up the maintenance job. Like many platforms, Pimcore needs to perform periodic maintenance tasks, such as log rotation and cleaning temporary or old data. Pimcore's guidelines ask us to execute this task every 5 minutes to make sure the environment is always efficient. To do this, we need to add a cron job. Type the following:
    crontab -e
  10. Then, enter the following content into crontab:
    */5 * * * * /your/project/bin/console maintenance

The configuration activates the maintenance job by running the console executable, with the maintenance parameter, which invokes the standard Pimcore maintenance job.

In this section, we introduced the Pimcore installation process. These instructions are quite easy to follow, but you need to have the hosting environment already installed. Installing Apache, MySQL, and configuring the network part is standard for most developers, but some system engineering knowledge is required that not all developers have (and maybe do not want to learn). Moreover, with this setup, you may have to replicate most of your jobs each time you set up a new project.

In the next section, we will learn how things are so much easier with Docker, seeing how you can do the same as what we achieved here (and maybe more) in just two commands.