How to install Sylius on Debian 8

install-sylius-on-a-debian-8-vpsIn this tutorial, we will explain how to install Sylius on a Debian 8 VPS with MariaDB, PHP-FPM and Nginx. Sylius is a modern e-commerce application build on top of Symfony 2 components. This guide should work on other Linux VPS systems as well but was tested and written for an Debian 8 VPS.

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages

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

Install MariaDB 10.0

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

[user]$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
[user]$ sudo add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/10.0/debian jessie 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 our Sylius installation.

[user]$ 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

Install Nginx

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

[user]$ sudo vim /etc/apt/sources.list
deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

Fetch and install the GnuPG key:

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

Update the system and install Nginx:

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

Install PHP and required PHP modules

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

[user]$ 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 all the required libraries you need for your project.

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

Install Sylius

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

The script will ask you several question:

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
[user]$ cd sylius
[user]$ php app/console sylius:install --env prod

The script above will check if everything is setup to run Sylius properly and ask you few additional questions.

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

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]$ 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

Restart PHP-FPM:

[user]$ sudo service php5-fpm restart

Nginx configuration

Create a new Nginx server block with the following content:

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

    access_log /var/log/nginx/sylius-access.log;
    error_log /var/log/nginx/sylius-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 :

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

Test the Nginx configuration and restart nginx:

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

That’s it. You have successfully installed Sylius on your Debian 8 VPS. For more information about how to manage your Sylius installation, please refer to the Sylius website.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this 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.

1 thought on “How to install Sylius on Debian 8”

Leave a Comment