How to install Pimcore on Ubuntu

install-pimcore-on-an-ubuntu-vpsIn this tutorial, we will show you how to install Pimcore on an Ubuntu 14.04 VPS with PHP-FPM and Nginx. Pimcore is an open source, content and product management framework. It is fast, flexible, and designer and developer-friendly. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh user@vps_IP

Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common nano wget

Install MariaDB 10.1

To add the MariaDB repository to your sources list and install the latest MariaDB server, run the following commands:

[user]$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
[user]$ sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.1/ubuntu trusty main'
[user]$ sudo apt-get update
[user]$ sudo apt-get install -y mariadb-server

When the installation is complete, run the following command to secure your installation:

[user]$ mysql_secure_installation

Next, we need to create a database for the Pimcore installation.

[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE pimcore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON pimcore.* TO 'pimcore'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Install and configure PHP

To install the latest stable version of PHP version 5.6 and all necessary modules, run:

[user]$ sudo add-apt-repository -y ppa:ondrej/php5-5.6
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install php5-fpm php5-cli php5-json php5-curl php5-gd php5-mysqlnd php5-mcrypt

Create a new PHP-FPM pool for your user:

[user]$ sudo nano /etc/php5/fpm/pool.d/your_user.conf
[your_user]
user = your_user
group = your_user
listen = /var/run/php-fpm-your_user.sock
listen.owner = your_user
listen.group = your_user
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Do not forget to change your_user with your username.
Restart PHP-FPM:

[user]$ sudo service php5-fpm restart

Install Pimcore

Create a root directory for your Pimcore installation using the following command:

[user]$ mkdir -p ~/myPimcore.com

Change to the directory:

[user]$ cd  ~/myPimcore.com

Download the latest release using wget:

[user]$ wget https://www.pimcore.org/download/pimcore-latest.zip

Extract the zip file in document root

[user]$ unzip pimcore-latest.zip

Install and configure Nginx

Ubuntu 14.04 comes with Nginx version 1.4, to install the latest stable version of Nginx version 1.8, run:

[user]$ sudo add-apt-repository -y ppa:nginx/stable
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install nginx

Next, create a new Nginx server block:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
[user]$ sudo nano /etc/nginx/sites-available/myPimcore.com
server {
    listen 80;
    server_name your_domain_name;
    root /home/your_user/myPimcore.com;
    index index.php;

    access_log  /var/log/nginx/pimcore.access.log;
    error_log   /var/log/nginx/pimcore.error.log;

    set $getassets "";
    if ($uri ~* ^/website/var/assets)   { set $getassets "${getassets}A"; }
    if ($request_method = GET)      { set $getassets "${getassets}B"; }
    if ($getassets = "AB") {
        rewrite ^ $uri$args last;
    }

    location ~* ^(/plugins/(?!.*/static).*|^/pimcore/(?!(static|modules/3rdparty)).*|/website/var/(?!tmp|assets|areas)|^.*modules/.*/static.*|^(vendor|tests|node_modules|phing)/.*|^(bower|package|composer|gulpfile)\.) {
        return 403;
    }

    location / {
      try_files $uri $uri/ /index.php$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm-your_user.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~* \.(jpe?g|gif|png|bmp|ico|css|js|pdf|zip|htm|html|docx?|xlsx?|pptx?|txt|wav|swf|avi|mp\d)$ {
        access_log off;
        log_not_found off;
        try_files $uri $uri/ /website/var/assets$uri /index.php?$args;
        expires 1w;
    }

    location ~ /\.ht {
        deny all;
    }
    
    # cache-buster rule for scripts & stylesheets embedded using view helpers
    rewrite ^\/cache-buster-\d+(.*) $1 break;
}

Do not forget to change your_user with your username.

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/myPimcore.com /etc/nginx/sites-enabled/myPimcore.com

Test the Nginx configuration and restart the service:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

Open http://myPimcore.com/ in your favorite web browser and you should see the Pimcore install screen. On this page you’ll need to enter the database details you created earlier, Pimcore admin details and click on the Install now button.

That’s it. You have successfully installed Pimcore on your Ubuntu 14.04 VPS. For more information about how to manage your Pimcore installation, please refer to the official Pimcore documentation.


Of course you don’t have to do any of this if you use one of our Ubuntu VPS Hosting services, in which case you can simply ask our expert Linux admins to install Pimcore for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

9 thoughts on “How to install Pimcore on Ubuntu”

  1. Hi, I have a question regarding the nginx server block, namely
    what should be the server_name ? that IP address doesn’t seem to be the one that everybody should use
    thanks

    Reply
      • Hi, thanks for your reply. I have one more question if I may, what about the /nginx/conf.d directory, should there be a .htaccess file as well? and does the reference to the php5-fpm socket file have to be “php5-fpm.sock” or “php-fpm.sock” ?

        Thanks!

        Reply
        • 1. Nginx doesn’t support .htaccess files. Use your rules inside Nginx configuration.
          2. Use the same reference as defined in /etc/php5/fpm/pool.d/your_user.conf

          Reply
          • Hi, thanks for your reply, I managed to install pimcore but right after logging in I get a white screen. Is that a permission issue? the console window shows a javascript error : ”startup.js?_dc=3744:764 Uncaught TypeError: pimcore.registerNS is not a function”

          • Please check the Pimcore log file for more information about the problem.

            Visit the official wiki at https://www.pimcore.org/wiki/display/PIMCORE/Logging about Pimcore’s logging.

            Thanks.

  2. @admin
    @gladtobehere

    I had the same problem with
    ”startup.js?_dc=3744:764 Uncaught TypeError: pimcore.registerNS is not a function”

    the error is in

    location / {
    try_files $uri $uri/ /index.php$args;
    }

    you can change it to

    location / {
    try_files $uri $uri/ /index.php$is_args$args;
    }

    or have a look to the official configuration for nginx/pimcore
    https://www.pimcore.org/docs/latest/Installation_and_Upgrade/System_Setup_and_Hosting/Nginx_Configuration.html

    GET params where not passed correctly to PHP

    Reply
    • Our tutorial is tested and working without a problem. Have you made sure that you’ve followed the instructions correctly?
      You can try doing all of the described steps again and be more careful or check the log files for more information about the problem.

      Reply
  3. If you are experiencing this error ”startup.js?_dc=3744:764 Uncaught TypeError: pimcore.registerNS is not a function”
    All you have to do is clear your pimcore cache by running the following:
    php pimcore/cli/console.php cache:clear

    Reply

Leave a Comment