How to Install X-Cart eCommerce platform on Debian 10

X-Cart is an extremely flexible open-source eCommerce platform with tons of features and integrations. X-Cart source code is hosted on Github. This guide describes the process of installing X-Cart 5 on Debian 10 by using Nginx as a web server and MariaDB as a database server.

Requirements

  • PHP version 7.2 or higher
  • PHP extensions: pdo, phar, mysql, mbstring, curl
  • MySQL version 5.7.7 or higher or MariaDB equivalent
  • Nginx

Initial Steps

Check your Debian version:

lsb_release -ds

Set up the timezone:

sudo dpkg-reconfigure tzdata

Update your operating system packages (software). This is an important first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:

sudo apt update && sudo apt upgrade -y

Install some essential packages that are necessary for basic administration of Debian operating system:

sudo apt install -y curl wget vim git unzip socat bash-completion

Step 1 - Install PHP and PHP extensions

Install PHP, as well as the necessary PHP extensions:

sudo apt install -y php php-cli php-fpm php-common php-mbstring php-curl php-mysql php-json php-xml php-phar php-pdo php-gd

To show PHP compiled in modules, you can run:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

Check the PHP version:

php --version

# PHP 7.3.17-0debian0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.17-0debian0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

PHP-FPM service is automatically started and enabled on reboot on Debian 10 system, so there is no need to start and enable it manually. We can move on to the next step, which is the database installation and setup.

Step 2 - Install MariaDB and create a database

Install MySQL:

sudo apt install -y mariadb-server

Check the version:

mysql --version
# mysql  Ver 14.14 Distrib 5.7.27, for Linux (x86_64) using  EditLine wrapper

Run the mysql_secure_installation script to improve the security of your MariaDB installation:

sudo mysql_secure_installation

Log into MariaDB as the root user:

sudo mysql -u root -p
# Enter password:

Create a new MariaDB database and user and remember the credentials:

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

Step 3 - Install acme.sh client and obtain Let's Encrypt certificate (optional)

Securing your website with HTTPS is not necessary, but it is a good practice to secure your site traffic. In order to obtain TLS certificate from Let's Encrypt we will use acme.sh client. Acme.sh is a pure UNIX shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies. 

Download and install acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail [email protected]
source ~/.bashrc
cd ~

Check acme.sh version:

acme.sh --version
# v2.8.6

Obtain RSA and ECC/ECDSA certificates for your domain/hostname:

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

If you want fake certificates for testing you can add the --staging flag to the above commands.

After running the above commands, your certificates and keys will be in:

  • For RSA: /home/username/example.com directory.
  • For ECC/ECDSA: /home/username/example.com_ecc directory.

To list your issued certs you can run:

acme.sh --list

Create a directory to store your certs. We will use the /etc/letsencrypt directory.

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

Install/copy certificates to /etc/letsencrypt directory.

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

All the certificates will be automatically renewed every 60 days.

After obtaining certs exit form the root user and return back to normal sudo user:

exit

Step 4 - Install and configure Nginx

Install Nginx:

sudo apt install -y nginx

Check the Nginx version:

sudo nginx -v
# nginx version: nginx/1.14.0

Configure Nginx for X-Cart by running:

sudo vim /etc/nginx/sites-available/xcart.conf

And populate the file with the below config.

server {
  listen 80;
  listen [::]:80;
  root /var/www/xcart;
  index index.php index.html index.htm;
  server_name example.com;
  location @handler {
    index cart.php;
    rewrite ^/sitemap.xml(\?.+)?$ /cart.php?target=sitemap;
    rewrite ^/(.*)$ /cart.php?url=$1 last;
  }
  location / {
    try_files $uri $uri/ @handler;
  }
  location ~ \.php$ {
    try_files     $uri @handler;
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    include fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Activate the new xcart.conf configuration by linking the file to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/xcart.conf /etc/nginx/sites-enabled

Test the configuration:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx

Step 5 - Install X-Cart

Navigate to the /var/www directory:

cd /var/www/

Download the most recent release of X-Cart from https://www.x-cart.com/download.html and unpack it to your document root:

After downloading, change ownership of the /var/www/xcart directory to www-data:

sudo chown -R www-data:www-data /var/www/xcart

Navigate to example.com/install.php in your web browser and follow the instructions to finish the installation.

Step 6 - Finish setup

Accept the license agreement and click Next.

X-Cart Installation Wizard

Create an Administrator Account.

Add admin account

The installation wizard will check whether your server meets the system requirements for X-Cart 5

Check requirements

Configure database settings:

Database login details

Setting up Directories + Step 6. Building Cache. All the tasks at these steps are fully automated, so you just need to wait and let X-Cart 5 do the job

Installation progress

Now the installation process has been completed.  You can use the links provided to access your store’s Customer front end and Admin area. 

x-Cart Installation successful

Share this page:

0 Comment(s)