How to install Sylius on Debian 8

In this tutorial, we are going to show you how to install Sylius on Debian 8 with MariaDB, PHP-FPM, and Nginx. Sylius is a modern e-commerce application built on top of Symfony 2. This tutorial should work on other Linux based systems, just as well, but was tested and written for Debian 8. Log in to your VPS via SSH

ssh [email protected]

Update the system and install the required packages

[furious]$ sudo apt-get update && sudo apt-get -y upgrade
[furious]$ sudo apt-get install curl

Install MariaDB 10.0

To install the latest version of MariaDB 10, run the following commands:

[furious]$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
[furious]$ sudo add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/10.0/debian jessie main'
[furious]$ sudo apt-get update
[furious]$ sudo apt-get install -y mariadb-server

When the installation is complete, run the following command to ensure the installation:

[furious]$ mysql_secure_installation

Next, we need to create a database for our Sylius installation.

[furious]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE syliusdb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON syliusdb.* TO 'syliusdbuser'@'localhost' IDENTIFIED BY 'syliusdbuserpasswd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> q

Installing Nginx

The latest version of Nginx, version 1.8, is not available through the default Debian repository, so we will add the Dotdeb repository. Open the /etc/apt/sources.list file and add the following lines:

[furious]$ sudo vim /etc/apt/sources.list

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

Get and install the GnuPG key:

[furious]$ curl -sS http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -

System update and Nginx installation:

[furious]$ sudo apt-get update
[furious]$ sudo apt-get -y install nginx

Install PHP and required PHP modules

To install the latest stable PHP version 5.6 and all related modules, run the following command:

[furious]$ sudo apt-get -y install php5-fpm php5-cli php5-gd php5-mysqlnd php5-curl php5-intl

Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the libraries you need for your project.

[furious]$ curl -sS https://getcomposer.org/installer | php
[furious]$ sudo mv composer.phar /usr/local/bin/composer

Install Sylius

[furious]$ cd ~/
[furious]$ composer create-project sylius/sylius:v0.14.0

[furious]$ cd sylius
[furious]$ php app/console sylius:install --env prod

The script will ask you a few questions:

Creating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
sylius.database.driver (pdo_mysql):
sylius.database.host (127.0.0.1):
sylius.database.port (null):
sylius.database.name (sylius): syliusdb
sylius.database.path (null):
sylius.database.user (root): syliusdbuser
sylius.database.password (null): syliusdbuserpasswd

[furious]$ cd sylius
[furious]$ php app/console sylius:install --env prod

The above script will check if everything is set up, launch Sylius correctly, and ask you a few additional questions.

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

[furious]$ cat << EOF | sudo tee /etc/php5/fpm/pool.d/$(whoami).conf
[$(whoami)]
user = $(whoami)  
group = $(whoami)  
listen = /var/run/php5-fpm-$(whoami).sock  
listen.owner = $(whoami)
listen.group = $(whoami)  
listen.mode = 0666  
pm = ondemand  
pm.max_children = 5  
pm.process_idle_timeout = 10s;  
pm.max_requests = 200  
chdir = /
EOF

Reload PHP-FPM:

[furious]$ sudo service php5-fpm restart

Nginx configuration

Create a new Nginx server block with the following content:

[furious]$ cat << EOF | sudo tee /etc/nginx/sites-available/mySylius.ru
server {
    server_name mySylius.ru;
    listen 80;
    root $HOME/sylius/web;

    access_log /var/log/nginx/syliusru-access.log;
    error_log /var/log/nginx/syliusru-error.log;

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

    location ~ ^/app.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm-$(whoami).sock;
        fastcgi_split_path_info ^(.+.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 ~ /.ht {
        deny all;
    }    
}
EOF

Activate the server block by creating a symbolic link:

[furious]$ sudo ln -s /etc/nginx/sites-available/mySylius.com /etc/nginx/sites-enabled/mySylius.ru

Checking Nginx configuration and restarting Nginx:

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

That’s all. You have successfully installed Sylius on Debian 8. For more information on how to manage your Sylius installation, please visit Sylius

Sidebar