ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install Sylius eCommerce application on CentOS 7

Sylius is a free and open source e-commerce application. It is written in PHP using the Symfony framework and uses MySQL/MariaDB to store its data. It is fully customizable and has a full feature set for an online store. It also provides the API which can be used to develop mobile applications. The user interface for both store and administration panel is responsive and mobile ready. It supports almost all the payment providers and has plugin and themes for extending its features.

In this tutorial, we will learn to install Sylius on CentOS 7.

Requirements

Sylius can be installed on systems with at least 1GB RAM. The requirement of RAM increase as the number of products and users increases. You will also need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing Sylius

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Once you have your system updated, run the following command to install few packages on your server.

yum -y install httpd mariadb-server mariadb

The above command will install Apache web server with MariaDB database server. Now you will need to install PHP. Sylius supports both PHP 5.6 and 7. In this tutorial, we will learn to install both PHP 5.6 and 7.1. You must install only one version of PHP. The YUM repository contains PHP version 5.4 only, hence we will need to use the Webtatic repository to install a version of PHP 5.6 or 7.0. Run the following commands for installing EPEL repository as EPEL repository is required before we install Webtatic repository.

yum -y install epel-release yum -y update

Now install Webtatic repository using the following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

To install PHP 5.6 and all the required PHP modules, run the following command.

yum -y install php56w php56w-cli php56w-curl php56w-gd php56w-exif php56w-fileinfo php56w-intl php56w-json php56w-ctype php56w-xml php56w-libxml php56w-mbstring php56w-iconv php56w-posix php56w-pdo php56w-mysqli php56w-opcache

To install PHP 7.1 and all the required PHP modules, run the following command.

yum -y install php71w php71w-cli php71w-curl php71w-gd php71w-exif php71w-fileinfo php71w-intl php71w-json php71w-ctype php71w-xml php71w-libxml php71w-mbstring php71w-iconv php71w-posix php71w-pdo php71w-mysqli php71w-opcache

Make sure that you are using only one of the PHP versions mentioned above. Once you have PHP installed, you can check the version of PHP using the following command.

php -v

You should get following output.

[root@liptan-pc ~]# php -v
PHP 7.1.1 (cli) (built: Jan 19 2017 20:35:16) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Once PHP is installed, you will need to configure few things in your php.ini configuration. Open /etc/php.ini using your favorite editor.

nano /etc/php.ini

If you do not have nano installed, you can install it using yum -y install nano. Scroll down to find the following lines.

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M

You can increase the memory_limit to a higher amount so that the processing of PHP can also be done faster. Further find the following line,

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone = 

Change the timezone according to your country. Save the file and exit from the editor. You also will need to Enable Mod_rewrite by editing /etc/httpd/conf/httpd.conf using your favorite text editor.

nano /etc/httpd/conf/httpd.conf

Find the following line under <Directory "/var/www/html"> block.

AllowOverride None

Change it to AllowOverride All. Now install Composer using the following command. Composer is a dependency manager for PHP.

curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/bin/composer

Now install the latest version of Node.js from the nodesource repository. Run the following command for same.

curl --silent --location https://rpm.nodesource.com/setup_7.x | bash - yum -y install nodejs

To start the Apache web server and enable it to start at boot time, run the following command.

systemctl start httpd systemctl enable httpd

Start MariaDB and enable it to start at boot time using the following commands.

systemctl start mariadb systemctl enable mariadb

Now run the following command to secure your MariaDB installation.

mysql_secure_installation

It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose y and set a strong password for the installation. It will further ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer yes or y to all the questions.

To create a database we will need to login to MySQL command line first. Run the following command for same.

mysql -u root -p

This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your Sylius installation.

CREATE DATABASE sylius;

The above query will create a database named sylius. For the database, you can use any name you prefer at the place of sylius. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. To create a new database user, run the following query.

CREATE USER 'sylius_user'@'localhost' IDENTIFIED BY 'StrongPassword';

The above query will create a user with username sylius_user. You can use any preferred username instead of sylius_user. Replace StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.

GRANT ALL PRIVILEGES ON sylius.* TO 'sylius_user'@'localhost';

Now run the following command to immediately apply the changes on the database privileges.

FLUSH PRIVILEGES;

Exit from MySQL prompt using exit command.

As we have all the dependencies ready, you can install Sylius using composer. Run the following command for same.

cd /var/www/html composer create-project -s beta sylius/sylius-standard sylius

The above command will take few minutes to download and install the PHP dependencies. Once the dependencies are installed, it will ask you to provide few parameter for parameters.yml file. In database_driver, provide mysqli. For database_host, enter 127.0.0.1. For Port, enter the MySQL port number, which is 3306. Further, it will ask for database_name, enter the database name you have created earlier for Sylius. In our case, it is sylius_data. Further, it will you for database_userand database_password. You can use the database user you have created earlier. In our case database_user is sylius_user.

Next, it will ask for the SMTP server to use for sending out emails. Provide smtp for mailer_transport and your SMTP host in mailer_host. Finally provide the username or email and password of the SMTP server. If you think you have made any error then you can configure the parameters.yml using the following command.

cd /var/www/html/sylius nano app/config/parameters.yml

Once the parameters file is populated, you can install Sylius using the following command.

cd /var/www/html/sylius php bin/console sylius:install --env=prod --no-debug

The above command will first check for the all the required dependencies to install Sylius. If you have followed the tutorial correctly, you won't get any error or warnings. It will then install the Sylius application for the production environment. It will also write the database. Further, it will ask you if you want to load the sample data. For production environment you would not want to use the sample data, choose y or N accordingly. Now it will ask you the default shop currency, provide the currency in 3 letter ISO format, eg GBP. Provide the email address and password for the site administrator. Sylius is now installed on your server.

Furthermore, you will need to install a few more Node.js dependencies. Run the following commands to do so.

npm install npm run gulp

Now you will need to create a virtual host file. Run the following command to do so.

nano /etc/httpd/conf.d/yourdomain.com.conf Replace yourdomain.com with your actual domain. Now copy and paste the following lines into the file.
<VirtualHost *:80>
    ServerAdmin admin@yourdomain.com
    DocumentRoot /var/www/html/sylius/web
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com

<Directory /var/www/html/sylius/web> Options FollowSymLinks AllowOverride All Order allow,deny allow from all RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L] </Directory>

ErrorLog /var/log/httpd/yourdomain.com-error_log CustomLog /var/log/httpd/yourdomain.com-access_log common

</VirtualHost>

In the above configuration change yourdomain.com to your actual domain. Once done, you will have to restart your Apache server so that the changes made can take effect.

systemctl restart httpd

Now you will need to disable your SELinux because Sylius does not work with SELinux policies. To temporary disable SELinux without restarting the server, run the following command.

setenforce 0

To completely disable the SELinux you will need to edit /etc/selinux/config file.

nano /etc/selinux/config

If you don't have nano installed, you can install it using yum -y install nano Find the following line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Now you will need to reboot your server so that the new configuration can take effect.

You will also need to provide appropriate ownership of the files to Apache user using the following command.

chown -R apache:apache /var/www/html/sylius/web

You can now browse the following URL in your favorite browser.

http://yourdomain.com

You will see the following shop screen.

You can login to the administrator panel by going to the following link.

http://yourdomain.com/admin

Log in using the credentials provided during installation. You will see the administrator dashboard as shown below.

Conclusion

In this tutorial, we have learned how to install Sylius e-commerce application on CentOS 7. You can now deploy the application on your server to create an online shop for your business.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans